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
58 changes: 0 additions & 58 deletions cmd/crossplane/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import (

"github.com/crossplane/crossplane-runtime/v2/pkg/errors"
"github.com/crossplane/crossplane-runtime/v2/pkg/logging"
"github.com/crossplane/crossplane-runtime/v2/pkg/meta"
"github.com/crossplane/crossplane-runtime/v2/pkg/resource"
"github.com/crossplane/crossplane-runtime/v2/pkg/resource/unstructured/composed"
ucomposite "github.com/crossplane/crossplane-runtime/v2/pkg/resource/unstructured/composite"

Expand All @@ -42,14 +40,6 @@ import (
renderv1alpha1 "github.com/crossplane/cli/v2/proto/render/v1alpha1"
)

// Annotations added to composed resources.
const (
AnnotationKeyCompositionResourceName = "crossplane.io/composition-resource-name"
AnnotationKeyCompositeName = "crossplane.io/composite"
AnnotationKeyClaimNamespace = "crossplane.io/claim-namespace"
AnnotationKeyClaimName = "crossplane.io/claim-name"
)

// CompositionInputs contains all inputs to the render process.
type CompositionInputs struct {
CompositeResource *ucomposite.Unstructured
Expand Down Expand Up @@ -154,54 +144,6 @@ func RewriteAddressesForDocker(fns []*renderv1alpha1.FunctionInput) []*renderv1a
return fns
}

// GetSecret retrieves the secret with the specified name and namespace from the provided list of secrets.
func GetSecret(name string, nameSpace string, secrets []corev1.Secret) (*corev1.Secret, error) {
for _, s := range secrets {
if s.GetName() == name && s.GetNamespace() == nameSpace {
return &s, nil
}
}

return nil, errors.Errorf("secret %q not found", name)
}

// SetComposedResourceMetadata sets standard, required composed resource
// metadata. It mirrors the behavior of RenderComposedResourceMetadata in
// Crossplane's composition controller.
func SetComposedResourceMetadata(cd resource.Object, xr resource.LegacyComposite, name string) error {
namePrefix := xr.GetLabels()[AnnotationKeyCompositeName]
if namePrefix == "" {
namePrefix = xr.GetName()
}

if cd.GetName() == "" && cd.GetGenerateName() == "" {
cd.SetGenerateName(namePrefix + "-")
}

if xr.GetNamespace() != "" {
cd.SetNamespace(xr.GetNamespace())
}

meta.AddAnnotations(cd, map[string]string{AnnotationKeyCompositionResourceName: name})
meta.AddLabels(cd, map[string]string{AnnotationKeyCompositeName: namePrefix})

if xr.GetLabels()[AnnotationKeyClaimName] != "" && xr.GetLabels()[AnnotationKeyClaimNamespace] != "" {
meta.AddLabels(cd, map[string]string{
AnnotationKeyClaimNamespace: xr.GetLabels()[AnnotationKeyClaimNamespace],
AnnotationKeyClaimName: xr.GetLabels()[AnnotationKeyClaimName],
})
} else if ref := xr.GetClaimReference(); ref != nil {
meta.AddLabels(cd, map[string]string{
AnnotationKeyClaimNamespace: ref.Namespace,
AnnotationKeyClaimName: ref.Name,
})
}

or := meta.AsController(meta.TypedReferenceTo(xr, xr.GetObjectKind().GroupVersionKind()))

return errors.Wrapf(meta.AddControllerReference(cd, or), "cannot set composite resource %q as controller ref of composed resource", xr.GetName())
}

// injectNetworkAnnotation sets the Docker network annotation on all functions
// so their containers join the specified network.
func injectNetworkAnnotation(fns []pkgv1.Function, networkName string) {
Expand Down
241 changes: 0 additions & 241 deletions cmd/crossplane/render/render_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/crossplane/render/xr/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (c *Cmd) Run(k *kong.Context, log logging.Logger, sp terminal.SpinnerPrinte
for i := range out.ComposedResources {
_, _ = fmt.Fprintln(k.Stdout, "---")
if err := s.Encode(&out.ComposedResources[i], k.Stdout); err != nil {
return errors.Wrapf(err, "cannot marshal composed resource %q to YAML", out.ComposedResources[i].GetAnnotations()[render.AnnotationKeyCompositionResourceName])
return errors.Wrapf(err, "cannot marshal composed resource %q to YAML", out.ComposedResources[i].GetAnnotations()[xcrd.AnnotationKeyCompositionResourceName])
}
}

Expand Down
Loading