@@ -789,12 +789,6 @@ func determineEnvironmentFlags(ctx context.Context, upgrade bool, dryRun bool) (
789
789
return nil , err
790
790
}
791
791
792
- featureGates , err := determineEnabledFeatureGates (ctx , clientConfig )
793
- if err != nil {
794
- return nil , errors .WithMessage (err , "couldn't determine feature gates" )
795
- }
796
- envFlagBuilder .AddFeatureGates (featureGates ... )
797
-
798
792
discoveryClient , err := kubeconfig .NewDiscoveryGetter (restConfig ).GetDiscoveryClient ()
799
793
if err != nil {
800
794
return nil , err
@@ -803,7 +797,15 @@ func determineEnvironmentFlags(ctx context.Context, upgrade bool, dryRun bool) (
803
797
if err != nil {
804
798
return nil , errors .WithMessage (err , "couldn't determine api groups" )
805
799
}
806
- envFlagBuilder .AddAPIGroups (apiGroups ... )
800
+ envFlagBuilder .AddAPIGroups (apiGroups .UnsortedList ()... )
801
+
802
+ if apiGroups .Has ("config.openshift.io" ) {
803
+ featureGates , err := determineEnabledFeatureGates (ctx , clientConfig )
804
+ if err != nil {
805
+ return nil , errors .WithMessage (err , "couldn't determine feature gates" )
806
+ }
807
+ envFlagBuilder .AddFeatureGates (featureGates ... )
808
+ }
807
809
808
810
//Additional flags can only be determined if we are able to obtain the clusterState
809
811
if clusterState != nil {
@@ -862,7 +864,7 @@ func determineExternalConnectivity(clusterConfig *clusterdiscovery.ClusterConfig
862
864
return "Direct"
863
865
}
864
866
865
- func determineEnabledAPIGroups (discoveryClient discovery.AggregatedDiscoveryInterface ) ([] string , error ) {
867
+ func determineEnabledAPIGroups (discoveryClient discovery.AggregatedDiscoveryInterface ) (sets. Set [ string ] , error ) {
866
868
groups , err := discoveryClient .ServerGroups ()
867
869
if err != nil {
868
870
return nil , fmt .Errorf ("unable to retrieve served resources: %v" , err )
@@ -876,7 +878,7 @@ func determineEnabledAPIGroups(discoveryClient discovery.AggregatedDiscoveryInte
876
878
apiGroups .Insert (apiGroup .Name )
877
879
}
878
880
879
- return apiGroups . List () , nil
881
+ return apiGroups , nil
880
882
}
881
883
882
884
func determineEnabledFeatureGates (ctx context.Context , configClient clientconfigv1.Interface ) ([]string , error ) {
0 commit comments