@@ -136,7 +136,7 @@ func (o *InitOptions) Run(ctx context.Context) error {
136136 }
137137 for _ , evapb := range evapbs .Items {
138138 if evapb .Name != MCPPurposeOverrideValidationPolicyName {
139- setupLog .Info ("Deleting existing ValidatingAdmissionPolicyBinding with architecture immutability purpose" , "name" , evapb .Name )
139+ log .Info ("Deleting existing ValidatingAdmissionPolicyBinding with architecture immutability purpose" , "name" , evapb .Name )
140140 if err := onboardingCluster .Client ().Delete (ctx , & evapb ); client .IgnoreNotFound (err ) != nil {
141141 return fmt .Errorf ("error deleting ValidatingAdmissionPolicyBinding '%s': %w" , evapb .Name , err )
142142 }
@@ -148,13 +148,13 @@ func (o *InitOptions) Run(ctx context.Context) error {
148148 }
149149 for _ , evap := range evaps .Items {
150150 if evap .Name != MCPPurposeOverrideValidationPolicyName {
151- setupLog .Info ("Deleting existing ValidatingAdmissionPolicy with architecture immutability purpose" , "name" , evap .Name )
151+ log .Info ("Deleting existing ValidatingAdmissionPolicy with architecture immutability purpose" , "name" , evap .Name )
152152 if err := onboardingCluster .Client ().Delete (ctx , & evap ); client .IgnoreNotFound (err ) != nil {
153153 return fmt .Errorf ("error deleting ValidatingAdmissionPolicy '%s': %w" , evap .Name , err )
154154 }
155155 }
156156 }
157- setupLog .Info ("creating/updating ValidatingAdmissionPolicies to prevent undesired changes to the MCP purpose override label ..." )
157+ log .Info ("creating/updating ValidatingAdmissionPolicies to prevent undesired changes to the MCP purpose override label ..." )
158158 vapm := resources .NewValidatingAdmissionPolicyMutator (MCPPurposeOverrideValidationPolicyName , admissionv1.ValidatingAdmissionPolicySpec {
159159 FailurePolicy : ptr .To (admissionv1 .Fail ),
160160 MatchConstraints : & admissionv1.MatchResources {
@@ -189,6 +189,10 @@ func (o *InitOptions) Run(ctx context.Context) error {
189189 Expression : `request.operation == "CREATE" || (variables.oldPurposeOverrideLabel == variables.purposeOverrideLabel)` ,
190190 Message : fmt .Sprintf (`The label "%s" is immutable, it cannot be added after creation and is not allowed to be changed or removed once set.` , corev2alpha1 .MCPPurposeOverrideLabel ),
191191 },
192+ {
193+ Expression : `variables.purposeOverrideLabel.contains("mcp")` ,
194+ Message : fmt .Sprintf (`The value of the label "%s" must contain "mcp".` , corev2alpha1 .MCPPurposeOverrideLabel ),
195+ },
192196 },
193197 })
194198 vapm .MetadataMutator ().WithLabels (map [string ]string {
@@ -231,7 +235,7 @@ func (o *InitOptions) Run(ctx context.Context) error {
231235 if err := resources .CreateOrUpdateResource (ctx , onboardingCluster .Client (), vapbm ); err != nil {
232236 return fmt .Errorf ("error creating/updating ValidatingAdmissionPolicyBinding for mcp purpose override validation: %w" , err )
233237 }
234- setupLog .Info ("ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding for mcp purpose override validation created/updated" )
238+ log .Info ("ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding for mcp purpose override validation created/updated" )
235239
236240 log .Info ("Finished init command" )
237241 return nil
0 commit comments