Skip to content
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

Publish each version only once on gcom publish #192

Merged
merged 2 commits into from
Oct 3, 2023
Merged

Conversation

guicaulada
Copy link
Contributor

No description provided.

@guicaulada guicaulada requested a review from a team October 3, 2023 16:56
@guicaulada guicaulada enabled auto-merge (squash) October 3, 2023 16:57

_, err = d.Container().From("alpine/curl").
WithSecretVariable("GCOM_API_KEY", apiKeySecret).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonVersionPayload), versionApiUrl)}).
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're not redirecting stdout or anything this can just be []string{"curl", "-H', "Content-Type: application/json", etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we need the $GCOM_API_KEY would Dagger use the environment variable without calling /bin/sh ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yea pretty sure it will. try it!


// PublishGCOMPackage publishes a package to grafana.com.
func PublishGCOMPackage(ctx context.Context, d *dagger.Client, packagePayload *GCOMPackagePayload, opts *GCOMOpts, version string) error {
packagesApiUrl := fmt.Sprintf("%s/api/grafana/versions/%s/packages", opts.URL, version)
Copy link
Collaborator

Choose a reason for hiding this comment

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

use paths.Join

Copy link
Contributor Author

@guicaulada guicaulada Oct 3, 2023

Choose a reason for hiding this comment

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

path.Join will get rid of the second / on "https://"

Copy link
Collaborator

Choose a reason for hiding this comment

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

use url.URL then if you're making a URL

Copy link
Collaborator

@kminehart kminehart Oct 3, 2023

Choose a reason for hiding this comment

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

and path.Join to build the URL path

@guicaulada guicaulada requested a review from kminehart October 3, 2023 18:56
@guicaulada guicaulada merged commit b8af7b5 into main Oct 3, 2023
3 checks passed
@guicaulada guicaulada deleted the fix-gcom-publish branch October 3, 2023 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants