Skip to content

Commit

Permalink
ARO-4373 add RP Feature Flag EnablePublicOIDCBlobAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdeepc2792 committed Jun 10, 2024
1 parent 6f5e60a commit 0d6abaf
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 32 deletions.
2 changes: 2 additions & 0 deletions docs/feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ feature flags defined in pkg/env/env.go. At the time of writing these include:

* EnableOCMEndpoints: Register the OCM endpoints in the frontend. Otherwise the
endpoints are not available at all.

* EnablePublicOIDCBlobAccess: Allow the Public access to the OIDC blob in case the environment needs a decoupling from an AFD endpoint. Production will always use AFD endpoint so no public access for the production.
2 changes: 1 addition & 1 deletion pkg/cluster/deploybaseresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (m *manager) createOIDC(ctx context.Context) error {

publicAccess := azstorage.PublicAccessNone
// Public access on OIDC Container needed for development environments because of no AFD availability
if m.env.IsLocalDevelopmentMode() {
if m.env.FeatureIsSet(env.FeatureEnablePublicOIDCBlobAccess) {
publicAccess = azstorage.PublicAccessBlob
}
err := m.rpBlob.CreateBlobContainer(ctx, m.env.ResourceGroup(), m.env.OIDCStorageAccountName(), blobContainerName, publicAccess)
Expand Down
56 changes: 28 additions & 28 deletions pkg/cluster/deploybaseresources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1466,12 +1466,12 @@ func TestCreateOIDC(t *testing.T) {
},
},
},
mocks: func(blob *mock_azblob.MockManager, env *mock_env.MockInterface, azblobClient *mock_azblob.MockAZBlobClient) {
env.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
env.EXPECT().IsLocalDevelopmentMode().Return(false)
env.EXPECT().ResourceGroup().Return(resourceGroupName)
env.EXPECT().Environment().Return(&azureclient.PublicCloud)
env.EXPECT().OIDCEndpoint().Return(afdEndpoint)
mocks: func(blob *mock_azblob.MockManager, menv *mock_env.MockInterface, azblobClient *mock_azblob.MockAZBlobClient) {
menv.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
menv.EXPECT().FeatureIsSet(env.FeatureEnablePublicOIDCBlobAccess).Return(false)
menv.EXPECT().ResourceGroup().Return(resourceGroupName)
menv.EXPECT().Environment().Return(&azureclient.PublicCloud)
menv.EXPECT().OIDCEndpoint().Return(afdEndpoint)
blob.EXPECT().CreateBlobContainer(gomock.Any(), resourceGroupName, oidcStorageAccountName, gomock.Any(), azstorage.PublicAccessNone).Return(nil)
azblobClient.EXPECT().UploadBuffer(gomock.Any(), "", oidcbuilder.DiscoveryDocumentKey, gomock.Any()).Return(nil)
azblobClient.EXPECT().UploadBuffer(gomock.Any(), "", oidcbuilder.JWKSKey, gomock.Any()).Return(nil)
Expand All @@ -1494,12 +1494,12 @@ func TestCreateOIDC(t *testing.T) {
},
},
},
mocks: func(blob *mock_azblob.MockManager, env *mock_env.MockInterface, azblobClient *mock_azblob.MockAZBlobClient) {
env.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
env.EXPECT().IsLocalDevelopmentMode().Return(true)
env.EXPECT().ResourceGroup().Return(resourceGroupName)
env.EXPECT().Environment().Return(&azureclient.PublicCloud)
env.EXPECT().OIDCEndpoint().Return(storageEndpointForDev)
mocks: func(blob *mock_azblob.MockManager, menv *mock_env.MockInterface, azblobClient *mock_azblob.MockAZBlobClient) {
menv.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
menv.EXPECT().FeatureIsSet(env.FeatureEnablePublicOIDCBlobAccess).Return(true)
menv.EXPECT().ResourceGroup().Return(resourceGroupName)
menv.EXPECT().Environment().Return(&azureclient.PublicCloud)
menv.EXPECT().OIDCEndpoint().Return(storageEndpointForDev)
blob.EXPECT().CreateBlobContainer(gomock.Any(), resourceGroupName, oidcStorageAccountName, gomock.Any(), azstorage.PublicAccessBlob).Return(nil)
azblobClient.EXPECT().UploadBuffer(gomock.Any(), "", oidcbuilder.DiscoveryDocumentKey, gomock.Any()).Return(nil)
azblobClient.EXPECT().UploadBuffer(gomock.Any(), "", oidcbuilder.JWKSKey, gomock.Any()).Return(nil)
Expand All @@ -1522,10 +1522,10 @@ func TestCreateOIDC(t *testing.T) {
},
},
},
mocks: func(blob *mock_azblob.MockManager, env *mock_env.MockInterface, azblob *mock_azblob.MockAZBlobClient) {
env.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
env.EXPECT().IsLocalDevelopmentMode().Return(false)
env.EXPECT().ResourceGroup().Return(resourceGroupName)
mocks: func(blob *mock_azblob.MockManager, menv *mock_env.MockInterface, azblob *mock_azblob.MockAZBlobClient) {
menv.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
menv.EXPECT().FeatureIsSet(env.FeatureEnablePublicOIDCBlobAccess).Return(false)
menv.EXPECT().ResourceGroup().Return(resourceGroupName)
blob.EXPECT().CreateBlobContainer(gomock.Any(), resourceGroupName, oidcStorageAccountName, gomock.Any(), azstorage.PublicAccessNone).Return(errors.New("generic error"))
},
wantBoundServiceAccountSigningKey: false,
Expand All @@ -1545,12 +1545,12 @@ func TestCreateOIDC(t *testing.T) {
},
},
},
mocks: func(blob *mock_azblob.MockManager, env *mock_env.MockInterface, azblobClient *mock_azblob.MockAZBlobClient) {
env.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
env.EXPECT().IsLocalDevelopmentMode().Return(false)
env.EXPECT().ResourceGroup().Return(resourceGroupName)
env.EXPECT().Environment().Return(&azureclient.PublicCloud)
env.EXPECT().OIDCEndpoint().Return(afdEndpoint)
mocks: func(blob *mock_azblob.MockManager, menv *mock_env.MockInterface, azblobClient *mock_azblob.MockAZBlobClient) {
menv.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
menv.EXPECT().FeatureIsSet(env.FeatureEnablePublicOIDCBlobAccess).Return(false)
menv.EXPECT().ResourceGroup().Return(resourceGroupName)
menv.EXPECT().Environment().Return(&azureclient.PublicCloud)
menv.EXPECT().OIDCEndpoint().Return(afdEndpoint)
blob.EXPECT().CreateBlobContainer(gomock.Any(), resourceGroupName, oidcStorageAccountName, gomock.Any(), azstorage.PublicAccessNone).Return(nil)
blob.EXPECT().GetAZBlobClient(gomock.Any(), &azblob.ClientOptions{}).Return(azblobClient, errors.New("generic error"))
},
Expand All @@ -1571,12 +1571,12 @@ func TestCreateOIDC(t *testing.T) {
},
},
},
mocks: func(blob *mock_azblob.MockManager, env *mock_env.MockInterface, azblobClient *mock_azblob.MockAZBlobClient) {
env.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
env.EXPECT().IsLocalDevelopmentMode().Return(false)
env.EXPECT().ResourceGroup().Return(resourceGroupName)
env.EXPECT().Environment().Return(&azureclient.PublicCloud)
env.EXPECT().OIDCEndpoint().Return(afdEndpoint)
mocks: func(blob *mock_azblob.MockManager, menv *mock_env.MockInterface, azblobClient *mock_azblob.MockAZBlobClient) {
menv.EXPECT().OIDCStorageAccountName().AnyTimes().Return(oidcStorageAccountName)
menv.EXPECT().FeatureIsSet(env.FeatureEnablePublicOIDCBlobAccess).Return(false)
menv.EXPECT().ResourceGroup().Return(resourceGroupName)
menv.EXPECT().Environment().Return(&azureclient.PublicCloud)
menv.EXPECT().OIDCEndpoint().Return(afdEndpoint)
blob.EXPECT().CreateBlobContainer(gomock.Any(), resourceGroupName, oidcStorageAccountName, gomock.Any(), azstorage.PublicAccessNone).Return(nil)
azblobClient.EXPECT().UploadBuffer(gomock.Any(), "", oidcbuilder.DiscoveryDocumentKey, gomock.Any()).Return(nil)
azblobClient.EXPECT().UploadBuffer(gomock.Any(), "", oidcbuilder.JWKSKey, gomock.Any()).Return(errors.New("generic error"))
Expand Down
1 change: 1 addition & 0 deletions pkg/deploy/devconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func DevConfig(_env env.Core) (*Config, error) {
"RequireD2sV3Workers",
"DisableReadinessDelay",
"EnableOCMEndpoints",
"EnablePublicOIDCBlobAccess",
},
// TODO update this to support FF
RPImagePrefix: to.StringPtr(os.Getenv("USER") + "aro.azurecr.io/aro"),
Expand Down
1 change: 1 addition & 0 deletions pkg/env/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func newDev(ctx context.Context, log *logrus.Entry, component ServiceComponent)
FeatureDisableSignedCertificates,
FeatureRequireD2sV3Workers,
FeatureDisableReadinessDelay,
FeatureEnablePublicOIDCBlobAccess,
} {
d.features[feature] = true
}
Expand Down
1 change: 1 addition & 0 deletions pkg/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
FeatureRequireD2sV3Workers
FeatureDisableReadinessDelay
FeatureEnableOCMEndpoints
FeatureEnablePublicOIDCBlobAccess
)

const (
Expand Down
7 changes: 4 additions & 3 deletions pkg/env/zz_generated_feature_enumer.go

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

0 comments on commit 0d6abaf

Please sign in to comment.