Skip to content

Commit b0b170d

Browse files
committed
features: adapt to new o/api features package
Features moved to a new package in openshift/api in: openshift/api@e00b981 This commit just adapts the installer to use the new packages.
1 parent 25c12fc commit b0b170d

File tree

11 files changed

+44
-39
lines changed

11 files changed

+44
-39
lines changed

pkg/asset/machines/master.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"sigs.k8s.io/yaml"
1818

1919
configv1 "github.com/openshift/api/config/v1"
20+
"github.com/openshift/api/features"
2021
machinev1 "github.com/openshift/api/machine/v1"
2122
machinev1alpha1 "github.com/openshift/api/machine/v1alpha1"
2223
machinev1beta1 "github.com/openshift/api/machine/v1beta1"
@@ -270,7 +271,7 @@ func (m *Master) Generate(dependencies asset.Parents) error {
270271
// so we don't want to include target pools in the control plane machineset.
271272
// TODO(padillon): once this feature gate is the default and we are
272273
// no longer using Terraform, we can update ConfigMasters not to populate this.
273-
if ic.EnabledFeatureGates().Enabled(configv1.FeatureGateClusterAPIInstall) {
274+
if ic.EnabledFeatureGates().Enabled(features.FeatureGateClusterAPIInstall) {
274275
for _, machine := range machines {
275276
providerSpec, ok := machine.Spec.ProviderSpec.Value.Object.(*machinev1beta1.GCPMachineProviderSpec)
276277
if !ok {

pkg/asset/manifests/capiutils/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package capiutils
22

33
import (
4-
v1 "github.com/openshift/api/config/v1"
4+
"github.com/openshift/api/features"
55
"github.com/openshift/installer/pkg/asset/installconfig"
66
"github.com/openshift/installer/pkg/ipnet"
77
)
@@ -21,7 +21,7 @@ func CIDRFromInstallConfig(installConfig *installconfig.InstallConfig) *ipnet.IP
2121

2222
// IsEnabled returns true if the feature gate is enabled.
2323
func IsEnabled(installConfig *installconfig.InstallConfig) bool {
24-
return installConfig.Config.EnabledFeatureGates().Enabled(v1.FeatureGateClusterAPIInstall)
24+
return installConfig.Config.EnabledFeatureGates().Enabled(features.FeatureGateClusterAPIInstall)
2525
}
2626

2727
// GenerateBoostrapMachineName generates the Cluster API Machine used for bootstrapping

pkg/destroy/bootstrap/bootstrap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/pkg/errors"
1111
"github.com/sirupsen/logrus"
1212

13-
configv1 "github.com/openshift/api/config/v1"
13+
"github.com/openshift/api/features"
1414
"github.com/openshift/installer/pkg/asset/cluster/metadata"
1515
osp "github.com/openshift/installer/pkg/destroy/openstack"
1616
"github.com/openshift/installer/pkg/infrastructure/openstack/preprovision"
@@ -73,7 +73,7 @@ func Destroy(ctx context.Context, dir string) (err error) {
7373
// Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to
7474
// SelfManaged.
7575
clusterProfile := types.GetClusterProfileName()
76-
featureSets, ok := configv1.AllFeatureSets()[clusterProfile]
76+
featureSets, ok := features.AllFeatureSets()[clusterProfile]
7777
if !ok {
7878
return fmt.Errorf("no feature sets for cluster profile %q", clusterProfile)
7979
}

pkg/infrastructure/platform/platform.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package platform
66
import (
77
"fmt"
88

9-
configv1 "github.com/openshift/api/config/v1"
9+
"github.com/openshift/api/features"
1010
"github.com/openshift/installer/pkg/infrastructure"
1111
awscapi "github.com/openshift/installer/pkg/infrastructure/aws/clusterapi"
1212
awsinfra "github.com/openshift/installer/pkg/infrastructure/aws/sdk"
@@ -50,15 +50,15 @@ import (
5050
func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastructure.Provider, error) {
5151
switch platform {
5252
case awstypes.Name:
53-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
53+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
5454
return clusterapi.InitializeProvider(&awscapi.Provider{}), nil
5555
}
56-
if fg.Enabled(configv1.FeatureGateInstallAlternateInfrastructureAWS) {
56+
if fg.Enabled(features.FeatureGateInstallAlternateInfrastructureAWS) {
5757
return awsinfra.InitializeProvider(), nil
5858
}
5959
return terraform.InitializeProvider(aws.PlatformStages), nil
6060
case azuretypes.Name:
61-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
61+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
6262
return clusterapi.InitializeProvider(&azureinfra.Provider{}), nil
6363
}
6464
return terraform.InitializeProvider(azure.PlatformStages), nil
@@ -67,36 +67,36 @@ func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastr
6767
case baremetaltypes.Name:
6868
return baremetalinfra.InitializeProvider(), nil
6969
case gcptypes.Name:
70-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
70+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
7171
return clusterapi.InitializeProvider(gcpcapi.Provider{}), nil
7272
}
7373
return terraform.InitializeProvider(gcp.PlatformStages), nil
7474
case ibmcloudtypes.Name:
75-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
75+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
7676
return clusterapi.InitializeProvider(ibmcloudcapi.Provider{}), nil
7777
}
7878
return terraform.InitializeProvider(ibmcloud.PlatformStages), nil
7979
case libvirttypes.Name:
8080
return terraform.InitializeProvider(libvirt.PlatformStages), nil
8181
case nutanixtypes.Name:
82-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
82+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
8383
return clusterapi.InitializeProvider(nutanixcapi.Provider{}), nil
8484
}
8585
return terraform.InitializeProvider(nutanix.PlatformStages), nil
8686
case powervstypes.Name:
87-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
87+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
8888
return clusterapi.InitializeProvider(&powervscapi.Provider{}), nil
8989
}
9090
return terraform.InitializeProvider(powervs.PlatformStages), nil
9191
case openstacktypes.Name:
92-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
92+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
9393
return clusterapi.InitializeProvider(openstackcapi.Provider{}), nil
9494
}
9595
return terraform.InitializeProvider(openstack.PlatformStages), nil
9696
case ovirttypes.Name:
9797
return terraform.InitializeProvider(ovirt.PlatformStages), nil
9898
case vspheretypes.Name:
99-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
99+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
100100
return clusterapi.InitializeProvider(vspherecapi.Provider{}), nil
101101
}
102102
return terraform.InitializeProvider(vsphere.PlatformStages), nil

pkg/infrastructure/platform/platform_altinfra.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package platform
66
import (
77
"fmt"
88

9-
configv1 "github.com/openshift/api/config/v1"
9+
"github.com/openshift/api/features"
1010
"github.com/openshift/installer/pkg/infrastructure"
1111
awscapi "github.com/openshift/installer/pkg/infrastructure/aws/clusterapi"
1212
awsinfra "github.com/openshift/installer/pkg/infrastructure/aws/sdk"
@@ -33,40 +33,40 @@ import (
3333
func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastructure.Provider, error) {
3434
switch platform {
3535
case awstypes.Name:
36-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
36+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
3737
return clusterapi.InitializeProvider(&awscapi.Provider{}), nil
3838
}
3939
return awsinfra.InitializeProvider(), nil
4040
case azuretypes.Name:
41-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
41+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
4242
return clusterapi.InitializeProvider(&azurecapi.Provider{}), nil
4343
}
4444
return nil, nil
4545
case gcptypes.Name:
46-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
46+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
4747
return clusterapi.InitializeProvider(gcpcapi.Provider{}), nil
4848
}
4949
return nil, nil
5050
case ibmcloudtypes.Name:
51-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
51+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
5252
return clusterapi.InitializeProvider(ibmcloudcapi.Provider{}), nil
5353
}
5454
return nil, nil
5555
case vspheretypes.Name:
56-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
56+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
5757
return clusterapi.InitializeProvider(vspherecapi.Provider{}), nil
5858
}
5959
case powervstypes.Name:
60-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
60+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
6161
return clusterapi.InitializeProvider(powervscapi.Provider{}), nil
6262
}
6363
return nil, nil
6464
case openstacktypes.Name:
65-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
65+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
6666
return clusterapi.InitializeProvider(openstackcapi.Provider{}), nil
6767
}
6868
case nutanixtypes.Name:
69-
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
69+
if fg.Enabled(features.FeatureGateClusterAPIInstall) {
7070
return clusterapi.InitializeProvider(nutanixcapi.Provider{}), nil
7171
}
7272
}

pkg/types/featuregates/featuregates.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
"k8s.io/apimachinery/pkg/util/sets"
1010

1111
configv1 "github.com/openshift/api/config/v1"
12+
features "github.com/openshift/api/features"
1213
)
1314

14-
func toFeatureGateNames(in []configv1.FeatureGateDescription) []configv1.FeatureGateName {
15+
func toFeatureGateNames(in []features.FeatureGateDescription) []configv1.FeatureGateName {
1516
out := []configv1.FeatureGateName{}
1617
for _, curr := range in {
1718
out = append(out, curr.FeatureGateAttributes.Name)
@@ -21,7 +22,7 @@ func toFeatureGateNames(in []configv1.FeatureGateDescription) []configv1.Feature
2122
}
2223

2324
// completeFeatureGates identifies every known feature and ensures that is explicitly on or explicitly off.
24-
func completeFeatureGates(knownFeatureSets map[configv1.FeatureSet]*configv1.FeatureGateEnabledDisabled, enabled, disabled []configv1.FeatureGateName) ([]configv1.FeatureGateName, []configv1.FeatureGateName) {
25+
func completeFeatureGates(knownFeatureSets map[configv1.FeatureSet]*features.FeatureGateEnabledDisabled, enabled, disabled []configv1.FeatureGateName) ([]configv1.FeatureGateName, []configv1.FeatureGateName) {
2526
specificallyEnabledFeatureGates := sets.New[configv1.FeatureGateName]()
2627
specificallyEnabledFeatureGates.Insert(enabled...)
2728

@@ -41,7 +42,7 @@ func completeFeatureGates(knownFeatureSets map[configv1.FeatureSet]*configv1.Fea
4142
}
4243

4344
// FeatureGateFromFeatureSets creates a FeatureGate from the active feature sets.
44-
func FeatureGateFromFeatureSets(knownFeatureSets map[configv1.FeatureSet]*configv1.FeatureGateEnabledDisabled, fs configv1.FeatureSet, customFS *configv1.CustomFeatureGates) FeatureGate {
45+
func FeatureGateFromFeatureSets(knownFeatureSets map[configv1.FeatureSet]*features.FeatureGateEnabledDisabled, fs configv1.FeatureSet, customFS *configv1.CustomFeatureGates) FeatureGate {
4546
if customFS != nil {
4647
completeEnabled, completeDisabled := completeFeatureGates(knownFeatureSets, customFS.Enabled, customFS.Disabled)
4748
return newFeatureGate(completeEnabled, completeDisabled)

pkg/types/gcp/validation/featuregates.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package validation
33
import (
44
"k8s.io/apimachinery/pkg/util/validation/field"
55

6-
configv1 "github.com/openshift/api/config/v1"
6+
features "github.com/openshift/api/features"
77
"github.com/openshift/installer/pkg/types"
88
"github.com/openshift/installer/pkg/types/featuregates"
99
"github.com/openshift/installer/pkg/types/gcp"
@@ -15,17 +15,17 @@ func GatedFeatures(c *types.InstallConfig) []featuregates.GatedInstallConfigFeat
1515
g := c.GCP
1616
return []featuregates.GatedInstallConfigFeature{
1717
{
18-
FeatureGateName: configv1.FeatureGateGCPLabelsTags,
18+
FeatureGateName: features.FeatureGateGCPLabelsTags,
1919
Condition: len(g.UserLabels) > 0,
2020
Field: field.NewPath("platform", "gcp", "userLabels"),
2121
},
2222
{
23-
FeatureGateName: configv1.FeatureGateGCPLabelsTags,
23+
FeatureGateName: features.FeatureGateGCPLabelsTags,
2424
Condition: len(g.UserTags) > 0,
2525
Field: field.NewPath("platform", "gcp", "userTags"),
2626
},
2727
{
28-
FeatureGateName: configv1.FeatureGateGCPClusterHostedDNS,
28+
FeatureGateName: features.FeatureGateGCPClusterHostedDNS,
2929
Condition: g.UserProvisionedDNS == gcp.UserProvisionedDNSEnabled,
3030
Field: field.NewPath("platform", "gcp", "userProvisionedDNS"),
3131
},

pkg/types/installconfig.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99

1010
configv1 "github.com/openshift/api/config/v1"
11+
features "github.com/openshift/api/features"
1112
"github.com/openshift/installer/pkg/ipnet"
1213
"github.com/openshift/installer/pkg/types/aws"
1314
"github.com/openshift/installer/pkg/types/azure"
@@ -549,7 +550,7 @@ func (c *InstallConfig) EnabledFeatureGates() featuregates.FeatureGate {
549550
}
550551

551552
clusterProfile := GetClusterProfileName()
552-
featureSets, ok := configv1.AllFeatureSets()[clusterProfile]
553+
featureSets, ok := features.AllFeatureSets()[clusterProfile]
553554
if !ok {
554555
logrus.Warnf("no feature sets for cluster profile %q", clusterProfile)
555556
}

pkg/types/utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/sirupsen/logrus"
88

99
configv1 "github.com/openshift/api/config/v1"
10+
features "github.com/openshift/api/features"
1011
)
1112

1213
// StringsToIPs is used to convert list of strings to list of IP addresses.
@@ -42,15 +43,15 @@ func MachineNetworksToCIDRs(nets []MachineNetworkEntry) []configv1.CIDR {
4243

4344
// GetClusterProfileName utility method to retrieve the cluster profile setting. This is used
4445
// when dealing with openshift api to get FeatureSets.
45-
func GetClusterProfileName() configv1.ClusterProfileName {
46+
func GetClusterProfileName() features.ClusterProfileName {
4647
// Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to
4748
// SelfManaged.
48-
clusterProfile := configv1.SelfManaged
49+
clusterProfile := features.SelfManaged
4950
if cp := os.Getenv("OPENSHIFT_INSTALL_EXPERIMENTAL_CLUSTER_PROFILE"); cp != "" {
5051
logrus.Warnf("Found override for Cluster Profile: %q", cp)
5152
// All profiles when getting FeatureSets need to have "include.release.openshift.io/" at the beginning.
5253
// See vendor/openshift/api/config/v1/feature_gates.go for more info.
53-
clusterProfile = configv1.ClusterProfileName(fmt.Sprintf("%s%s", "include.release.openshift.io/", cp))
54+
clusterProfile = features.ClusterProfileName(fmt.Sprintf("%s%s", "include.release.openshift.io/", cp))
5455
}
5556
return clusterProfile
5657
}

pkg/types/validation/installconfig.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
utilsnet "k8s.io/utils/net"
2121

2222
configv1 "github.com/openshift/api/config/v1"
23+
"github.com/openshift/api/features"
2324
operv1 "github.com/openshift/api/operator/v1"
2425
"github.com/openshift/installer/pkg/hostcrypt"
2526
"github.com/openshift/installer/pkg/ipnet"
@@ -1229,14 +1230,14 @@ func ValidateFeatureSet(c *types.InstallConfig) field.ErrorList {
12291230
allErrs := field.ErrorList{}
12301231

12311232
clusterProfile := types.GetClusterProfileName()
1232-
featureSets, ok := configv1.AllFeatureSets()[clusterProfile]
1233+
featureSets, ok := features.AllFeatureSets()[clusterProfile]
12331234
if !ok {
12341235
logrus.Warnf("no feature sets for cluster profile %q", clusterProfile)
12351236
}
12361237
if _, ok := featureSets[c.FeatureSet]; c.FeatureSet != configv1.CustomNoUpgrade && !ok {
12371238
sortedFeatureSets := func() []string {
12381239
v := []string{}
1239-
for n := range configv1.AllFeatureSets()[clusterProfile] {
1240+
for n := range features.AllFeatureSets()[clusterProfile] {
12401241
v = append(v, string(n))
12411242
}
12421243
// Add CustomNoUpgrade since it is not part of features sets for profiles

0 commit comments

Comments
 (0)