@@ -361,6 +361,11 @@ consumes:
361361 Expect (outMeta .CompatibleKubernetesDistributions [0 ].Name ).To (Equal ("k0s" ))
362362 Expect (outMeta .CompatibleKubernetesDistributions [0 ].Version ).To (Equal (">0.0.0" ))
363363 Expect (outMeta .RequiresKubernetes ).To (BeTrue ())
364+ Expect (outMeta .UsesKubernetesFeatures ).To (HaveLen (2 ))
365+ Expect (outMeta .UsesKubernetesFeatures [0 ].Name ).To (Equal ("gpu-scheduling" ))
366+ Expect (outMeta .UsesKubernetesFeatures [0 ].Optional ).To (BeFalse ())
367+ Expect (outMeta .UsesKubernetesFeatures [1 ].Name ).To (Equal ("node-local-storage" ))
368+ Expect (outMeta .UsesKubernetesFeatures [1 ].Optional ).To (BeTrue ())
364369 })
365370 It ("creates empty instance_group and jobs directories" , func () {
366371 Expect (filepath .Join (outputPath , "instance_groups" )).To (BeADirectory ())
@@ -495,6 +500,51 @@ consumes:
495500 Expect (err .Error ()).To (ContainSubstring ("tile metadata_version too old" ))
496501 })
497502 })
503+ When ("the tile declares no kubernetes features" , func () {
504+ // Ops Manager rejects uses_kubernetes_features on a tile that is not a
505+ // kubernetes consumer, so an absent block must stay absent rather than
506+ // baking out as an empty list.
507+ BeforeEach (func () {
508+ m := models.Metadata {
509+ Name : "k8s-tile-test" ,
510+ Label : "test tile" ,
511+ IconImage : "$( icon )" ,
512+ MetadataVersion : "3.2.0" ,
513+ MinimumVersionForUpgrade : "0.0.0" ,
514+ ProductVersion : "$( version )" ,
515+ Rank : 1 ,
516+ Serial : false ,
517+ PropertyBlueprints : []string {
518+ `$( property "database_name" )` ,
519+ `$( property "admin_password" )` ,
520+ },
521+ FormTypes : []string {`$( form "db_props" )` },
522+ Variables : []proofing.Variable {},
523+ PackageInstalls : []string {`$( package "test-install" )` },
524+ CompatibleKubernetesDistributions : []models.ProductVersion {{Name : "k0s" , Version : ">0.0.0" }},
525+ }
526+ yamlData , err := yaml .Marshal (& m )
527+ Expect (err ).NotTo (HaveOccurred ())
528+ Expect (string (yamlData )).NotTo (ContainSubstring ("uses_kubernetes_features" ))
529+ err = os .WriteFile (path .Join (inputPath , "base.yml" ), yamlData , 0644 )
530+ Expect (err ).NotTo (HaveOccurred ())
531+ })
532+
533+ It ("omits uses_kubernetes_features from the baked metadata" , func () {
534+ Expect (err ).NotTo (HaveOccurred ())
535+
536+ yamlData , readErr := os .ReadFile (path .Join (outputPath , "base.yml" ))
537+ Expect (readErr ).NotTo (HaveOccurred ())
538+ Expect (string (yamlData )).NotTo (ContainSubstring ("uses_kubernetes_features" ))
539+
540+ outMeta := models.MetadataOut {}
541+ Expect (yaml .Unmarshal (yamlData , & outMeta )).To (Succeed ())
542+ Expect (outMeta .UsesKubernetesFeatures ).To (BeEmpty ())
543+ // the rest of the kubernetes metadata is unaffected
544+ Expect (outMeta .RequiresKubernetes ).To (BeTrue ())
545+ Expect (outMeta .CompatibleKubernetesDistributions ).To (HaveLen (1 ))
546+ })
547+ })
498548 })
499549 })
500550
0 commit comments