Skip to content

Create secret Page #2224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
618ce9f
create sercet
AsmaaNabilBakr Jan 15, 2023
53bc63a
Merge branch 'main' of https://github.com/weaveworks/weave-gitops-ent…
AsmaaNabilBakr Jan 15, 2023
eb6f1e2
Allow git repo selection for gitAuth
AsmaaNabilBakr Jan 16, 2023
58f54a4
Merge branch 'main' into create-secret
AsmaaNabilBakr Jan 16, 2023
88dd6e5
replace secret store kind with Type
AsmaaNabilBakr Jan 18, 2023
a571314
Merge branch 'main' into create-secret
ahussein3 Jan 18, 2023
7780716
add context provider
AsmaaNabilBakr Jan 18, 2023
fc5bb36
update dependecy array
ahussein3 Jan 18, 2023
bcd076a
add return to a function
AsmaaNabilBakr Jan 18, 2023
535eb2b
setting gitlab as default repo for testing purposes
ahussein3 Jan 18, 2023
005a1aa
fix list secret stores (#2247)
Jan 18, 2023
3a89570
revert auth changes
ahussein3 Jan 19, 2023
d88d3e8
Merge branch 'create-secret' of github.com:weaveworks/weave-gitops-en…
ahussein3 Jan 19, 2023
4a34baa
Merge branch 'main' into create-secret
ahussein3 Jan 19, 2023
8953af5
fix handle cluster secret store namespace
AsmaaNabilBakr Jan 19, 2023
d1959b2
show selected cluster after gitlab auth
ahussein3 Jan 19, 2023
b87cc98
git latest from main
ahussein3 Jan 19, 2023
ac597f7
update target cluster after gitlab auth
ahussein3 Jan 19, 2023
39ccc5c
set flag ShowAuthDialog with true
AsmaaNabilBakr Jan 19, 2023
002dab3
hide unbootstrapped clusters from list
AsmaaNabilBakr Jan 22, 2023
1357c79
fix data binding in gitlab Auth
AsmaaNabilBakr Jan 22, 2023
23688d9
Merge branch 'main' into create-secret
waleedhammam Jan 23, 2023
b7f4b4e
fix cluster secret store
waleedhammam Jan 23, 2023
aa9e8a4
Merge branch 'main' into create-secret
ahussein3 Jan 23, 2023
2558573
set kind as secretStore/clusterSecretStore - UI
AsmaaNabilBakr Jan 23, 2023
ef2398f
Merge pull request #2268 from weaveworks/dev-cluster-secret
waleedhammam Jan 24, 2023
8ea2a25
fix secret store type in get secret details (#2275)
Jan 24, 2023
7b9c2dd
fix material ui Warning
AsmaaNabilBakr Jan 24, 2023
7ecf7e7
Merge branch 'main' into create-secret
AsmaaNabilBakr Jan 29, 2023
3b823ba
splitting Create Form
AsmaaNabilBakr Jan 29, 2023
98ae520
move handle select secretStore from create comp.
AsmaaNabilBakr Jan 29, 2023
9f21b3e
fix route file & selected secret store
AsmaaNabilBakr Jan 30, 2023
91cd5f4
refactor use effect to reduce number of renders
Jan 30, 2023
43e0c78
remove uneeded .length
Jan 30, 2023
7d5f1fb
Merge branch 'main' into create-secret
ahussein3 Jan 30, 2023
9a28605
Merge branch 'main' into create-secret
AsmaaNabilBakr Jan 30, 2023
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
1 change: 1 addition & 0 deletions cmd/clusters-service/api/cluster_services.proto
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ message ExternalSecretSpec {

message externalSecretStoreRef {
string name = 1;
string kind = 2;
}

message externalSecretTarget {
Expand Down
3 changes: 3 additions & 0 deletions cmd/clusters-service/api/cluster_services.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3125,6 +3125,9 @@
"properties": {
"name": {
"type": "string"
},
"kind": {
"type": "string"
}
}
},
Expand Down
1,583 changes: 796 additions & 787 deletions cmd/clusters-service/pkg/protos/cluster_services.pb.go

Large diffs are not rendered by default.

320 changes: 192 additions & 128 deletions cmd/clusters-service/pkg/protos/cluster_services.pb.gw.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions cmd/clusters-service/pkg/protos/cluster_services_grpc.pb.go

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

5 changes: 4 additions & 1 deletion cmd/clusters-service/pkg/server/automations.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func createExternalSecretObject(es *capiv1_proto.ExternalSecret) (*esv1beta1.Ext
Spec: esv1beta1.ExternalSecretSpec{
SecretStoreRef: esv1beta1.SecretStoreRef{
Name: es.Spec.SecretStoreRef.Name,
Kind: "SecretStore",
Kind: es.Spec.SecretStoreRef.Kind,
},
RefreshInterval: &metav1.Duration{
Duration: refreshInterval,
Expand Down Expand Up @@ -533,6 +533,9 @@ func validateExternalSecret(externalSecret *capiv1_proto.ExternalSecret) error {
if externalSecret.Spec.SecretStoreRef.Name == "" {
err = multierror.Append(err, fmt.Errorf("secretStoreRef name must be specified in ExternalSecret %s", externalSecret.Metadata.Name))
}
if externalSecret.Spec.SecretStoreRef.Kind == "" {
err = multierror.Append(err, fmt.Errorf("secretStoreRef kind must be specified in ExternalSecret %s", externalSecret.Metadata.Name))
}
}

if externalSecret.Spec.Target == nil {
Expand Down
9 changes: 8 additions & 1 deletion cmd/clusters-service/pkg/server/automations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ status: {}
RefreshInterval: "1h",
SecretStoreRef: &capiv1_protos.ExternalSecretStoreRef{
Name: "testname",
Kind: "SecretStore",
},
Target: &capiv1_protos.ExternalSecretTarget{
Name: "new-secret",
Expand Down Expand Up @@ -751,6 +752,7 @@ status:
RefreshInterval: "1h",
SecretStoreRef: &capiv1_protos.ExternalSecretStoreRef{
Name: "testname",
Kind: "SecretStore",
},
Target: &capiv1_protos.ExternalSecretTarget{
Name: "new-secret",
Expand Down Expand Up @@ -814,6 +816,7 @@ status:
RefreshInterval: "1h",
SecretStoreRef: &capiv1_protos.ExternalSecretStoreRef{
Name: "testname",
Kind: "SecretStore",
},
Target: &capiv1_protos.ExternalSecretTarget{
Name: "new-secret",
Expand Down Expand Up @@ -880,6 +883,7 @@ status:
RefreshInterval: "1h",
SecretStoreRef: &capiv1_protos.ExternalSecretStoreRef{
Name: "testname",
Kind: "SecretStore",
},
Target: &capiv1_protos.ExternalSecretTarget{
Name: "new-secret",
Expand Down Expand Up @@ -944,7 +948,9 @@ status:
Metadata: testNewMetadata(t, "new-secret", "flux-system"),
Spec: &capiv1_protos.ExternalSecretSpec{
RefreshInterval: "1h",
SecretStoreRef: &capiv1_protos.ExternalSecretStoreRef{},
SecretStoreRef: &capiv1_protos.ExternalSecretStoreRef{
Kind: "SecretStore",
},
Target: &capiv1_protos.ExternalSecretTarget{
Name: "new-secret",
},
Expand Down Expand Up @@ -1010,6 +1016,7 @@ status:
RefreshInterval: "1h",
SecretStoreRef: &capiv1_protos.ExternalSecretStoreRef{
Name: "testname",
Kind: "SecretStore",
},
Target: &capiv1_protos.ExternalSecretTarget{
Name: "new-secret",
Expand Down
56 changes: 45 additions & 11 deletions cmd/clusters-service/pkg/server/external_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -141,10 +142,22 @@ func (s *server) GetExternalSecret(ctx context.Context, req *capiv1_proto.GetExt
response.Version = externalSecret.Spec.Data[0].RemoteRef.Version
}

//Get SecretStore
var externalSecretStore esv1beta1.SecretStore
if err := clustersClient.Get(ctx, req.ClusterName, client.ObjectKey{Name: externalSecret.Spec.SecretStoreRef.Name, Namespace: req.Namespace}, &externalSecretStore); err == nil {
response.SecretStoreType = getSecretStoreType(&externalSecretStore)
var secretStoreProvider *esv1beta1.SecretStoreProvider
if externalSecret.Spec.SecretStoreRef.Kind == esv1beta1.ClusterSecretStoreKind {
var clusterSecretStore esv1beta1.ClusterSecretStore
if err := clustersClient.Get(ctx, req.ClusterName, client.ObjectKey{Name: externalSecret.Spec.SecretStoreRef.Name}, &clusterSecretStore); err == nil {
secretStoreProvider = clusterSecretStore.Spec.Provider
}

} else {
var secretStore esv1beta1.SecretStore
if err := clustersClient.Get(ctx, req.ClusterName, client.ObjectKey{Name: externalSecret.Spec.SecretStoreRef.Name, Namespace: req.Namespace}, &secretStore); err == nil {
secretStoreProvider = secretStore.Spec.Provider
}
}

if secretStoreProvider != nil {
response.SecretStoreType = getSecretStoreType(secretStoreProvider)
}

return &response, nil
Expand Down Expand Up @@ -190,40 +203,61 @@ func (s *server) ListExternalSecretStores(ctx context.Context, req *capiv1_proto
}

var secretStores esv1beta1.SecretStoreList
var clusterSecretStores esv1beta1.ClusterSecretStoreList

g, gctx := errgroup.WithContext(ctx)
g.Go(func() error {
return clustersClient.List(gctx, req.ClusterName, &secretStores)
})

g.Go(func() error {
return clustersClient.List(gctx, req.ClusterName, &clusterSecretStores)
})

if err := g.Wait(); err != nil {
if strings.Contains(err.Error(), "no matches for kind") {
return &capiv1_proto.ListExternalSecretStoresResponse{}, nil
}
return nil, fmt.Errorf("failed to list secret stores, error %w", err)
}

response := capiv1_proto.ListExternalSecretStoresResponse{}

for _, item := range secretStores.Items {
response.Stores = append(response.Stores, &capiv1_proto.ExternalSecretStore{
Kind: item.GetKind(),
Name: item.GetName(),
Namespace: item.GetNamespace(),
Type: getSecretStoreType(&item),
Type: getSecretStoreType(item.Spec.Provider),
})
}

for _, item := range clusterSecretStores.Items {
response.Stores = append(response.Stores, &capiv1_proto.ExternalSecretStore{
Kind: item.GetKind(),
Name: item.GetName(),
Namespace: item.GetNamespace(),
Type: getSecretStoreType(item.Spec.Provider),
})
}

sort.Slice(response.Stores, func(i, j int) bool {
return response.Stores[i].Name < response.Stores[j].Name
})

response.Total = int32(len(response.Stores))
return &response, nil
}

// getSecretStoreType gets SecretStoreType from SecretStore object
func getSecretStoreType(secretStore *esv1beta1.SecretStore) string {

if secretStore.Spec.Provider.AWS != nil {
func getSecretStoreType(provider *esv1beta1.SecretStoreProvider) string {
if provider.AWS != nil {
return "AWS Secrets Manager"
} else if secretStore.Spec.Provider.AzureKV != nil {
} else if provider.AzureKV != nil {
return "Azure Key Vault"
} else if secretStore.Spec.Provider.GCPSM != nil {
} else if provider.GCPSM != nil {
return "Google Cloud Platform Secret Manager"
} else if secretStore.Spec.Provider.Vault != nil {
} else if provider.Vault != nil {
return "HashiCorp Vault"
} else {
return "Unknown"
Expand Down
Loading