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

Add nightly build support to oss publish scripts #153

Merged
merged 17 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
10 changes: 10 additions & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ var DockerFlags = []cli.Flag{
Usage: "The Ubuntu image to use as the base image when building the Ubuntu version of the Grafana docker image",
Value: "ubuntu:latest",
},
&cli.StringFlag{
Name: "org",
Usage: "Overrides the organization of the images",
Value: "grafana",
},
}

var DockerPublishFlags = []cli.Flag{
Expand All @@ -187,6 +192,11 @@ var DockerPublishFlags = []cli.Flag{
Usage: "Prefix the image name with the registry provided",
Value: "docker.io",
},
&cli.StringFlag{
Name: "org",
Usage: "Overrides the organization of the images",
Value: "grafana",
},
&cli.BoolFlag{
Name: "latest",
Usage: "Tags the published images as latest",
Expand Down
4 changes: 4 additions & 0 deletions containers/opts_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ type DockerOpts struct {
// Password is supplied to login to the docker registry when publishing images.
Password string

// Org overrides the organization when when publishing images.
Org string

// Latest is supplied to also tag as latest when publishing images.
Latest bool
}
Expand All @@ -34,6 +37,7 @@ func DockerOptsFromFlags(c cliutil.CLIContext) *DockerOpts {
UbuntuBase: c.String("ubuntu-base"),
Username: c.String("username"),
Password: c.String("password"),
Org: c.String("org"),
Latest: c.Bool("latest"),
}
}
5 changes: 2 additions & 3 deletions pipelines/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ func ImageTag(registry, org, repo, version string) string {

// GrafanaImageTag returns the name of the grafana docker image based on the tar package name.
// To maintain backwards compatibility, we must keep this the same as it was before.
func GrafanaImageTags(base BaseImage, registry string, opts TarFileOpts) []string {
func GrafanaImageTags(base BaseImage, org string, registry string, opts TarFileOpts) []string {
var (
org = "grafana"
repos = []string{"grafana-image-tags", "grafana-oss-image-tags"}
version = opts.Version

Expand Down Expand Up @@ -88,7 +87,7 @@ func Docker(ctx context.Context, d *dagger.Client, args PipelineArgs) error {
for _, base := range bases {
var (
platform = executil.Platform(tarOpts.Distro)
tags = GrafanaImageTags(base, opts.Registry, tarOpts)
tags = GrafanaImageTags(base, opts.Org, opts.Registry, tarOpts)
baseImage = opts.AlpineBase
socket = d.Host().UnixSocket("/var/run/docker.sock")
)
Expand Down
2 changes: 1 addition & 1 deletion pipelines/docker_publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func PublishDocker(ctx context.Context, d *dagger.Client, args PipelineArgs) err
base = BaseImageUbuntu
}

tags := GrafanaImageTags(base, opts.Registry, tarOpts)
tags := GrafanaImageTags(base, opts.Org, opts.Registry, tarOpts)
for _, tag := range tags {
// For each tag we publish an image and add the tag to the list of tags for a specific manifest
// Since each package has a maximum of 2 tags, this for loop will only run twice on a worst case scenario
Expand Down
2 changes: 1 addition & 1 deletion pipelines/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestImageName(t *testing.T) {
for n, test := range cases {
t.Run(fmt.Sprintf("[%d / %d] %s", n+1, len(cases), test.Description), func(t *testing.T) {
expect := sort.StringSlice(test.Tags)
res := sort.StringSlice(pipelines.GrafanaImageTags(test.BaseImage, "docker.io", test.TarOpts))
res := sort.StringSlice(pipelines.GrafanaImageTags(test.BaseImage, "grafana", "docker.io", test.TarOpts))

for i := range expect {
e := expect[i]
Expand Down
2 changes: 1 addition & 1 deletion scripts/drone_publish_tag_grafana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dagger run --silent go run ./cmd \
--build-id=${DRONE_BUILD_NUMBER} \
--grafana-dir=${GRAFANA_DIR} \
--github-token=${GITHUB_TOKEN} \
--version=${DRONE_TAG} \
--version=${VERSION} \
guicaulada marked this conversation as resolved.
Show resolved Hide resolved
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > assets.txt

Expand Down
Loading