Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
Signed-off-by: Vishwanath Hiremath <[email protected]>
  • Loading branch information
vishwahiremat committed Feb 16, 2024
1 parent c784e27 commit 990ca8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/corerp/frontend/controller/secretstores/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ func UpsertSecret(ctx context.Context, newResource, old *datamodel.SecretStore,
if ref == "" && old != nil {
ref = old.Properties.Resource
}
if isGlobalScopedResource(newResource) && newResource.Properties.Resource == "" {
if isGlobalScopedResource(newResource) && ref == "" {
return rest.NewBadRequestResponse("$.properties.resource cannot be empty for global scoped resource."), nil
}

ns, name, err := fromResourceID(ref)
if err != nil {
return nil, err
Expand All @@ -198,6 +199,7 @@ func UpsertSecret(ctx context.Context, newResource, old *datamodel.SecretStore,
return nil, err
}
}

err = options.KubeClient.Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}})
if err != nil && apierrors.IsAlreadyExists(err) {
logger.Info("Using existing namespace", "namespace", ns)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ func TestUpsertSecret(t *testing.T) {
"secret0"),
}, newResource.Properties.Status.OutputResources[0])
})

t.Run("create a new secret resource with invalid resource", func(t *testing.T) {
ctrl := gomock.NewController(t)
sc := store.NewMockStorageClient(ctrl)
Expand All @@ -522,6 +523,7 @@ func TestUpsertSecret(t *testing.T) {
require.Error(t, err)
require.Equal(t, err.Error(), "no Kubernetes namespace")
})

t.Run("create a new secret resource with empty resource", func(t *testing.T) {
ctrl := gomock.NewController(t)
sc := store.NewMockStorageClient(ctrl)
Expand Down

0 comments on commit 990ca8f

Please sign in to comment.