Skip to content

Update /v1/clusters to accept a list of workloads #1104

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 12 commits into from
Jul 26, 2022

Conversation

sarataha
Copy link
Member

closes: #1079

PR to update /v1/clusters endpoint to:

  • receive a list of kustomizations
  • generate a yaml file for each one
  • add the files to branch commit

@sarataha sarataha added the enhancement New feature or request label Jul 17, 2022
@sarataha sarataha requested a review from a team July 18, 2022 08:49
err = multierror.Append(err, invalidNamespaceErr)
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add another test for this fn a couple of invalid messages?

@@ -609,6 +609,28 @@ func validateCreateClusterPR(msg *capiv1_proto.CreatePullRequestRequest) error {
}
}

for _, k := range msg.Kustomizations {
if k.Name == "" {
err = multierror.Append(err, fmt.Errorf("kustomization name must be specified"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be just errors.New("kustomization name must be specified") as you're not formatting anything.


if k.SourceRef != nil {
if k.SourceRef.Name == "" {
err = multierror.Append(err, fmt.Errorf("sourceRef name must be specified"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue with Errorf here, but perhaps we could include the name of the kustomization (k.Name) in the error message to help with diagnosing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree 👌

return files, nil
}

func getClusterKustomizationsPath(cluster types.NamespacedName, ns, name string) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it should be two types.NamespacedName values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yesss, thank you 🙂

Copy link
Collaborator

@foot foot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -609,6 +614,28 @@ func validateCreateClusterPR(msg *capiv1_proto.CreatePullRequestRequest) error {
}
}

for _, k := range msg.Kustomizations {
if k.Metadata.Name == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might panic if k.Metadata is nil? Could we add one more test where we omit Metadata in the request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 🙂

@sarataha sarataha merged commit 6cd73b5 into main Jul 26, 2022
@sarataha sarataha deleted the create-cluster-workloads branch July 26, 2022 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request team/pesto
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] Update create-cluster-pr endpoint to accept list of workloads
3 participants