@@ -473,6 +473,70 @@ var _ = Describe("getIgnitionConfig", func() {
473473 Entry ("contains space" , "$VAR NAME" ),
474474 )
475475
476+ Context ("ignition-override annotation" , func () {
477+ const validOverride = `{"ignition":{"version":"3.1.0"},"storage":{"files":[{"path":"/etc/override-file","contents":{"source":"data:,"},"mode":384}]}}`
478+
479+ It ("should merge valid ignition-override annotation into host ignition" , func () {
480+ config := & bootstrapv1alpha2.OpenshiftAssistedConfig {
481+ ObjectMeta : metav1.ObjectMeta {
482+ Annotations : map [string ]string {
483+ bootstrapv1alpha2 .IgnitionOverrideAnnotation : validOverride ,
484+ },
485+ },
486+ Spec : bootstrapv1alpha2.OpenshiftAssistedConfigSpec {
487+ NodeRegistration : bootstrapv1alpha2.NodeRegistrationOptions {
488+ KubeletExtraLabels : []string {"zone=east" },
489+ },
490+ },
491+ }
492+
493+ ignitionJSON , err := getIgnitionConfig (config )
494+ Expect (err ).NotTo (HaveOccurred ())
495+ Expect (ignitionJSON ).To (ContainSubstring (`/etc/override-file` ))
496+ Expect (ignitionJSON ).To (ContainSubstring (`kubelet_custom_labels` ))
497+ })
498+
499+ It ("should ignore annotation when value is not valid JSON" , func () {
500+ config := & bootstrapv1alpha2.OpenshiftAssistedConfig {
501+ ObjectMeta : metav1.ObjectMeta {
502+ Annotations : map [string ]string {
503+ bootstrapv1alpha2 .IgnitionOverrideAnnotation : `not-json` ,
504+ },
505+ },
506+ Spec : bootstrapv1alpha2.OpenshiftAssistedConfigSpec {
507+ NodeRegistration : bootstrapv1alpha2.NodeRegistrationOptions {
508+ KubeletExtraLabels : []string {"zone=east" },
509+ },
510+ },
511+ }
512+
513+ ignitionJSON , err := getIgnitionConfig (config )
514+ Expect (err ).NotTo (HaveOccurred ())
515+ Expect (ignitionJSON ).NotTo (ContainSubstring (`/etc/override-file` ))
516+ Expect (ignitionJSON ).To (ContainSubstring (`kubelet_custom_labels` ))
517+ })
518+
519+ It ("should return error when annotation is valid JSON but invalid ignition" , func () {
520+ config := & bootstrapv1alpha2.OpenshiftAssistedConfig {
521+ ObjectMeta : metav1.ObjectMeta {
522+ Annotations : map [string ]string {
523+ // Unknown ignition version so parse fails
524+ bootstrapv1alpha2 .IgnitionOverrideAnnotation : `{"ignition":{"version":"99.0.0"}}` ,
525+ },
526+ },
527+ Spec : bootstrapv1alpha2.OpenshiftAssistedConfigSpec {
528+ NodeRegistration : bootstrapv1alpha2.NodeRegistrationOptions {
529+ KubeletExtraLabels : []string {"zone=east" },
530+ },
531+ },
532+ }
533+
534+ _ , err := getIgnitionConfig (config )
535+ Expect (err ).To (HaveOccurred ())
536+ Expect (err .Error ()).To (ContainSubstring (bootstrapv1alpha2 .IgnitionOverrideAnnotation ))
537+ })
538+ })
539+
476540 Context ("ProviderID" , func () {
477541 It ("should write KUBELET_PROVIDERID with static value" , func () {
478542 config := & bootstrapv1alpha2.OpenshiftAssistedConfig {
0 commit comments