Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 120 additions & 60 deletions pkg/api/validate/openshiftcluster_validatedynamic.go

Large diffs are not rendered by default.

26 changes: 4 additions & 22 deletions pkg/api/validate/openshiftcluster_validatedynamic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,7 @@ func TestValidateProviders(t *testing.T) {

tt.mocks(providerClient)

dv := &openShiftClusterDynamicValidator{
log: logrus.NewEntry(logrus.StandardLogger()),
spProviders: providerClient,
}

err := dv.validateProviders(ctx)
err := validateProviders(ctx, logrus.NewEntry(logrus.StandardLogger()), providerClient)
if err != nil && err.Error() != tt.wantErr ||
err == nil && tt.wantErr != "" {
t.Error(err)
Expand Down Expand Up @@ -466,12 +461,7 @@ func TestValidateVnet(t *testing.T) {
tt.modifyVnet(vnet)
}

dv := &openShiftClusterDynamicValidator{
log: logrus.NewEntry(logrus.StandardLogger()),
oc: oc,
}

err := dv.validateVnet(ctx, vnet)
err := validateVnet(ctx, logrus.NewEntry(logrus.StandardLogger()), oc, vnet)
if err != nil && err.Error() != tt.wantErr ||
err == nil && tt.wantErr != "" {
t.Error(err)
Expand All @@ -488,10 +478,6 @@ func TestValidateVnetPermissions(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()

dv := &openShiftClusterDynamicValidator{
log: logrus.NewEntry(logrus.StandardLogger()),
}

for _, tt := range []struct {
name string
mocks func(*mock_authorization.MockPermissionsClient, func())
Expand Down Expand Up @@ -563,7 +549,7 @@ func TestValidateVnetPermissions(t *testing.T) {

tt.mocks(permissionsClient, cancel)

err := dv.validateVnetPermissions(ctx, mockrefreshable.NewMockAuthorizer(controller), permissionsClient, vnetID, &azure.Resource{}, api.CloudErrorCodeInvalidResourceProviderPermissions, "resource provider")
err := validateVnetPermissions(ctx, logrus.NewEntry(logrus.StandardLogger()), mockrefreshable.NewMockAuthorizer(controller), permissionsClient, vnetID, &azure.Resource{}, api.CloudErrorCodeInvalidResourceProviderPermissions, "resource provider")
if err != nil && err.Error() != tt.wantErr ||
err == nil && tt.wantErr != "" {
t.Error(err)
Expand All @@ -583,10 +569,6 @@ func TestValidateRouteTablePermissionsSubnet(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()

dv := &openShiftClusterDynamicValidator{
log: logrus.NewEntry(logrus.StandardLogger()),
}

for _, tt := range []struct {
name string
mocks func(*mock_authorization.MockPermissionsClient, func())
Expand Down Expand Up @@ -693,7 +675,7 @@ func TestValidateRouteTablePermissionsSubnet(t *testing.T) {
tt.vnet(vnet)
}

err := dv.validateRouteTablePermissionsSubnet(ctx, mockrefreshable.NewMockAuthorizer(controller), permissionsClient, vnet, tt.subnet, "properties.masterProfile.subnetId", api.CloudErrorCodeInvalidResourceProviderPermissions, "resource provider")
err := validateRouteTablePermissionsSubnet(ctx, logrus.NewEntry(logrus.StandardLogger()), mockrefreshable.NewMockAuthorizer(controller), permissionsClient, vnet, tt.subnet, "properties.masterProfile.subnetId", api.CloudErrorCodeInvalidResourceProviderPermissions, "resource provider")
if err != nil && err.Error() != tt.wantErr ||
err == nil && tt.wantErr != "" {
t.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validate/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func NewAzureQuotaValidator(ctx context.Context, log *logrus.Entry, env env.Inte
return nil, err
}

spAuthorizer, err := validateServicePrincipalProfile(ctx, log, env, oc, subscriptionDoc)
spAuthorizer, err := validateServicePrincipalProfile(ctx, log, &oc.Properties.ServicePrincipalProfile, subscriptionDoc.Subscription.Properties.TenantID, env.Environment().ResourceManagerEndpoint)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/deploystorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (m *manager) clusterSPObjectID(ctx context.Context) (string, error) {
var clusterSPObjectID string
spp := &m.doc.OpenShiftCluster.Properties.ServicePrincipalProfile

token, err := aad.GetToken(ctx, m.log, m.doc.OpenShiftCluster, m.subscriptionDoc, m.env.Environment().GraphEndpoint)
token, err := aad.GetToken(ctx, m.log, &m.doc.OpenShiftCluster.Properties.ServicePrincipalProfile, m.subscriptionDoc.Subscription.Properties.TenantID, m.env.Environment().GraphEndpoint)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func (m *manager) validateResources(ctx context.Context) error {
ocDynamicValidator := validate.NewOpenShiftClusterDynamicValidator(
ocDynamicValidator := validate.NewOpenShiftClusterFullDynamicValidator(
m.log, m.env, m.doc.OpenShiftCluster, m.subscriptionDoc, m.fpAuthorizer,
)
return ocDynamicValidator.Dynamic(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ type ClusterSpec struct {
ResourceID string `json:"resourceId,omitempty"`
ACRName string `json:"acrName,omitempty"`
ACRDomain string `json:"acrDomain,omitempty"`
AZEnvironment string `json:"azEnvironment,omitempty"`
Location string `json:"location,omitempty"`
GenevaLogging GenevaLoggingSpec `json:"genevaLogging,omitempty"`
InternetChecker InternetCheckerSpec `json:"internetChecker,omitempty"`

Features FeaturesSpec `json:"features,omitempty"`
VNetID string `json:"vnetId,omitempty"`
Features FeaturesSpec `json:"features,omitempty"`
}

// FeaturesSpec defines ARO operator feature gates
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/deploy/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions pkg/operator/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
"github.com/Azure/ARO-RP/pkg/util/ready"
"github.com/Azure/ARO-RP/pkg/util/restconfig"
"github.com/Azure/ARO-RP/pkg/util/subnet"
"github.com/Azure/ARO-RP/pkg/util/tls"
"github.com/Azure/ARO-RP/pkg/util/version"
)
Expand Down Expand Up @@ -138,6 +139,11 @@ func (o *operator) resources() ([]runtime.Object, error) {
return nil, fmt.Errorf("unsupported cloud environment")
}

vnetID, _, err := subnet.Split(o.oc.Properties.MasterProfile.SubnetID)
if err != nil {
return nil, err
}

// create a secret here for genevalogging, later we will copy it to
// the genevalogging namespace.
return append(results,
Expand All @@ -157,9 +163,11 @@ func (o *operator) resources() ([]runtime.Object, error) {
Name: arov1alpha1.SingletonClusterName,
},
Spec: arov1alpha1.ClusterSpec{
ResourceID: o.oc.ID,
ACRDomain: o.env.ACRDomain(),
Location: o.env.Location(),
ResourceID: o.oc.ID,
ACRDomain: o.env.ACRDomain(),
AZEnvironment: o.env.Environment().Name,
Location: o.env.Location(),
VNetID: vnetID,
GenevaLogging: arov1alpha1.GenevaLoggingSpec{
ConfigVersion: o.env.ClustersGenevaLoggingConfigVersion(),
MonitoringGCSEnvironment: o.env.ClustersGenevaLoggingEnvironment(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ spec:
type: string
acrName:
type: string
azEnvironment:
type: string
features:
description: FeaturesSpec defines ARO operator feature gates
properties:
Expand Down Expand Up @@ -69,6 +71,8 @@ spec:
resourceId:
description: ResourceID is the Azure resourceId of the cluster
type: string
vnetId:
type: string
type: object
status:
description: ClusterStatus defines the observed state of Cluster
Expand Down
Loading