@@ -418,6 +418,11 @@ consumes:
418418 Expect (outMeta .RequiresProductVersions [0 ].Name ).To (Equal ("some-other-product" ))
419419 Expect (outMeta .RequiresProductVersions [0 ].Version ).To (Equal (">=1.0.0" ))
420420 Expect (outMeta .RequiresProductVersions [0 ].Optional ).To (BeTrue ())
421+ Expect (outMeta .UsesKubernetesFeatures ).To (HaveLen (2 ))
422+ Expect (outMeta .UsesKubernetesFeatures [0 ].Name ).To (Equal ("gpu-scheduling" ))
423+ Expect (outMeta .UsesKubernetesFeatures [0 ].Optional ).To (BeFalse ())
424+ Expect (outMeta .UsesKubernetesFeatures [1 ].Name ).To (Equal ("node-local-storage" ))
425+ Expect (outMeta .UsesKubernetesFeatures [1 ].Optional ).To (BeTrue ())
421426 })
422427 It ("creates empty instance_group and jobs directories" , func () {
423428 Expect (filepath .Join (outputPath , "instance_groups" )).To (BeADirectory ())
@@ -600,6 +605,51 @@ consumes:
600605 Expect (outMeta .RequiresProductVersions ).To (BeEmpty ())
601606 })
602607 })
608+ When ("the tile declares no kubernetes features" , func () {
609+ // Ops Manager rejects uses_kubernetes_features on a tile that is not a
610+ // kubernetes consumer, so an absent block must stay absent rather than
611+ // baking out as an empty list.
612+ BeforeEach (func () {
613+ m := models.Metadata {
614+ Name : "k8s-tile-test" ,
615+ Label : "test tile" ,
616+ IconImage : "$( icon )" ,
617+ MetadataVersion : "3.2.0" ,
618+ MinimumVersionForUpgrade : "0.0.0" ,
619+ ProductVersion : "$( version )" ,
620+ Rank : 1 ,
621+ Serial : false ,
622+ PropertyBlueprints : []string {
623+ `$( property "database_name" )` ,
624+ `$( property "admin_password" )` ,
625+ },
626+ FormTypes : []string {`$( form "db_props" )` },
627+ Variables : []proofing.Variable {},
628+ PackageInstalls : []string {`$( package "test-install" )` },
629+ CompatibleKubernetesDistributions : []models.ProductVersion {{Name : "k0s" , Version : ">0.0.0" }},
630+ }
631+ yamlData , err := yaml .Marshal (& m )
632+ Expect (err ).NotTo (HaveOccurred ())
633+ Expect (string (yamlData )).NotTo (ContainSubstring ("uses_kubernetes_features" ))
634+ err = os .WriteFile (path .Join (inputPath , "base.yml" ), yamlData , 0644 )
635+ Expect (err ).NotTo (HaveOccurred ())
636+ })
637+
638+ It ("omits uses_kubernetes_features from the baked metadata" , func () {
639+ Expect (err ).NotTo (HaveOccurred ())
640+
641+ yamlData , readErr := os .ReadFile (path .Join (outputPath , "base.yml" ))
642+ Expect (readErr ).NotTo (HaveOccurred ())
643+ Expect (string (yamlData )).NotTo (ContainSubstring ("uses_kubernetes_features" ))
644+
645+ outMeta := models.MetadataOut {}
646+ Expect (yaml .Unmarshal (yamlData , & outMeta )).To (Succeed ())
647+ Expect (outMeta .UsesKubernetesFeatures ).To (BeEmpty ())
648+ // the rest of the kubernetes metadata is unaffected
649+ Expect (outMeta .RequiresKubernetes ).To (BeTrue ())
650+ Expect (outMeta .CompatibleKubernetesDistributions ).To (HaveLen (1 ))
651+ })
652+ })
603653 })
604654 })
605655
0 commit comments