@@ -132,6 +132,30 @@ func (o *GenericOptions) FeatureGates() (featuregates.FeatureGateAccess, error)
132132 return nil , fmt .Errorf ("cannot return FeatureGate without rendered manifests" )
133133 }
134134
135+ manifests , err := o .FeatureGateManifests ()
136+ if err != nil {
137+ return nil , fmt .Errorf ("error reading input manifests: %w" , err )
138+ }
139+ // they're all the same, so just get the first
140+ featureGate , err := manifests [0 ].GetDecodedObj ()
141+ if err != nil {
142+ return nil , fmt .Errorf ("error decoding FeatureGates: %w" , err )
143+ }
144+
145+ ret , err := featuregates .NewHardcodedFeatureGateAccessFromFeatureGate (featureGate .(* configv1.FeatureGate ), o .PayloadVersion )
146+ if err != nil {
147+ return nil , fmt .Errorf ("error creating feature accessor: %w" , err )
148+ }
149+
150+ return ret , nil
151+ }
152+
153+ // FeatureGateManifests is exposed for usage in getting FeatureGateAccess and for convenient by cluster-config-operator
154+ func (o * GenericOptions ) FeatureGateManifests () (RenderedManifests , error ) {
155+ if len (o .RenderedManifestInputFilenames ) == 0 {
156+ return nil , nil
157+ }
158+
135159 inputManifest , err := o .ReadInputManifests ()
136160 if err != nil {
137161 return nil , fmt .Errorf ("error reading input manifests: %w" , err )
@@ -140,10 +164,15 @@ func (o *GenericOptions) FeatureGates() (featuregates.FeatureGateAccess, error)
140164 if len (featureGates ) == 0 {
141165 return nil , fmt .Errorf ("no FeatureGates found in manfest dir: %v" , o .RenderedManifestInputFilenames )
142166 }
167+
168+ ret := RenderedManifests {}
169+
143170 var prev * RenderedManifest
144171 var featureGate * configv1.FeatureGate
145172 for i := range featureGates {
146173 curr := featureGates [i ]
174+ ret = append (ret , curr )
175+
147176 decodedObj , err := curr .GetDecodedObj ()
148177 if err != nil {
149178 return nil , fmt .Errorf ("decoding failure for %q: %w" , curr .OriginalFilename , err )
@@ -163,12 +192,25 @@ func (o *GenericOptions) FeatureGates() (featuregates.FeatureGateAccess, error)
163192 }
164193 }
165194
166- ret , err := featuregates .NewHardcodedFeatureGateAccessFromFeatureGate (featureGate , o .PayloadVersion )
195+ return ret , nil
196+ }
197+
198+ func (o * GenericOptions ) FeatureSetName () (configv1.FeatureSet , error ) {
199+ if len (o .RenderedManifestInputFilenames ) == 0 {
200+ return configv1 .FeatureSet (o .FeatureSet ), nil
201+ }
202+
203+ manifests , err := o .FeatureGateManifests ()
167204 if err != nil {
168- return nil , fmt .Errorf ("error creating feature accessor: %w" , err )
205+ return "MISSING" , fmt .Errorf ("error reading input manifests: %w" , err )
206+ }
207+ // they're all the same, so just get the first
208+ featureGate , err := manifests [0 ].GetDecodedObj ()
209+ if err != nil {
210+ return "MISSING" , fmt .Errorf ("error decoding FeatureGates: %w" , err )
169211 }
170212
171- return ret , nil
213+ return featureGate .( * configv1. FeatureGate ). Spec . FeatureSet , nil
172214}
173215
174216// ApplyTo applies the options to the given config struct using the provided text/template data.
0 commit comments