diff --git a/cmd/main.go b/cmd/main.go index 1293dfdd309..da17a5bcfa4 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -365,10 +365,6 @@ func main() { Options.InstructionConfig.AgentImage, } - for _, releaseImage := range releaseImagesArray { - images = append(images, *releaseImage.URL) - } - pullSecretValidator, err := validations.NewPullSecretValidator(Options.ValidationsConfig, authHandler, images...) failOnError(err, "failed to create pull secret validator") diff --git a/internal/bminventory/inventory.go b/internal/bminventory/inventory.go index ead062709b9..fffc7b2e23e 100644 --- a/internal/bminventory/inventory.go +++ b/internal/bminventory/inventory.go @@ -177,7 +177,7 @@ type InstallerInternals interface { GetKnownHostApprovedCounts(clusterID strfmt.UUID) (registered, approved int, err error) HostWithCollectedLogsExists(clusterId strfmt.UUID) (bool, error) GetKnownApprovedHosts(clusterId strfmt.UUID) ([]*common.Host, error) - ValidatePullSecret(secret string, username string) error + ValidatePullSecret(secret string, username string, releaseImageURL string) error GetInfraEnvInternal(ctx context.Context, params installer.GetInfraEnvParams) (*common.InfraEnv, error) V2UpdateHostInstallProgressInternal(ctx context.Context, params installer.V2UpdateHostInstallProgressParams) error } @@ -285,8 +285,8 @@ func NewBareMetalInventory( } } -func (b *bareMetalInventory) ValidatePullSecret(secret string, username string) error { - return b.secretValidator.ValidatePullSecret(secret, username) +func (b *bareMetalInventory) ValidatePullSecret(secret string, username string, releaseImageURL string) error { + return b.secretValidator.ValidatePullSecret(secret, username, releaseImageURL) } func (b *bareMetalInventory) updatePullSecret(pullSecret string, log logrus.FieldLogger) (string, error) { @@ -633,7 +633,7 @@ func (b *bareMetalInventory) RegisterClusterInternal( } pullSecret := swag.StringValue(params.NewClusterParams.PullSecret) - err = b.ValidatePullSecret(pullSecret, ocm.UserNameFromContext(ctx)) + err = b.ValidatePullSecret(pullSecret, ocm.UserNameFromContext(ctx), *releaseImage.URL) if err != nil { err = errors.Wrap(secretValidationToUserError(err), "pull secret for new cluster is invalid") return nil, common.NewApiError(http.StatusBadRequest, err) @@ -1847,7 +1847,7 @@ func (b *bareMetalInventory) validateAndUpdateClusterParams(ctx context.Context, log := logutil.FromContext(ctx, b.log) if swag.StringValue(params.ClusterUpdateParams.PullSecret) != "" { - if err := b.ValidatePullSecret(*params.ClusterUpdateParams.PullSecret, ocm.UserNameFromContext(ctx)); err != nil { + if err := b.ValidatePullSecret(*params.ClusterUpdateParams.PullSecret, ocm.UserNameFromContext(ctx), cluster.OcpReleaseImage); err != nil { log.WithError(err).Errorf("Pull secret for cluster %s is invalid", params.ClusterID) return installer.V2UpdateClusterParams{}, err } @@ -4645,7 +4645,7 @@ func (b *bareMetalInventory) RegisterInfraEnvInternal( } pullSecret := swag.StringValue(params.InfraenvCreateParams.PullSecret) - err = b.ValidatePullSecret(pullSecret, ocm.UserNameFromContext(ctx)) + err = b.ValidatePullSecret(pullSecret, ocm.UserNameFromContext(ctx), "") if err != nil { err = errors.Wrap(secretValidationToUserError(err), "pull secret for new infraEnv is invalid") return common.NewApiError(http.StatusBadRequest, err) @@ -5109,7 +5109,7 @@ func (b *bareMetalInventory) validateAndUpdateInfraEnvParams(ctx context.Context log := logutil.FromContext(ctx, b.log) if params.InfraEnvUpdateParams.PullSecret != "" { - if err := b.ValidatePullSecret(params.InfraEnvUpdateParams.PullSecret, ocm.UserNameFromContext(ctx)); err != nil { + if err := b.ValidatePullSecret(params.InfraEnvUpdateParams.PullSecret, ocm.UserNameFromContext(ctx), ""); err != nil { log.WithError(err).Errorf("Pull secret for infraEnv %s is invalid", params.InfraEnvID) return installer.UpdateInfraEnvParams{}, err } diff --git a/internal/bminventory/inventory_test.go b/internal/bminventory/inventory_test.go index 10912450f37..a01f0cfc865 100644 --- a/internal/bminventory/inventory_test.go +++ b/internal/bminventory/inventory_test.go @@ -227,7 +227,7 @@ func toMac(macStr string) *strfmt.MAC { } func mockClusterRegisterSteps() { - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(common.TestDefaultConfig.ReleaseImage, nil).Times(1) mockOSImages.EXPECT().GetOsImage(gomock.Any(), gomock.Any()).Return(common.TestDefaultConfig.OsImage, nil).Times(1) mockOperatorManager.EXPECT().GetSupportedOperatorsByType(models.OperatorTypeBuiltin).Return([]*models.MonitoredOperator{&common.TestDefaultConfig.MonitoredOperator}).Times(1) @@ -252,7 +252,7 @@ func mockClusterRegisterSuccessWithVersion(cpuArchitecture, openshiftVersion str Version: swag.String(openshiftVersion), SupportLevel: models.OpenshiftVersionSupportLevelProduction, } - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(releaseImage, nil).Times(1) mockOperatorManager.EXPECT().GetSupportedOperatorsByType(models.OperatorTypeBuiltin).Return([]*models.MonitoredOperator{&common.TestDefaultConfig.MonitoredOperator}).Times(1) mockProviderRegistry.EXPECT().SetPlatformUsages(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) @@ -282,7 +282,7 @@ func mockInfraEnvRegisterSuccess() { mockOSImages.EXPECT().GetOsImageOrLatest(gomock.Any(), gomock.Any()).Return(common.TestDefaultConfig.OsImage, nil).AnyTimes() mockOSImages.EXPECT().GetOsImage(gomock.Any(), gomock.Any()).Return(common.TestDefaultConfig.OsImage, nil).AnyTimes() mockStaticNetworkConfig.EXPECT().FormatStaticNetworkConfigForDB(gomock.Any()).Return("", nil).Times(1) - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockIgnitionBuilder.EXPECT().FormatDiscoveryIgnitionFile(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(discovery_ignition_3_1, nil).Times(1) mockEvents.EXPECT().SendInfraEnvEvent(gomock.Any(), eventstest.NewEventMatcher( eventstest.WithNameMatcher(eventgen.ImageInfoUpdatedEventName))).AnyTimes() @@ -3071,7 +3071,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("8.8.8.2")}} err := "the second element of apiVIPs must be an IPv6 address. got: 8.8.8.8" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3093,7 +3093,7 @@ var _ = Describe("cluster", func() { mockHostApi.EXPECT().RefreshInventory(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) mockHostApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) mockHostApi.EXPECT().GetStagesByRole(gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) apiVip := "1.2.3.100" ingressVip := "1.2.3.101" @@ -3122,7 +3122,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("8.8.8.1")}} err := "the first element of apiVIPs must be an IPv4 address. got: 2001:db8::1" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3143,7 +3143,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("2001:db8::4")}} err := "the first element of apiVIPs must be an IPv4 address. got: 2001:db8::1" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3164,7 +3164,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("2001:db8::4")}, {IP: models.IP("8.8.8.4")}} err := "apiVIPs supports 2 vips. got: 3" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3185,7 +3185,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("invalid ingressVip 2")}} multiErr := "4 errors occurred:\n\t* Could not parse VIP ip invalid apiVip\n\t* Could not parse VIP ip invalid apiVip 2\n\t* Could not parse VIP ip invalid ingressVip\n\t* Could not parse VIP ip invalid ingressVip 2" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3206,7 +3206,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("2001:db8::4")}} multiErr := "1 error occurred:\n\t* Could not parse VIP ip invalid apiVip\n" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3227,7 +3227,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}} err := "configuration must include the same number of apiVIPs (got 2) and ingressVIPs (got 1)" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3248,7 +3248,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("2001:db8::3")}} err := "The IP address \"1.2.3.100\" appears multiple times in apiVIPs" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3269,7 +3269,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP(ingressVip)}} err := "The IP address \"1.2.3.101\" appears multiple times in ingressVIPs" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -3289,7 +3289,7 @@ var _ = Describe("cluster", func() { ingressVips := []*models.IngressVip{{IP: models.IP(apiVip)}, {IP: models.IP("2001:db8::4")}} err := "The IP address \"1.2.3.100\" appears both in apiVIPs and ingressVIPs" - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, @@ -8398,7 +8398,7 @@ var _ = Describe("infraEnvs", func() { *common.TestDefaultConfig.OsImage.OpenshiftVersion, *common.TestDefaultConfig.OsImage.CPUArchitecture).Return(common.TestDefaultConfig.OsImage, nil).Times(1) mockStaticNetworkConfig.EXPECT().FormatStaticNetworkConfigForDB(gomock.Any()).Return("", nil).Times(1) - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockIgnitionBuilder.EXPECT().FormatDiscoveryIgnitionFile(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(discovery_ignition_3_1, nil).Times(1) mockEvents.EXPECT().SendInfraEnvEvent(ctx, eventstest.NewEventMatcher( @@ -8526,7 +8526,7 @@ var _ = Describe("infraEnvs", func() { mockOSImages.EXPECT().GetOsImageOrLatest(gomock.Any(), gomock.Any()).Return(common.TestDefaultConfig.OsImage, nil).AnyTimes() mockOSImages.EXPECT().GetOsImage(gomock.Any(), gomock.Any()).Return(common.TestDefaultConfig.OsImage, nil).AnyTimes() - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockIgnitionBuilder.EXPECT().FormatDiscoveryIgnitionFile(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(discovery_ignition_3_1, nil).Times(1) mockEvents.EXPECT().SendInfraEnvEvent(gomock.Any(), eventstest.NewEventMatcher( eventstest.WithNameMatcher(eventgen.ImageInfoUpdatedEventName))).AnyTimes() @@ -8562,7 +8562,7 @@ var _ = Describe("infraEnvs", func() { mockOSImages.EXPECT().GetOsImageOrLatest(gomock.Any(), gomock.Any()).Return(common.TestDefaultConfig.OsImage, nil).AnyTimes() mockStaticNetworkConfig.EXPECT().FormatStaticNetworkConfigForDB(gomock.Any()).Return("", nil).Times(1) - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockIgnitionBuilder.EXPECT().FormatDiscoveryIgnitionFile(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(largeDiscoveryIgnition, nil).AnyTimes() mockEvents.EXPECT().SendInfraEnvEvent(ctx, eventstest.NewEventMatcher( eventstest.WithNameMatcher(eventgen.InfraEnvRegistrationFailedEventName))).Times(1) @@ -9649,7 +9649,7 @@ var _ = Describe("infraEnvs", func() { prevURL = newURL By("updating pull secret") - mockSecretValidator.EXPECT().ValidatePullSecret("mypullsecret", gomock.Any()).Return(nil) + mockSecretValidator.EXPECT().ValidatePullSecret("mypullsecret", gomock.Any(), gomock.Any()).Return(nil) params.PullSecret = "mypullsecret" newURL = updateInfraEnv(params) Expect(newURL).ToNot(Equal(prevURL)) @@ -13675,7 +13675,7 @@ var _ = Describe("TestRegisterCluster", func() { Context("ValidateIncompatibleFeatures", func() { It("s390x on 4.13 OCP version", func() { - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockOperatorManager.EXPECT().GetSupportedOperatorsByType(models.OperatorTypeBuiltin).Return([]*models.MonitoredOperator{&common.TestDefaultConfig.MonitoredOperator}).Times(1) mockProviderRegistry.EXPECT().SetPlatformUsages(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockMetric.EXPECT().ClusterRegistered().Times(1) @@ -13786,7 +13786,7 @@ var _ = Describe("TestRegisterCluster", func() { }) It("Sno is compatible with s390x on 4.13", func() { - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockOperatorManager.EXPECT().GetSupportedOperatorsByType(models.OperatorTypeBuiltin).Return([]*models.MonitoredOperator{&common.TestDefaultConfig.MonitoredOperator}).Times(1) mockProviderRegistry.EXPECT().SetPlatformUsages(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockMetric.EXPECT().ClusterRegistered().Times(1) @@ -13914,7 +13914,7 @@ var _ = Describe("TestRegisterCluster", func() { }) It("s390x on 4.13 OCP version", func() { - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockOperatorManager.EXPECT().GetSupportedOperatorsByType(models.OperatorTypeBuiltin).Return([]*models.MonitoredOperator{&common.TestDefaultConfig.MonitoredOperator}).Times(1) mockProviderRegistry.EXPECT().SetPlatformUsages(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockMetric.EXPECT().ClusterRegistered().Times(1) @@ -14798,7 +14798,7 @@ var _ = Describe("TestRegisterCluster", func() { }) It("cluster api failed to register with invalid pull secret", func() { - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()). + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()). Return(errors.New("error")).Times(1) mockOperatorManager.EXPECT().GetSupportedOperatorsByType(models.OperatorTypeBuiltin).Return([]*models.MonitoredOperator{}).Times(1) mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(common.TestDefaultConfig.ReleaseImage, nil).Times(1) @@ -14873,7 +14873,7 @@ var _ = Describe("TestRegisterCluster", func() { }) It("Register cluster with arm64 CPU architecture as multiarch if multiarch release image used", func() { - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&models.ReleaseImage{ CPUArchitecture: swag.String(common.MultiCPUArchitecture), CPUArchitectures: []string{common.X86CPUArchitecture, common.ARM64CPUArchitecture, common.PowerCPUArchitecture}, @@ -15114,7 +15114,7 @@ var _ = Describe("TestRegisterCluster", func() { }) It("Register a cluster with multi CPU architecture - success", func() { - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&models.ReleaseImage{ CPUArchitecture: swag.String(common.MultiCPUArchitecture), CPUArchitectures: []string{common.X86CPUArchitecture, common.ARM64CPUArchitecture, common.PowerCPUArchitecture}, diff --git a/internal/bminventory/mock_installer_internal.go b/internal/bminventory/mock_installer_internal.go index 39978ddd2e1..bdeb43e68e0 100644 --- a/internal/bminventory/mock_installer_internal.go +++ b/internal/bminventory/mock_installer_internal.go @@ -548,15 +548,15 @@ func (mr *MockInstallerInternalsMockRecorder) V2UpdateHostInternal(arg0, arg1, a } // ValidatePullSecret mocks base method. -func (m *MockInstallerInternals) ValidatePullSecret(arg0, arg1 string) error { +func (m *MockInstallerInternals) ValidatePullSecret(arg0, arg1, arg2 string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ValidatePullSecret", arg0, arg1) + ret := m.ctrl.Call(m, "ValidatePullSecret", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } // ValidatePullSecret indicates an expected call of ValidatePullSecret. -func (mr *MockInstallerInternalsMockRecorder) ValidatePullSecret(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockInstallerInternalsMockRecorder) ValidatePullSecret(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatePullSecret", reflect.TypeOf((*MockInstallerInternals)(nil).ValidatePullSecret), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatePullSecret", reflect.TypeOf((*MockInstallerInternals)(nil).ValidatePullSecret), arg0, arg1, arg2) } diff --git a/internal/cluster/validations/mock_validations.go b/internal/cluster/validations/mock_validations.go index 68985145997..914e9aeae9a 100644 --- a/internal/cluster/validations/mock_validations.go +++ b/internal/cluster/validations/mock_validations.go @@ -34,15 +34,15 @@ func (m *MockPullSecretValidator) EXPECT() *MockPullSecretValidatorMockRecorder } // ValidatePullSecret mocks base method. -func (m *MockPullSecretValidator) ValidatePullSecret(secret, username string) error { +func (m *MockPullSecretValidator) ValidatePullSecret(secret, username, releaseImageURL string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ValidatePullSecret", secret, username) + ret := m.ctrl.Call(m, "ValidatePullSecret", secret, username, releaseImageURL) ret0, _ := ret[0].(error) return ret0 } // ValidatePullSecret indicates an expected call of ValidatePullSecret. -func (mr *MockPullSecretValidatorMockRecorder) ValidatePullSecret(secret, username interface{}) *gomock.Call { +func (mr *MockPullSecretValidatorMockRecorder) ValidatePullSecret(secret, username, releaseImageURL interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatePullSecret", reflect.TypeOf((*MockPullSecretValidator)(nil).ValidatePullSecret), secret, username) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatePullSecret", reflect.TypeOf((*MockPullSecretValidator)(nil).ValidatePullSecret), secret, username, releaseImageURL) } diff --git a/internal/cluster/validations/validation_test.go b/internal/cluster/validations/validation_test.go index cc6a27d75ea..a5c161bd701 100644 --- a/internal/cluster/validations/validation_test.go +++ b/internal/cluster/validations/validation_test.go @@ -19,17 +19,18 @@ import ( // #nosec const ( - validSecretFormat = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"}}}" - invalidAuthFormat = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"afsdfasf==\",\"email\":\"r@r.com\"}}}" - invalidSecretFormat = "{\"auths\":{\"cloud.openshift.com\":{\"key\":\"abcdef=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"adasfsdf=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"tatastata==\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"afsdfasf==\",\"email\":\"r@r.com\"}}}" - invalidStrSecretFormat = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":null,\"email\":null},\"quay.io\":{\"auth\":\"adasfsdf=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"tatastata==\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"afsdfasf==\",\"email\":\"r@r.com\"}}}" - validSSHPublicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD14Gv4V1111yr7O6/44laYx52VYLe8yrEA3fOieWDmojRs3scqLnfeLHJWsfYA4QMjTuraLKhT8dhETSYiSR88RMM56+isLbcLshE6GkNkz3MBZE2hcdakqMDm6vucP3dJD6snuh5Hfpq7OWDaTcC0zCAzNECJv8F7LcWVa8TLpyRgpek4U022T5otE1ZVbNFqN9OrGHgyzVQLtC4xN1yT83ezo3r+OEdlSVDRQfsq73Zg26d4dyagb6lmrryUUA111mn/HalJTHB73LyjilKiPvJ+x2bG7Aeiq111wtQSpt02FCdQGptmsSqqWF/b9botOO38e111PNppMn7LT5wzDZdDlfwTCBWkpqijPcdo/LTD9dJlNHjwXZtHETtiid6N3ZZWpA0/VKjqUeQdSnHqLEzTidswsnOjCIoIhmJFqczeP5kOty/MWdq1II/FX/EpYCJxoSWkT/hVwD6VOamGwJbLVw9LkEb0VVWFRJB5suT/T8DtPdPl+A0qUGiN4KM= xxxxxx@localhost.localdomain" - validSSHPublicKeys = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD14Gv4V1111yr7O6/44laYx52VYLe8yrEA3fOieWDmojRs3scqLnfeLHJWsfYA4QMjTuraLKhT8dhETSYiSR88RMM56+isLbcLshE6GkNkz3MBZE2hcdakqMDm6vucP3dJD6snuh5Hfpq7OWDaTcC0zCAzNECJv8F7LcWVa8TLpyRgpek4U022T5otE1ZVbNFqN9OrGHgyzVQLtC4xN1yT83ezo3r+OEdlSVDRQfsq73Zg26d4dyagb6lmrryUUA111mn/HalJTHB73LyjilKiPvJ+x2bG7Aeiq111wtQSpt02FCdQGptmsSqqWF/b9botOO38e111PNppMn7LT5wzDZdDlfwTCBWkpqijPcdo/LTD9dJlNHjwXZtHETtiid6N3ZZWpA0/VKjqUeQdSnHqLEzTidswsnOjCIoIhmJFqczeP5kOty/MWdq1II/FX/EpYCJxoSWkT/hVwD6VOamGwJbLVw9LkEb0VVWFRJB5suT/T8DtPdPl+A0qUGiN4KM= xxxxxx@localhost.localdomain\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD14Gv4V1111yr7O6/44laYx52VYLe8yrEA3fOieWDmojRs3scqLnfeLHJWsfYA4QMjTuraLKhT8dhETSYiSR88RMM56+isLbcLshE6GkNkz3MBZE2hcdakqMDm6vucP3dJD6snuh5Hfpq7OWDaTcC0zCAzNECJv8F7LcWVa8TLpyRgpek4U022T5otE1ZVbNFqN9OrGHgyzVQLtC4xN1yT83ezo3r+OEdlSVDRQfsq73Zg26d4dyagb6lmrryUUA111mn/HalJTHB73LyjilKiPvJ+x2bG7Aeiq111wtQSpt02FCdQGptmsSqqWF/b9botOO38e111PNppMn7LT5wzDZdDlfwTCBWkpqijPcdo/LTD9dJlNHjwXZtHETtiid6N3ZZWpA0/VKjqUeQdSnHqLEzTidswsnOjCIoIhmJFqczeP5kOty/MWdq1II/FX/EpYCJxoSWkT/hVwD6VOamGwJbLVw9LkEb0VVWFRJB5suT/T8DtPdPl+A0qUGiN4KM= xxxxxx@localhost.localdomain" - invalidSSHPublicKeyA = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDI2PBP9RuAHCJ1JvxS0gkK7cm1sMHtdqCYuHzK7fmoMSPeAu+GEPVlBmes825gabO7vUK/pVmcsP9mQLXB0KZ8m/QEBXSO9vmF8dEt5OqtpRLcRzxmcnU1iUs50VSQyEeSxdSV4KA9JuWa+q0f3o3VO+CF6s4kQvQ4lumyCyNSFIBnFCX16+O8syah/UpHUWVqJeHaXCV8qzYKyRvy6nMI5lqCgxe+ENqHkgfkQkgEKHZ8gEnzHtJgewZ3E6fbjQ59eEEvF0zb7WKKWA0YzWOMVGGybj4cFMPQ4Jt7iJ0OZKPBQZMHBcPNrej5lasgcKR7nH5XS0UjHhX5vZJ7e7zONHK4XZj6OjEOXilg3/4rxSn0+QQtT1v0RDXRQhHS6sCyRFV12MqEP8XjPIdBMbE26lRwk3tBwWx7plj3UCVamQid3nY5kslD4X7+cqE8n3bNF922rhCy5STycfEFN3XTs73yKvVPjpro4aQw4BVi4P7B7m7F1d/DqRBuYwWuQ6cLLLLLLLLLLL= root@xxxxxx.xx.xxx.xxx.redhat.com" - invalidSSHPublicKeyB = "test!!! ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDi8KHZYGyPQjECHwytquI3rmpgoUn6M+lkeOD2nEKvYElLE5mPIeqF0izJIl56uar2wda+3z107M9QkatE+dP4S9/Ltrlm+/ktAf4O6UoxNLUzv/TGHasb9g3Xkt8JTkohVzVK36622Sd8kLzEc61v1AonLWIADtpwq6/GvHMAuPK2R/H0rdKhTokylKZLDdTqQ+KUFelI6RNIaUBjtVrwkx1j0htxN11DjBVuUyPT2O1ejWegtrM0T+4vXGEA3g3YfbT2k0YnEzjXXqngqbXCYEJCZidp3pJLH/ilo4Y4BId/bx/bhzcbkZPeKlLwjR8g9sydce39bzPIQj+b7nlFv1Vot/77VNwkjXjYPUdUPu0d1PkFD9jKDOdB3fAC61aG2a/8PFS08iBrKiMa48kn+hKXC4G4D5gj/QzIAgzWSl2tEzGQSoIVTucwOAL/jox2dmAa0RyKsnsHORppanuW4qD7KAcmas1GHrAqIfNyDiU2JR50r1jCxj5H76QxIuM= root@ocp-edge34.lab.eng.tlv2.redhat.com" - userName = "jdoe123@example.com" - validSecretFormatUpdated = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.stage.redhat.io\":{\"auth\":\"c29tZW9uZUBleGFtcGxlLmNvbTp0aGlzaXNhc2VjcmV0\"}}}" - regCred = "someone@example.com:thisisasecret" + validPullSecretWithCIToken = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"}, \"registry.ci\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"}}}" + validSecretFormat = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"}}}" + invalidAuthFormat = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"afsdfasf==\",\"email\":\"r@r.com\"}}}" + invalidSecretFormat = "{\"auths\":{\"cloud.openshift.com\":{\"key\":\"abcdef=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"adasfsdf=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"tatastata==\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"afsdfasf==\",\"email\":\"r@r.com\"}}}" + invalidStrSecretFormat = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":null,\"email\":null},\"quay.io\":{\"auth\":\"adasfsdf=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"tatastata==\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"afsdfasf==\",\"email\":\"r@r.com\"}}}" + validSSHPublicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD14Gv4V1111yr7O6/44laYx52VYLe8yrEA3fOieWDmojRs3scqLnfeLHJWsfYA4QMjTuraLKhT8dhETSYiSR88RMM56+isLbcLshE6GkNkz3MBZE2hcdakqMDm6vucP3dJD6snuh5Hfpq7OWDaTcC0zCAzNECJv8F7LcWVa8TLpyRgpek4U022T5otE1ZVbNFqN9OrGHgyzVQLtC4xN1yT83ezo3r+OEdlSVDRQfsq73Zg26d4dyagb6lmrryUUA111mn/HalJTHB73LyjilKiPvJ+x2bG7Aeiq111wtQSpt02FCdQGptmsSqqWF/b9botOO38e111PNppMn7LT5wzDZdDlfwTCBWkpqijPcdo/LTD9dJlNHjwXZtHETtiid6N3ZZWpA0/VKjqUeQdSnHqLEzTidswsnOjCIoIhmJFqczeP5kOty/MWdq1II/FX/EpYCJxoSWkT/hVwD6VOamGwJbLVw9LkEb0VVWFRJB5suT/T8DtPdPl+A0qUGiN4KM= xxxxxx@localhost.localdomain" + validSSHPublicKeys = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD14Gv4V1111yr7O6/44laYx52VYLe8yrEA3fOieWDmojRs3scqLnfeLHJWsfYA4QMjTuraLKhT8dhETSYiSR88RMM56+isLbcLshE6GkNkz3MBZE2hcdakqMDm6vucP3dJD6snuh5Hfpq7OWDaTcC0zCAzNECJv8F7LcWVa8TLpyRgpek4U022T5otE1ZVbNFqN9OrGHgyzVQLtC4xN1yT83ezo3r+OEdlSVDRQfsq73Zg26d4dyagb6lmrryUUA111mn/HalJTHB73LyjilKiPvJ+x2bG7Aeiq111wtQSpt02FCdQGptmsSqqWF/b9botOO38e111PNppMn7LT5wzDZdDlfwTCBWkpqijPcdo/LTD9dJlNHjwXZtHETtiid6N3ZZWpA0/VKjqUeQdSnHqLEzTidswsnOjCIoIhmJFqczeP5kOty/MWdq1II/FX/EpYCJxoSWkT/hVwD6VOamGwJbLVw9LkEb0VVWFRJB5suT/T8DtPdPl+A0qUGiN4KM= xxxxxx@localhost.localdomain\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD14Gv4V1111yr7O6/44laYx52VYLe8yrEA3fOieWDmojRs3scqLnfeLHJWsfYA4QMjTuraLKhT8dhETSYiSR88RMM56+isLbcLshE6GkNkz3MBZE2hcdakqMDm6vucP3dJD6snuh5Hfpq7OWDaTcC0zCAzNECJv8F7LcWVa8TLpyRgpek4U022T5otE1ZVbNFqN9OrGHgyzVQLtC4xN1yT83ezo3r+OEdlSVDRQfsq73Zg26d4dyagb6lmrryUUA111mn/HalJTHB73LyjilKiPvJ+x2bG7Aeiq111wtQSpt02FCdQGptmsSqqWF/b9botOO38e111PNppMn7LT5wzDZdDlfwTCBWkpqijPcdo/LTD9dJlNHjwXZtHETtiid6N3ZZWpA0/VKjqUeQdSnHqLEzTidswsnOjCIoIhmJFqczeP5kOty/MWdq1II/FX/EpYCJxoSWkT/hVwD6VOamGwJbLVw9LkEb0VVWFRJB5suT/T8DtPdPl+A0qUGiN4KM= xxxxxx@localhost.localdomain" + invalidSSHPublicKeyA = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDI2PBP9RuAHCJ1JvxS0gkK7cm1sMHtdqCYuHzK7fmoMSPeAu+GEPVlBmes825gabO7vUK/pVmcsP9mQLXB0KZ8m/QEBXSO9vmF8dEt5OqtpRLcRzxmcnU1iUs50VSQyEeSxdSV4KA9JuWa+q0f3o3VO+CF6s4kQvQ4lumyCyNSFIBnFCX16+O8syah/UpHUWVqJeHaXCV8qzYKyRvy6nMI5lqCgxe+ENqHkgfkQkgEKHZ8gEnzHtJgewZ3E6fbjQ59eEEvF0zb7WKKWA0YzWOMVGGybj4cFMPQ4Jt7iJ0OZKPBQZMHBcPNrej5lasgcKR7nH5XS0UjHhX5vZJ7e7zONHK4XZj6OjEOXilg3/4rxSn0+QQtT1v0RDXRQhHS6sCyRFV12MqEP8XjPIdBMbE26lRwk3tBwWx7plj3UCVamQid3nY5kslD4X7+cqE8n3bNF922rhCy5STycfEFN3XTs73yKvVPjpro4aQw4BVi4P7B7m7F1d/DqRBuYwWuQ6cLLLLLLLLLLL= root@xxxxxx.xx.xxx.xxx.redhat.com" + invalidSSHPublicKeyB = "test!!! ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDi8KHZYGyPQjECHwytquI3rmpgoUn6M+lkeOD2nEKvYElLE5mPIeqF0izJIl56uar2wda+3z107M9QkatE+dP4S9/Ltrlm+/ktAf4O6UoxNLUzv/TGHasb9g3Xkt8JTkohVzVK36622Sd8kLzEc61v1AonLWIADtpwq6/GvHMAuPK2R/H0rdKhTokylKZLDdTqQ+KUFelI6RNIaUBjtVrwkx1j0htxN11DjBVuUyPT2O1ejWegtrM0T+4vXGEA3g3YfbT2k0YnEzjXXqngqbXCYEJCZidp3pJLH/ilo4Y4BId/bx/bhzcbkZPeKlLwjR8g9sydce39bzPIQj+b7nlFv1Vot/77VNwkjXjYPUdUPu0d1PkFD9jKDOdB3fAC61aG2a/8PFS08iBrKiMa48kn+hKXC4G4D5gj/QzIAgzWSl2tEzGQSoIVTucwOAL/jox2dmAa0RyKsnsHORppanuW4qD7KAcmas1GHrAqIfNyDiU2JR50r1jCxj5H76QxIuM= root@ocp-edge34.lab.eng.tlv2.redhat.com" + userName = "jdoe123@example.com" + validSecretFormatUpdated = "{\"auths\":{\"cloud.openshift.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"quay.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.connect.redhat.com\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.redhat.io\":{\"auth\":\"dXNlcjpwYXNzd29yZAo=\",\"email\":\"r@r.com\"},\"registry.stage.redhat.io\":{\"auth\":\"c29tZW9uZUBleGFtcGxlLmNvbTp0aGlzaXNhc2VjcmV0\"}}}" + regCred = "someone@example.com:thisisasecret" ) var _ = Describe("Pull secret validation", func() { @@ -58,35 +59,35 @@ var _ = Describe("Pull secret validation", func() { }) It("valid format", func() { - err := secretValiatorWithNoAuth.ValidatePullSecret(validSecretFormat, "") + err := secretValiatorWithNoAuth.ValidatePullSecret(validSecretFormat, "", "") Expect(err).ShouldNot(HaveOccurred()) }) It("empty secret", func() { - err := secretValiatorWithNoAuth.ValidatePullSecret("", "") + err := secretValiatorWithNoAuth.ValidatePullSecret("", "", "") Expect(err).Should(HaveOccurred()) }) It("invalid format for the auth", func() { - err := secretValiatorWithNoAuth.ValidatePullSecret(invalidAuthFormat, "") + err := secretValiatorWithNoAuth.ValidatePullSecret(invalidAuthFormat, "", "") Expect(err).Should(HaveOccurred()) Expect(err).Should(BeAssignableToTypeOf(&PullSecretError{})) }) It("invalid format", func() { - err := secretValiatorWithNoAuth.ValidatePullSecret(invalidSecretFormat, "") + err := secretValiatorWithNoAuth.ValidatePullSecret(invalidSecretFormat, "", "") Expect(err).Should(HaveOccurred()) Expect(err).Should(BeAssignableToTypeOf(&PullSecretError{})) }) It("invalid format - non-string", func() { - err := secretValiatorWithNoAuth.ValidatePullSecret(invalidStrSecretFormat, "") + err := secretValiatorWithNoAuth.ValidatePullSecret(invalidStrSecretFormat, "", "") Expect(err).Should(HaveOccurred()) Expect(err).Should(BeAssignableToTypeOf(&PullSecretError{})) }) It("valid format - Invalid user", func() { - err := secretValidator.ValidatePullSecret(validSecretFormat, "NotSameUser@example.com") + err := secretValidator.ValidatePullSecret(validSecretFormat, "NotSameUser@example.com", "") Expect(err).Should(HaveOccurred()) Expect(err).Should(BeAssignableToTypeOf(&PullSecretError{})) }) It("valid format - Valid user", func() { - err := secretValidator.ValidatePullSecret(validSecretFormat, userName) + err := secretValidator.ValidatePullSecret(validSecretFormat, userName, "") Expect(err).ShouldNot(HaveOccurred()) }) It("Add RH Reg PullSecret ", func() { @@ -108,14 +109,14 @@ var _ = Describe("Pull secret validation", func() { It("pull secret accepted when it contains all required registries", func() { validator, err := NewPullSecretValidator(Config{}, authHandlerDisabled, "quay.io/testing:latest", "registry.redhat.io/image:v1") Expect(err).ShouldNot(HaveOccurred()) - err = validator.ValidatePullSecret(validSecretFormat, "") + err = validator.ValidatePullSecret(validSecretFormat, "", "") Expect(err).ShouldNot(HaveOccurred()) }) It("pull secret accepted even if it does not contain registry.stage.redhat.io", func() { validator, err := NewPullSecretValidator(Config{}, authHandlerDisabled, "quay.io/testing:latest", "registry.stage.redhat.io/special:v1") Expect(err).ShouldNot(HaveOccurred()) - err = validator.ValidatePullSecret(validSecretFormat, "") + err = validator.ValidatePullSecret(validSecretFormat, "", "") Expect(err).ShouldNot(HaveOccurred()) }) @@ -125,42 +126,58 @@ var _ = Describe("Pull secret validation", func() { } validator, err := NewPullSecretValidator(config, authHandlerDisabled, "quay.io/testing:latest", "ignore.com/image:v1", "something.com/container:X") Expect(err).ShouldNot(HaveOccurred()) - err = validator.ValidatePullSecret(validSecretFormat, "") + err = validator.ValidatePullSecret(validSecretFormat, "", "") Expect(err).ShouldNot(HaveOccurred()) }) + It("pull secret accepted when release image is specified and its registry credentials exists", func() { + config := Config{} + validator, err := NewPullSecretValidator(config, authHandlerDisabled, "quay.io/testing:latest") + Expect(err).ShouldNot(HaveOccurred()) + err = validator.ValidatePullSecret(validPullSecretWithCIToken, "", "registry.ci/test:latest") + Expect(err).ShouldNot(HaveOccurred()) + }) + + It("pull secret is not accepted when release image is specified bit its registry credentials missing", func() { + config := Config{} + validator, err := NewPullSecretValidator(config, authHandlerDisabled, "quay.io/testing:latest") + Expect(err).ShouldNot(HaveOccurred()) + err = validator.ValidatePullSecret(validSecretFormat, "", "registry.ci/test:latest") + Expect(err).Should(HaveOccurred()) + }) + It("docker.io auth is accepted when there is an image from docker.io", func() { validator, err := NewPullSecretValidator(Config{}, authHandlerDisabled, "docker.io/testing:latest") Expect(err).ShouldNot(HaveOccurred()) - err = validator.ValidatePullSecret(pullSecDocker, "") + err = validator.ValidatePullSecret(pullSecDocker, "", "") Expect(err).ShouldNot(HaveOccurred()) }) It("legacy DockerHub auth is accepted when there is an image from docker.io", func() { validator, err := NewPullSecretValidator(Config{}, authHandlerDisabled, "docker.io/testing:latest") Expect(err).ShouldNot(HaveOccurred()) - err = validator.ValidatePullSecret(pullSecLegacyDocker, "") + err = validator.ValidatePullSecret(pullSecLegacyDocker, "", "") Expect(err).ShouldNot(HaveOccurred()) }) It("docker.io auth is accepted when there is an image with default registry", func() { validator, err := NewPullSecretValidator(Config{}, authHandlerDisabled, "local:v1") Expect(err).ShouldNot(HaveOccurred()) - err = validator.ValidatePullSecret(pullSecDocker, "") + err = validator.ValidatePullSecret(pullSecDocker, "", "") Expect(err).ShouldNot(HaveOccurred()) }) It("legacy DockerHub auth is accepted when there is an image with default registry", func() { validator, err := NewPullSecretValidator(Config{}, authHandlerDisabled, "local:v2") Expect(err).ShouldNot(HaveOccurred()) - err = validator.ValidatePullSecret(pullSecLegacyDocker, "") + err = validator.ValidatePullSecret(pullSecLegacyDocker, "", "") Expect(err).ShouldNot(HaveOccurred()) }) It("error when pull secret does not contain required registry", func() { validator, err := NewPullSecretValidator(Config{}, authHandlerDisabled, "quay.io/testing:latest", "required.com/image:v1") Expect(err).ShouldNot(HaveOccurred()) - err = validator.ValidatePullSecret(validSecretFormat, "") + err = validator.ValidatePullSecret(validSecretFormat, "", "") Expect(err).Should(HaveOccurred()) Expect(err).Should(BeAssignableToTypeOf(&PullSecretError{})) }) diff --git a/internal/cluster/validations/validations.go b/internal/cluster/validations/validations.go index 02c17ce1593..512629e2433 100644 --- a/internal/cluster/validations/validations.go +++ b/internal/cluster/validations/validations.go @@ -62,12 +62,13 @@ func init() { // //go:generate mockgen -source=validations.go -package=validations -destination=mock_validations.go type PullSecretValidator interface { - ValidatePullSecret(secret string, username string) error + ValidatePullSecret(secret string, username string, releaseImageURL string) error } type registryPullSecretValidator struct { - registriesWithAuth *map[string]bool - authHandler auth.Authenticator + config Config + images []string + authHandler auth.Authenticator } type imagePullSecret struct { @@ -171,20 +172,15 @@ func AddRHRegPullSecret(secret, rhCred string) (string, error) { // NewPullSecretValidator receives all images whose registries must have an entry in a user pull secret (auth) func NewPullSecretValidator(config Config, authHandler auth.Authenticator, images ...string) (PullSecretValidator, error) { - - authRegList, err := getRegistriesWithAuth(config.PublicRegistries, ignoreListSeparator, images...) - if err != nil { - return nil, err - } - return ®istryPullSecretValidator{ - registriesWithAuth: authRegList, - authHandler: authHandler, + config: config, + images: images, + authHandler: authHandler, }, nil } // ValidatePullSecret validates that a pull secret is well formed and contains all required data -func (v *registryPullSecretValidator) ValidatePullSecret(secret string, username string) error { +func (v *registryPullSecretValidator) ValidatePullSecret(secret string, username string, releaseImageURL string) error { creds, err := ParsePullSecret(secret) if err != nil { return err @@ -192,13 +188,13 @@ func (v *registryPullSecretValidator) ValidatePullSecret(secret string, username // only check for cloud creds if we're authenticating against Red Hat SSO if v.authHandler.AuthType() == auth.TypeRHSSO { - r, ok := creds["cloud.openshift.com"] if !ok { return &PullSecretError{Msg: "pull secret must contain auth for \"cloud.openshift.com\""} } - user, err := v.authHandler.AuthAgentAuth(r.AuthRaw) + var user interface{} + user, err = v.authHandler.AuthAgentAuth(r.AuthRaw) if err != nil { return &PullSecretError{Msg: "failed to authenticate the pull secret token"} } @@ -208,8 +204,19 @@ func (v *registryPullSecretValidator) ValidatePullSecret(secret string, username } } - for registry := range *v.registriesWithAuth { + images := make([]string, len(v.images)) + copy(images, v.images) + + if releaseImageURL != "" { + images = append(images, releaseImageURL) + } + + registriesWithAuth, err := getRegistriesWithAuth(v.config.PublicRegistries, ignoreListSeparator, images...) + if err != nil { + return err + } + for registry := range *registriesWithAuth { // Both "docker.io" and "https://index.docker.io/v1/" are acceptable for DockerHub login if registry == dockerHubRegistry { if _, ok := creds[dockerHubLegacyAuth]; ok { @@ -322,7 +329,6 @@ func ParseRegistry(image string) (string, error) { // on a list of used images and an ignore list. The ingore list comes as a string and a separator // to make it easier to read from a configuration variable func getRegistriesWithAuth(ignoreList string, ignoreSeparator string, images ...string) (*map[string]bool, error) { - ignored := make(map[string]bool) for _, i := range strings.Split(ignoreList, ignoreSeparator) { ignored[i] = true diff --git a/internal/controller/controllers/clusterdeployments_controller_test.go b/internal/controller/controllers/clusterdeployments_controller_test.go index 07aab004640..a6aeb68491e 100644 --- a/internal/controller/controllers/clusterdeployments_controller_test.go +++ b/internal/controller/controllers/clusterdeployments_controller_test.go @@ -274,7 +274,7 @@ var _ = Describe("cluster reconcile", func() { }) validateCreation := func(cluster *hivev1.ClusterDeployment) { - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) request := newClusterDeploymentRequest(cluster) result, err := cr.Reconcile(ctx, request) Expect(err).To(BeNil()) @@ -545,7 +545,7 @@ var _ = Describe("cluster reconcile", func() { It("fail to get openshift version when trying to create a cluster", func() { mockVersions.EXPECT().GetReleaseImageByURL(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.Errorf("some-error")) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) cluster := newClusterDeployment(clusterName, testNamespace, defaultClusterSpec) Expect(c.Create(ctx, cluster)).ShouldNot(HaveOccurred()) @@ -575,7 +575,7 @@ var _ = Describe("cluster reconcile", func() { errString := "internal error" mockInstallerInternal.EXPECT().RegisterClusterInternal(gomock.Any(), gomock.Any(), gomock.Any()). Return(nil, errors.Errorf(errString)) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockVersions.EXPECT().GetReleaseImageByURL(gomock.Any(), gomock.Any(), gomock.Any()).Return(releaseImage, nil) cluster := newClusterDeployment(clusterName, testNamespace, defaultClusterSpec) @@ -621,7 +621,7 @@ var _ = Describe("cluster reconcile", func() { imageSet := getDefaultTestImageSet(imageSetName, releaseImageUrl) Expect(c.Create(ctx, imageSet)).To(BeNil()) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockVersions.EXPECT().GetReleaseImageByURL(gomock.Any(), gomock.Any(), gomock.Any()).Return(releaseImage, nil) }) @@ -858,7 +858,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(0, 0, nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(false, "").Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) @@ -928,7 +928,7 @@ var _ = Describe("cluster reconcile", func() { It("validate ignitionEndpoint override doesn't trigger clusterUpdate unless required", func() { mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil).Times(2) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(2) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) pullSecret := getDefaultTestPullSecret("pull-secret", testNamespace) Expect(c.Create(ctx, pullSecret)).To(BeNil()) imageSet := getDefaultTestImageSet(imageSetName, releaseImageUrl) @@ -1322,7 +1322,7 @@ var _ = Describe("cluster reconcile", func() { Expect(result).Should(Equal(ctrl.Result{})) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(nil, gorm.ErrRecordNotFound) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().RegisterClusterInternal(gomock.Any(), gomock.Any(), gomock.Any()).Return(backEndCluster, nil) aci = newAgentClusterInstall(agentClusterInstallName, testNamespace, defaultAgentClusterInstallSpec, cd) @@ -1391,7 +1391,7 @@ var _ = Describe("cluster reconcile", func() { mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) installClusterReply := &common.Cluster{ Cluster: models.Cluster{ @@ -1417,7 +1417,7 @@ var _ = Describe("cluster reconcile", func() { It("hold installation", func() { backEndCluster.Status = swag.String(models.ClusterStatusReady) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(2) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(2) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(2) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) @@ -1466,7 +1466,7 @@ var _ = Describe("cluster reconcile", func() { It("hold installation by cluster deployment annotation", func() { backEndCluster.Status = swag.String(models.ClusterStatusReady) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(2) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(2) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(2) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) @@ -1515,7 +1515,7 @@ var _ = Describe("cluster reconcile", func() { It("CVO status", func() { backEndCluster.Status = swag.String(models.ClusterStatusReady) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) @@ -1556,7 +1556,7 @@ var _ = Describe("cluster reconcile", func() { It("CVO empty status", func() { backEndCluster.Status = swag.String(models.ClusterStatusReady) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) @@ -1597,7 +1597,7 @@ var _ = Describe("cluster reconcile", func() { backEndCluster.OpenshiftClusterID = openshiftID backEndCluster.Kind = swag.String(models.ClusterKindCluster) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(2) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(2) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) kubeconfig := "kubeconfig content" mockInstallerInternal.EXPECT().GetCredentialsInternal(gomock.Any(), gomock.Any()).Return(&models.Credentials{Password: "foo", Username: "bar"}, nil).Times(1) mockInstallerInternal.EXPECT().V2DownloadClusterCredentialsInternal(gomock.Any(), gomock.Any()).Return(io.NopCloser(strings.NewReader(kubeconfig)), int64(len(kubeconfig)), nil).Times(1) @@ -1637,7 +1637,7 @@ var _ = Describe("cluster reconcile", func() { backEndCluster.OpenshiftClusterID = openshiftID backEndCluster.Kind = swag.String(models.ClusterKindCluster) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(2) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(2) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(false, "").Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) password := "test" @@ -1683,7 +1683,7 @@ var _ = Describe("cluster reconcile", func() { backEndCluster.OpenshiftClusterID = openshiftID backEndCluster.Kind = swag.String(models.ClusterKindCluster) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(2) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(2) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) password := "test" username := "admin" @@ -1747,7 +1747,7 @@ var _ = Describe("cluster reconcile", func() { backEndCluster.OpenshiftClusterID = openshiftID backEndCluster.Kind = swag.String(models.ClusterKindCluster) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) day2backEndCluster := &common.Cluster{ Cluster: models.Cluster{ @@ -1795,7 +1795,7 @@ var _ = Describe("cluster reconcile", func() { backEndCluster.OpenshiftClusterID = openshiftID backEndCluster.Kind = swag.String(models.ClusterKindCluster) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) password := "test" username := "admin" cred := &models.Credentials{ @@ -1826,7 +1826,7 @@ var _ = Describe("cluster reconcile", func() { backEndCluster.OpenshiftClusterID = openshiftID backEndCluster.Kind = swag.String(models.ClusterKindCluster) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) expectedErr := "internal error" mockInstallerInternal.EXPECT().GetCredentialsInternal(gomock.Any(), gomock.Any()).Return(nil, errors.New(expectedErr)).Times(1) request := newClusterDeploymentRequest(cluster) @@ -1848,7 +1848,7 @@ var _ = Describe("cluster reconcile", func() { expectedErr := "internal error" backEndCluster.Status = swag.String(models.ClusterStatusReady) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().InstallClusterInternal(gomock.Any(), gomock.Any()). Return(nil, errors.Errorf(expectedErr)) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) @@ -1876,7 +1876,7 @@ var _ = Describe("cluster reconcile", func() { mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(false, "").Times(1) Expect(c.Update(ctx, cluster)).Should(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) request := newClusterDeploymentRequest(cluster) result, err := cr.Reconcile(ctx, request) @@ -1898,7 +1898,7 @@ var _ = Describe("cluster reconcile", func() { Expect(c.Update(ctx, cluster)).Should(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) request := newClusterDeploymentRequest(cluster) result, err := cr.Reconcile(ctx, request) Expect(err).To(BeNil()) @@ -1919,7 +1919,7 @@ var _ = Describe("cluster reconcile", func() { Expect(c.Update(ctx, cluster)).Should(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) request := newClusterDeploymentRequest(cluster) result, err := cr.Reconcile(ctx, request) Expect(err).To(BeNil()) @@ -1943,7 +1943,7 @@ var _ = Describe("cluster reconcile", func() { Expect(c.Update(ctx, cluster)).Should(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) request := newClusterDeploymentRequest(cluster) result, err := cr.Reconcile(ctx, request) Expect(err).To(BeNil()) @@ -1968,7 +1968,7 @@ var _ = Describe("cluster reconcile", func() { aci.Spec.ProvisionRequirements.WorkerAgents = 0 Expect(c.Update(ctx, aci)).Should(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) request := newClusterDeploymentRequest(cluster) result, err := cr.Reconcile(ctx, request) Expect(err).To(BeNil()) @@ -1992,7 +1992,7 @@ var _ = Describe("cluster reconcile", func() { aci.Spec.ProvisionRequirements.WorkerAgents = 0 Expect(c.Update(ctx, aci)).Should(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) request := newClusterDeploymentRequest(cluster) result, err := cr.Reconcile(ctx, request) Expect(err).To(BeNil()) @@ -2027,7 +2027,7 @@ var _ = Describe("cluster reconcile", func() { backEndCluster.Hosts = []*models.Host{h} commonHosts := []*common.Host{{Host: *h}} mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().GetKnownApprovedHosts(gomock.Any()).Return(commonHosts, nil) mockInstallerInternal.EXPECT().InstallSingleDay2HostInternal(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) @@ -2058,7 +2058,7 @@ var _ = Describe("cluster reconcile", func() { commonHosts := []*common.Host{{Host: *h}} expectedErr := "internal error" mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) mockInstallerInternal.EXPECT().GetKnownApprovedHosts(gomock.Any()).Return(commonHosts, nil) mockInstallerInternal.EXPECT().InstallSingleDay2HostInternal(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(errors.New(expectedErr)) @@ -2083,7 +2083,7 @@ var _ = Describe("cluster reconcile", func() { backEndCluster.Status = swag.String(models.ClusterStatusReady) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(2) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) @@ -2120,7 +2120,7 @@ var _ = Describe("cluster reconcile", func() { Expect(c.Create(ctx, cm)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(2) @@ -2147,7 +2147,7 @@ var _ = Describe("cluster reconcile", func() { It("Update manifests - manifests exists , list failed", func() { ref := &corev1.LocalObjectReference{Name: "cluster-install-config"} mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(2) @@ -2188,7 +2188,7 @@ var _ = Describe("cluster reconcile", func() { Expect(c.Create(ctx, cm)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockManifestsApi.EXPECT().CreateClusterManifestInternal(gomock.Any(), gomock.Any(), true).Return(nil, nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) @@ -2232,7 +2232,7 @@ var _ = Describe("cluster reconcile", func() { By("no manifests") mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(nil, nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(1) @@ -2249,7 +2249,7 @@ var _ = Describe("cluster reconcile", func() { It("Update manifests - delete old + error should be ignored", func() { mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{&models.Manifest{FileName: "test", Folder: "test"}, &models.Manifest{FileName: "test2", Folder: "test2"}}, nil).Times(1) mockManifestsApi.EXPECT().DeleteClusterManifestInternal(gomock.Any(), gomock.Any()).Return(nil).Times(1) mockManifestsApi.EXPECT().DeleteClusterManifestInternal(gomock.Any(), gomock.Any()).Return(errors.Errorf("ignore it")).Times(1) @@ -2313,7 +2313,7 @@ var _ = Describe("cluster reconcile", func() { Expect(c.Create(ctx, cm2)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockManifestsApi.EXPECT().CreateClusterManifestInternal(gomock.Any(), gomock.Any(), true).Return(nil, nil).Times(2) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) @@ -2378,7 +2378,7 @@ var _ = Describe("cluster reconcile", func() { Expect(c.Create(ctx, cm2)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(2) @@ -2437,7 +2437,7 @@ var _ = Describe("cluster reconcile", func() { Expect(c.Create(ctx, cm2)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockManifestsApi.EXPECT().ListClusterManifestsInternal(gomock.Any(), gomock.Any()).Return(models.ListManifests{}, nil).Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(2) @@ -2464,7 +2464,7 @@ var _ = Describe("cluster reconcile", func() { It("install cluster with API VIP and Ingress VIP", func() { backEndCluster.Status = swag.String(models.ClusterStatusReady) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(true, "").Times(1) mockInstallerInternal.EXPECT().GetKnownHostApprovedCounts(gomock.Any()).Return(5, 5, nil).Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) @@ -2568,7 +2568,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: "different-pull-secret", } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) updateReply := &common.Cluster{ Cluster: models.Cluster{ @@ -2619,7 +2619,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) updateReply := getDefaultTestCluster() @@ -2664,7 +2664,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) updateReply := &common.Cluster{ Cluster: models.Cluster{ @@ -2764,7 +2764,7 @@ var _ = Describe("cluster reconcile", func() { } backEndCluster.MachineNetworks = test.dbMachineNetworks mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) aci.Spec.Networking.MachineNetwork = test.specMachineNetworks @@ -2813,7 +2813,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) mockClusterApi.EXPECT().IsReadyForInstallation(gomock.Any()).Return(false, "").Times(1) request := newClusterDeploymentRequest(cluster) @@ -2859,7 +2859,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: "different-pull-secret", } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) errString := "update internal error" mockInstallerInternal.EXPECT().UpdateClusterNonInteractive(gomock.Any(), gomock.Any()). @@ -2895,7 +2895,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) installConfigOverrides := `{"controlPlane": {"hyperthreading": "Disabled"}}` updateReply := &common.Cluster{ @@ -2940,7 +2940,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) updateReply := &common.Cluster{ Cluster: models.Cluster{ ID: &sId, @@ -2981,7 +2981,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) installConfigOverrides := `{"controlPlane": {"hyperthreading": "Enabled"}}` updateReply := &common.Cluster{ @@ -3025,7 +3025,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) installConfigOverrides := `{{{"controlPlane": ""` mockInstallerInternal.EXPECT().UpdateClusterInstallConfigInternal(gomock.Any(), gomock.Any()). @@ -3077,7 +3077,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) pullSecret := getDefaultTestPullSecret("pull-secret", testNamespace) Expect(c.Create(ctx, pullSecret)).To(BeNil()) @@ -3117,7 +3117,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().V2DownloadClusterCredentialsInternal(gomock.Any(), gomock.Any()).Return(io.NopCloser(strings.NewReader("kubeconfig")), int64(len("kubeconfig")), nil).Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) mockInstallerInternal.EXPECT().UpdateClusterNonInteractive(gomock.Any(), gomock.Any()). @@ -3165,7 +3165,7 @@ var _ = Describe("cluster reconcile", func() { PullSecret: testPullSecretVal, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().V2DownloadClusterCredentialsInternal(gomock.Any(), gomock.Any()).Return(io.NopCloser(strings.NewReader("kubeconfig")), int64(len("kubeconfig")), nil).Times(1) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) @@ -3295,7 +3295,7 @@ var _ = Describe("cluster reconcile", func() { }, } mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(cluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().UpdateClusterNonInteractive(gomock.Any(), gomock.Any()).Return(cluster, nil) mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) mockClientFactory = spoke_k8s_client.NewMockSpokeK8sClientFactory(mockCtrl) @@ -4196,7 +4196,7 @@ var _ = Describe("day2 cluster", func() { Expect(result).To(Equal(ctrl.Result{})) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(dbCluster, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().GetKnownApprovedHosts(gomock.Any()).Return(nil, nil) // expected not to be called mockInstallerInternal.EXPECT().UpdateClusterInstallConfigInternal(gomock.Any(), gomock.Any()).Times(0) diff --git a/internal/controller/controllers/infraenv_controller_test.go b/internal/controller/controllers/infraenv_controller_test.go index aaa48df2113..033939b1d47 100644 --- a/internal/controller/controllers/infraenv_controller_test.go +++ b/internal/controller/controllers/infraenv_controller_test.go @@ -143,7 +143,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, clusterDeployment)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -183,7 +183,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, clusterDeployment)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -228,7 +228,7 @@ var _ = Describe("infraEnv reconcile", func() { }, } mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil).Return(dbInfraEnv, nil).Times(1) kubeInfraEnv := newInfraEnvImage("myInfraEnv", testNamespace, aiv1beta1.InfraEnvSpec{ PullSecretRef: &corev1.LocalObjectReference{Name: "pull-secret"}, @@ -286,7 +286,7 @@ var _ = Describe("infraEnv reconcile", func() { }, } mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil).Return(dbInfraEnv, nil).Times(1) kubeInfraEnv := newInfraEnvImage("myInfraEnv", testNamespace, aiv1beta1.InfraEnvSpec{ PullSecretRef: &corev1.LocalObjectReference{Name: "pull-secret"}, @@ -378,7 +378,7 @@ var _ = Describe("infraEnv reconcile", func() { } backendInfraEnv.KernelArguments = encodeKernelArguments(initialKargs) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil).Times(1) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) kubeInfraEnv := newInfraEnvImage("myInfraEnv", testNamespace, aiv1beta1.InfraEnvSpec{ PullSecretRef: &corev1.LocalObjectReference{Name: "pull-secret"}, KernelArguments: initialKargs, @@ -419,7 +419,7 @@ var _ = Describe("infraEnv reconcile", func() { }, } mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil).Return(dbInfraEnv, nil).Times(1) kubeInfraEnv := newInfraEnvImage("myInfraEnv", testNamespace, aiv1beta1.InfraEnvSpec{ PullSecretRef: &corev1.LocalObjectReference{Name: "pull-secret"}, @@ -488,7 +488,7 @@ var _ = Describe("infraEnv reconcile", func() { }, } mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil).AnyTimes() - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil).Return(dbInfraEnv, nil).Times(2) kubeInfraEnv := newInfraEnvImage("myInfraEnv", testNamespace, aiv1beta1.InfraEnvSpec{ @@ -530,7 +530,7 @@ var _ = Describe("infraEnv reconcile", func() { expectedError := common.NewApiError(http.StatusInternalServerError, errors.New("server error")) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -625,7 +625,7 @@ var _ = Describe("infraEnv reconcile", func() { expectedError := common.NewApiError(http.StatusConflict, errors.New("Another request to generate an image has been recently submitted. Please wait a few seconds and try again.")) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -662,7 +662,7 @@ var _ = Describe("infraEnv reconcile", func() { expectedClientError := common.NewApiError(http.StatusBadRequest, errors.New("client error")) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(2) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil).Times(2) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -688,7 +688,7 @@ var _ = Describe("infraEnv reconcile", func() { // retry immediately expectedConflictError := common.NewApiError(http.StatusConflict, errors.New("Another request to generate an image has been recently submitted. Please wait a few seconds and try again.")) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -706,7 +706,7 @@ var _ = Describe("infraEnv reconcile", func() { expectedError := common.NewApiError(http.StatusBadRequest, errors.New("client error")) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -782,7 +782,7 @@ var _ = Describe("infraEnv reconcile", func() { mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -810,7 +810,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, infraEnvImage)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -837,7 +837,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, infraEnvImage)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -864,7 +864,7 @@ var _ = Describe("infraEnv reconcile", func() { mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil).Return(nil, errors.Errorf("failure")).Times(1) res, err := ir.Reconcile(ctx, newInfraEnvRequest(infraEnvImage)) @@ -885,7 +885,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, clusterDeployment)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -933,7 +933,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, clusterDeployment)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -980,7 +980,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, clusterDeployment)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -1040,7 +1040,7 @@ var _ = Describe("infraEnv reconcile", func() { }) Expect(c.Create(ctx, infraEnvImage)).To(BeNil()) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(nil, gorm.ErrRecordNotFound) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().RegisterInfraEnvInternal(gomock.Any(), gomock.Any(), gomock.Any()). Do(func(ctx context.Context, kubeKey *types.NamespacedName, params installer.RegisterInfraEnvParams) { Expect(params.InfraenvCreateParams.OpenshiftVersion).To(Equal(osImageVersion)) @@ -1086,7 +1086,7 @@ var _ = Describe("infraEnv reconcile", func() { }) Expect(c.Create(ctx, infraEnvImage)).To(BeNil()) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(nil, gorm.ErrRecordNotFound) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().RegisterInfraEnvInternal(gomock.Any(), gomock.Any(), gomock.Any()). Do(func(ctx context.Context, kubeKey *types.NamespacedName, params installer.RegisterInfraEnvParams) { Expect(params.InfraenvCreateParams.OpenshiftVersion).To(Equal("")) @@ -1118,7 +1118,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, infraEnvImage)).To(BeNil()) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(nil, gorm.ErrRecordNotFound) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(1) mockInstallerInternal.EXPECT().RegisterInfraEnvInternal(gomock.Any(), gomock.Any(), gomock.Any()). Do(func(ctx context.Context, kubeKey *types.NamespacedName, params installer.RegisterInfraEnvParams) { Expect(params.InfraenvCreateParams.OpenshiftVersion).To(Equal(ocpVersion)) @@ -1143,7 +1143,7 @@ var _ = Describe("infraEnv reconcile", func() { Expect(c.Create(ctx, clusterDeployment)).To(BeNil()) mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil).Times(2) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil).Times(2) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(2) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -1260,7 +1260,7 @@ var _ = Describe("infraEnv reconcile", func() { mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -1295,7 +1295,7 @@ var _ = Describe("infraEnv reconcile", func() { // in the namespace when the selector is omitted. mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) @@ -1332,7 +1332,7 @@ var _ = Describe("infraEnv reconcile", func() { mockInstallerInternal.EXPECT().GetClusterByKubeKey(gomock.Any()).Return(backEndCluster, nil) expectedError := common.NewApiError(http.StatusBadRequest, errors.New("internal error")) mockInstallerInternal.EXPECT().GetInfraEnvByKubeKey(gomock.Any()).Return(backendInfraEnv, nil) - mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil) + mockInstallerInternal.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) mockInstallerInternal.EXPECT().UpdateInfraEnvInternal(gomock.Any(), gomock.Any(), nil). Do(func(ctx context.Context, params installer.UpdateInfraEnvParams, internalIgnitionConfig *string) { Expect(params.InfraEnvID).To(Equal(*backendInfraEnv.ID)) diff --git a/internal/controller/controllers/pullsecret_handler.go b/internal/controller/controllers/pullsecret_handler.go index 136767612b7..cbb1e09b9af 100644 --- a/internal/controller/controllers/pullsecret_handler.go +++ b/internal/controller/controllers/pullsecret_handler.go @@ -39,7 +39,7 @@ func (ps *pullSecretManager) GetValidPullSecret(ctx context.Context, key types.N return "", err } - err = ps.Installer.ValidatePullSecret(pullSecret, "") + err = ps.Installer.ValidatePullSecret(pullSecret, "", "") if err != nil { return "", errors.Wrap(err, fmt.Sprintf("invalid pull secret data in secret %s %s", key.Name, pullSecret)) }