Reallow name, namepsace, generated-name of a composed to be patched
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
This commit is contained in:
parent
0d4427da14
commit
ff60580885
|
|
@ -336,6 +336,13 @@ func (r *APIDryRunRenderer) Render(ctx context.Context, cp resource.Composite, c
|
||||||
return errors.New(errNamePrefix)
|
return errors.New(errNamePrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unmarshalling the template will overwrite any existing fields, so we must
|
||||||
|
// restore the existing name, if any. We also set generate name in case we
|
||||||
|
// haven't yet named this composed resource.
|
||||||
|
cd.SetGenerateName(cp.GetLabels()[xcrd.LabelKeyNamePrefixForComposed] + "-")
|
||||||
|
cd.SetName(name)
|
||||||
|
cd.SetNamespace(namespace)
|
||||||
|
|
||||||
onlyPatches := []v1.PatchType{v1.PatchTypeFromCompositeFieldPath, v1.PatchTypeCombineFromComposite}
|
onlyPatches := []v1.PatchType{v1.PatchTypeFromCompositeFieldPath, v1.PatchTypeCombineFromComposite}
|
||||||
for i, p := range t.Patches {
|
for i, p := range t.Patches {
|
||||||
if err := p.Apply(cp, cd, onlyPatches...); err != nil {
|
if err := p.Apply(cp, cd, onlyPatches...); err != nil {
|
||||||
|
|
@ -354,13 +361,6 @@ func (r *APIDryRunRenderer) Render(ctx context.Context, cp resource.Composite, c
|
||||||
SetCompositionResourceName(cd, *t.Name)
|
SetCompositionResourceName(cd, *t.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshalling the template will overwrite any existing fields, so we must
|
|
||||||
// restore the existing name, if any. We also set generate name in case we
|
|
||||||
// haven't yet named this composed resource.
|
|
||||||
cd.SetGenerateName(cp.GetLabels()[xcrd.LabelKeyNamePrefixForComposed] + "-")
|
|
||||||
cd.SetName(name)
|
|
||||||
cd.SetNamespace(namespace)
|
|
||||||
|
|
||||||
// We do this last to ensure that a Composition cannot influence owner (and
|
// We do this last to ensure that a Composition cannot influence owner (and
|
||||||
// especially controller) references.
|
// especially controller) references.
|
||||||
or := meta.AsController(meta.TypedReferenceTo(cp, cp.GetObjectKind().GroupVersionKind()))
|
or := meta.AsController(meta.TypedReferenceTo(cp, cp.GetObjectKind().GroupVersionKind()))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue