Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: nop.example.org/v1alpha1
kind: NopResource
metadata:
annotations:
crossplane.io/composition-resource-name: only
name: watch-cancelled-only
spec:
forProvider:
configData: watch-cancelled
status:
conditions:
- type: Synced
status: "True"
reason: ReconcileSuccess
lastTransitionTime: "2026-01-01T00:00:00Z"
- type: Ready
status: "True"
reason: Available
lastTransitionTime: "2026-01-01T00:00:00Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: nop.example.org/v1alpha1
kind: NopResource
metadata:
annotations:
crossplane.io/composition-resource-name: only
name: watch-composed-only
spec:
forProvider:
configData: watch-composed
status:
conditions:
- type: Synced
status: "True"
reason: ReconcileSuccess
lastTransitionTime: "2026-01-01T00:00:00Z"
- type: Ready
status: "True"
reason: Available
lastTransitionTime: "2026-01-01T00:00:00Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: nop.example.org/v1alpha1
kind: NopResource
metadata:
annotations:
crossplane.io/composition-resource-name: only
name: watch-deleted-only
spec:
forProvider:
configData: watch-deleted
status:
conditions:
- type: Synced
status: "True"
reason: ReconcileSuccess
lastTransitionTime: "2026-01-01T00:00:00Z"
- type: Ready
status: "True"
reason: Available
lastTransitionTime: "2026-01-01T00:00:00Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: nop.example.org/v1alpha1
kind: NopResource
metadata:
annotations:
crossplane.io/composition-resource-name: only
name: watch-xr-only
spec:
forProvider:
configData: watch-xr
status:
conditions:
- type: Synced
status: "True"
reason: ReconcileSuccess
lastTransitionTime: "2026-01-01T00:00:00Z"
- type: Ready
status: "True"
reason: Available
lastTransitionTime: "2026-01-01T00:00:00Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# A cluster-scoped XR the watch-cancelled case of TestTraceWatchIntegration watches.
apiVersion: trace.example.org/v1alpha1
kind: XNop
metadata:
name: watch-cancelled
spec:
coolField: watch-cancelled
compositionRef:
name: xnops.trace.example.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# A cluster-scoped XR the watch-composed case of TestTraceWatchIntegration watches.
apiVersion: trace.example.org/v1alpha1
kind: XNop
metadata:
name: watch-composed
spec:
coolField: watch-composed
compositionRef:
name: xnops.trace.example.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# A cluster-scoped XR the watch-deleted case of TestTraceWatchIntegration watches.
apiVersion: trace.example.org/v1alpha1
kind: XNop
metadata:
name: watch-deleted
spec:
coolField: watch-deleted
compositionRef:
name: xnops.trace.example.org
9 changes: 9 additions & 0 deletions cmd/crossplane/trace/testdata/integration/xr-watch-xr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# A cluster-scoped XR the watch-xr case of TestTraceWatchIntegration watches.
apiVersion: trace.example.org/v1alpha1
kind: XNop
metadata:
name: watch-xr
spec:
coolField: watch-xr
compositionRef:
name: xnops.trace.example.org
14 changes: 12 additions & 2 deletions cmd/crossplane/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ type Cmd struct {
Watch bool `default:"false" help:"Watch for changes until resource deletion." name:"watch" short:"w"`

Impersonation kube.ImpersonationFlags `embed:""`

// Hooks is for tests; the CLI never sets it.
Hooks *Hooks `kong:"-"`
}

// Hooks change how a trace command runs, so a test can run the real command.
// Fields left zero keep the CLI's behavior.
type Hooks struct {
// Headless runs watch mode without reading the terminal and at a fixed
// window size, since tests have no TTY.
Headless bool
}

// Help returns help message for the trace command.
Expand Down Expand Up @@ -141,8 +152,7 @@ func (c *Cmd) setupKubeClient(logger logging.Logger) (clientcmd.ClientConfig, cl
}

// Run runs the trace command.
func (c *Cmd) Run(k *kong.Context, logger logging.Logger) error {
ctx := context.Background()
func (c *Cmd) Run(ctx context.Context, k *kong.Context, logger logging.Logger) error {
logger = logger.WithValues("Resource", c.Resource, "Name", c.Name)

// Init new printer
Expand Down
Loading
Loading