Skip to content

Commit

Permalink
tools: generate docker tags args from sourcegraph/sourcegraph
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Nov 29, 2020
1 parent 3259228 commit 3cab7ed
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 31 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/pulumi/pulumi v1.12.0
github.com/sethgrid/pester v1.1.0
github.com/slimsag/update-docker-tags v0.7.0
github.com/sourcegraph/sourcegraph/enterprise/dev/ci/images v0.0.0-20201129044102-91280e756de5
)

replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v12.4.3+incompatible
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
github.com/slimsag/update-docker-tags v0.7.0 h1:43SSOii74DpuQ3HK+AxHeE54tTFiUEz1xOsiI8hwymQ=
github.com/slimsag/update-docker-tags v0.7.0/go.mod h1:T42NkUDP2MrfiSj3NT4JI27g/ksCngfCiY1goUQdIh0=
github.com/sourcegraph/sourcegraph v0.0.0-20201129044102-91280e756de5 h1:uVixZOxbX8zdG4y1pM42lr75YBjEXBMmtewQ44bWO2M=
github.com/sourcegraph/sourcegraph/enterprise/dev/ci/images v0.0.0-20201129044102-91280e756de5 h1:K/ojwjaivMZ45jt3dslKka1ciZvMrGbRuofN/PESL5o=
github.com/sourcegraph/sourcegraph/enterprise/dev/ci/images v0.0.0-20201129044102-91280e756de5/go.mod h1:RrAuT1kEkrErj2fmr4f3pPDoBF0ruFBhOSC1yORlv24=
github.com/spf13/cast v1.2.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg=
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
Expand Down
5 changes: 5 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
"semanticCommits": false,
"labels": ["automerge"]
},
{
"groupName": "Sourcegraph Docker images list",
"packagePatterns": ["github.com/sourcegraph/sourcegraph/enterprise/dev/ci/images"],
"labels": ["automerge"]
},
{
"groupName": "Pulumi NPM packages",
"managers": ["npm"],
Expand Down
8 changes: 0 additions & 8 deletions tools/tools.go

This file was deleted.

29 changes: 6 additions & 23 deletions tools/update-docker-tags.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
#!/bin/bash

set -e

root_dir="$(dirname "${BASH_SOURCE[0]}")/.."
cd "$root_dir"

CONSTRAINT=$1

# Using `go run` ensures we are using the version of `update-docker-tags` pinned in `go.mod`
go run github.com/slimsag/update-docker-tags \
-enforce="sourcegraph/cadvisor=$CONSTRAINT" \
-enforce="sourcegraph/frontend=$CONSTRAINT" \
-enforce="sourcegraph/jaeger-agent=$CONSTRAINT" \
-enforce="sourcegraph/github-proxy=$CONSTRAINT" \
-enforce="sourcegraph/gitserver=$CONSTRAINT" \
-enforce="sourcegraph/grafana=$CONSTRAINT" \
-enforce="sourcegraph/indexed-searcher=$CONSTRAINT" \
-enforce="sourcegraph/search-indexer=$CONSTRAINT" \
-enforce="sourcegraph/jaeger-all-in-one=$CONSTRAINT" \
-enforce="sourcegraph/postgres-11.4=$CONSTRAINT" \
-enforce="sourcegraph/precise-code-intel-worker=$CONSTRAINT" \
-enforce="sourcegraph/codeintel-db=$CONSTRAINT" \
-enforce="sourcegraph/syntax-highlighter=$CONSTRAINT" \
-enforce="sourcegraph/prometheus=$CONSTRAINT" \
-enforce="sourcegraph/query-runner=$CONSTRAINT" \
-enforce="sourcegraph/redis-cache=$CONSTRAINT" \
-enforce="sourcegraph/redis-store=$CONSTRAINT" \
-enforce="sourcegraph/repo-updater=$CONSTRAINT" \
-enforce="sourcegraph/searcher=$CONSTRAINT" \
-enforce="sourcegraph/symbols=$CONSTRAINT" \
-enforce="sourcegraph/minio=$CONSTRAINT" \
base/
go run ./update-tags "$CONSTRAINT" base/
40 changes: 40 additions & 0 deletions tools/update-tags/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"fmt"
"log"
"os"
"os/exec"

"github.com/sourcegraph/sourcegraph/enterprise/dev/ci/images"

// pins update-docker-tags CLI
_ "github.com/slimsag/update-docker-tags"
)

func main() {
if len(os.Args) == 2 {
log.Fatal("constraint, directory arguments must be provided")
}
var (
constraint = os.Args[0]
dir = os.Args[1]
)
args := []string{
"run",
"github.com/slimsag/update-docker-tags",
}
for _, image := range images.SourcegraphDockerImages {
enforce := fmt.Sprintf(`-enforce="sourcegraph/%s=%s"`, image, constraint)
log.Println(enforce)
args = append(args, enforce)
}
args = append(args, dir)
cmd := exec.Command("go", args...)
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
log.Fatal((err))
}
}

0 comments on commit 3cab7ed

Please sign in to comment.