Skip to content

Commit

Permalink
Merge pull request #5031 from phisco/dev/trace-xrc-secret
Browse files Browse the repository at this point in the history
fix(cli): trace show xrc connection secret too
  • Loading branch information
phisco committed Nov 22, 2023
2 parents a6e7ebf + 558fd84 commit e7f998d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/crank/beta/trace/internal/resource/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func getResourceChildrenRefs(r *Resource, getConnectionSecrets bool) []v1.Object
return nil
}

if obj.GetNamespace() != "" {
if xrcNamespace := obj.GetNamespace(); xrcNamespace != "" {
// This is an XRC, get the XR ref, we leave the connection secret
// handling to the XR
xrc := claim.Unstructured{Unstructured: obj}
Expand All @@ -145,6 +145,18 @@ func getResourceChildrenRefs(r *Resource, getConnectionSecrets bool) []v1.Object
Namespace: ref.Namespace,
})
}
if getConnectionSecrets {
xrcSecretRef := xrc.GetWriteConnectionSecretToReference()
if xrcSecretRef != nil {
ref := v1.ObjectReference{
APIVersion: "v1",
Kind: "Secret",
Name: xrcSecretRef.Name,
Namespace: xrcNamespace,
}
refs = append(refs, ref)
}
}
return refs
}
// This could be an XR or an MR
Expand Down
6 changes: 6 additions & 0 deletions cmd/crank/beta/trace/internal/resource/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ func TestGetResourceChildrenRefs(t *testing.T) {
},
want: want{
refs: []v1.ObjectReference{
{
APIVersion: "v1",
Kind: "Secret",
Namespace: "ns-1",
Name: "secret-1",
},
{
APIVersion: "example.com/v1",
Kind: "XR",
Expand Down

0 comments on commit e7f998d

Please sign in to comment.