Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anekkanti committed Nov 21, 2023
1 parent 9550bd2 commit 2fd1c04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
21 changes: 5 additions & 16 deletions workflows/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,26 +252,15 @@ func (w *workflows) ReconcileNamespaces(ctx workflow.Context, in *ReconcileNames
if err := validator.ValidateStruct(in); err != nil {
return nil, fmt.Errorf("invalid input: %s", err)
}
var (
getNamespacesReq = &cloudservice.GetNamespacesRequest{}
namespaces = make([]*namespace.Namespace, 0)
out = &ReconcileNamespacesOutput{}
)
for {
resp, err := w.GetNamespaces(ctx, getNamespacesReq)
if err != nil {
return nil, err
}
namespaces = append(namespaces, resp.Namespaces...)
if resp.NextPageToken == "" {
break
}
getNamespacesReq.PageToken = resp.NextPageToken
namespaces, err := w.GetAllNamespaces(ctx)
if err != nil {
return nil, err
}
out := &ReconcileNamespacesOutput{}
for i := range in.Specs {
var namespace *namespace.Namespace
for _, ns := range namespaces {
if ns.Namespace == in.Specs[i].Name {
if ns.Spec.Name == in.Specs[i].Name {
namespace = ns
namespaces = append(namespaces[:i], namespaces[i+1:]...) // remove the namespace from the list
break
Expand Down
19 changes: 4 additions & 15 deletions workflows/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,11 @@ func (w *workflows) ReconcileUsers(ctx workflow.Context, in *ReconcileUsersInput
if err := validator.ValidateStruct(in); err != nil {
return nil, fmt.Errorf("invalid input: %s", err)
}
var (
getUsersReq = &cloudservice.GetUsersRequest{}
users = make([]*identity.User, 0)
out = &ReconcileUsersOutput{}
)
for {
resp, err := w.GetUsers(ctx, getUsersReq)
if err != nil {
return nil, err
}
users = append(users, resp.Users...)
if resp.NextPageToken == "" {
break
}
getUsersReq.PageToken = resp.NextPageToken
users, err := w.GetAllUsers(ctx)
if err != nil {
return nil, err
}
out := &ReconcileUsersOutput{}
for i := range in.Specs {
var user *identity.User
for _, u := range users {
Expand Down

0 comments on commit 2fd1c04

Please sign in to comment.