diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4cbc656..69b437b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,33 +1,77 @@ name: Build + on: - # Build only triggers once lint and test workflow successfully completes workflow_run: workflows: [Lint] types: - completed + workflow_dispatch: jobs: - dagger-build: + dagger-build-satellite: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build the binary for the satellite + uses: dagger/dagger-for-github@v5 + with: + version: latest + verb: call + module: github.com/container-registry/harbor-satellite + args: build --source=. --name=satellite + + - name: Release on Github + uses: dagger/dagger-for-github@v5 + with: + version: latest + verb: call + module: github.com/container-registry/harbor-satellite + args: release --source=. --name=satellite --token=$GITHUB_TOKEN + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_USERNAME: ${{ github.repository_owner }} + GITHUB_SHA: ${{ github.sha }} + ### Uncomment the below line if you wish to see the traces of the workflow on dagger cloud + ### register to dagger cloud and get the token + #### https://dagger.cloud/ + # cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }} + + build-ground-control: runs-on: ubuntu-latest - # unless you specify the success on the event, - # this job will also run if the lint workflow was skipped(which is also the case if the condition for the file extension type is false). - if: ${{ github.event.workflow_run.conclusion == 'success' }} + permissions: + contents: write + packages: write steps: - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup go - uses: actions/setup-go@v4 - with: - go-version: '>=1.22' - - - name: Install - run: go get dagger.io/dagger@latest - - - name: Install Dagger CLI - run: cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | sh; cd -; } - - - name: Build with Dagger - run: dagger run go run ci/main.go - + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build the binary for ground control + uses: dagger/dagger-for-github@v5 + with: + version: latest + verb: call + module: github.com/container-registry/harbor-satellite + args: build --source=./ground-control --name=ground-control + + - name: Release on Github + uses: dagger/dagger-for-github@v5 + with: + version: latest + verb: call + module: github.com/container-registry/harbor-satellite + args: release --source=. --name=ground-control --token=$GITHUB_TOKEN + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_USERNAME: ${{ github.repository_owner }} + GITHUB_SHA: ${{ github.sha }} + ### Uncomment the below line if you wish to see the traces of the workflow on dagger cloud + ### register to dagger cloud and get the token + #### https://dagger.cloud/ + # cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }} diff --git a/.gitignore b/.gitignore index 424ddb7..a5581a5 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,6 @@ go.work dist/ # Remove DS_Store -.DS_Store \ No newline at end of file +.DS_Store +zot/cache.db +secrets.txt diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..05b2c29 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,59 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 +project_name: harbor-satellite + +git: + ignore_tags: + - "*-ground-control" +builds: + - main: "./main.go" + binary: "{{ .Env.APP_NAME }}" + env: + - CGO_ENABLED=0 + ldflags: + - -w -s -X github.com/container-registry/harbor-satellite/internal/version.GitCommit={{.FullCommit}} + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + ignore: + - goos: windows + goarch: arm + - goos: windows + goarch: arm64 + mod_timestamp: "{{ .CommitTimestamp }}" + + +release: + name_template: "{{ .Tag }}" + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .Env.APP_NAME }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/ci/.gitattributes b/ci/.gitattributes new file mode 100644 index 0000000..3a45493 --- /dev/null +++ b/ci/.gitattributes @@ -0,0 +1,4 @@ +/dagger.gen.go linguist-generated +/internal/dagger/** linguist-generated +/internal/querybuilder/** linguist-generated +/internal/telemetry/** linguist-generated diff --git a/ci/.gitignore b/ci/.gitignore new file mode 100644 index 0000000..7ebabcc --- /dev/null +++ b/ci/.gitignore @@ -0,0 +1,4 @@ +/dagger.gen.go +/internal/dagger +/internal/querybuilder +/internal/telemetry diff --git a/ci/README.md b/ci/README.md new file mode 100644 index 0000000..b6282c1 --- /dev/null +++ b/ci/README.md @@ -0,0 +1,74 @@ +# Harbor Satellite CI/CD Pipeline + +This repository uses [Dagger](https://docs.dagger.io/) for testing, building, and releasing Harbor Satellite. + +## Setting Up Dagger for Harbor Satellite + +Follow the steps below to set up Dagger: + +### 1. Install Dagger CLI + +Choose your operating system and install the Dagger CLI: + +- **macOS:** + ```sh + brew install dagger/tap/dagger +- **Windows:** + ```sh + Invoke-WebRequest -UseBasicParsing -Uri https://dl.dagger.io/dagger/install.ps1 | Invoke-Expression; Install-Dagger +- **Linux:** + ```sh + curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh + +### 2. Verify Installation +Run the following command to verify the Dagger installation: + - ```sh + dagger --version +If you encounter any errors, refer to the [detailed installation guide](https://docs.dagger.io/install). + +### 3. Generate Go Code +Once the Dagger CLI is installed, navigate to the root folder of harbor-satellite and run: + +- ```sh + dagger develop + +This command will generate Go code in the ./ci folder. + +### 4. Folder Structure +After running dagger develop, your ./ci folder should contain the following structure: +- ```sh + ci/ + ├── dagger.gen.go + ├── ground_control.go + ├── internal + │ ├── dagger + │ ├── querybuilder + │ └── telemetry + ├── satellite.go + ├── README.md + ├── release.sh + └── utils.go +If you encounter any issues during this process, consult the [Dagger Quickstart Guide](https://docs.dagger.io/quickstart/daggerize) for more detailed instructions. + +## Running Dagger Functions +To view available functions, run: +- ```sh + dagger functions +To run a particular function, run: +- ```sh + dagger call --args +- #### Example: Building Satellite Binaries + To build the satellite binaries, use the following command: + - ```sh + dagger call build --source=. --name=satellite export --path=./bin +This would spin up a container and install required dependencies and build various architecture binaries and export them to the host on path ./bin for testing on the host. +- #### Example: Releasing to GitHub + To release the project on GitHub, use the following command + - ```sh + dagger call release --directory=. --token= --name=satellite +The above function would then proceed to release the project on github for the name provided. The above function also takes argument `--release-type` which would tell the release what kind of release it is i.e major, minor or path, The default value is set to be path release +- #### Example: Releasing to GitHub with type of release + To release the project on GitHub, use the following command + - ```sh + dagger call release --directory=. --token= --name=satellite --release-type=minor +The above function would release the minor version for the project mentioned diff --git a/ci/ground_control.go b/ci/ground_control.go new file mode 100644 index 0000000..3883c21 --- /dev/null +++ b/ci/ground_control.go @@ -0,0 +1,36 @@ +package main + +import ( + "context" + "fmt" + + "container-registry.com/harbor-satellite/ci/internal/dagger" +) + +// Would execute the tests for the ground control. Source should be the path to the path to main.go file. +func (m *HarborSatellite) ExecuteTestsForGroundControl(ctx context.Context, source *dagger.Directory) (string, error) { + goContainer := dag.Container(). + From(DEFAULT_GO) + + containerWithDocker, err := m.Attach(ctx, goContainer, "24.0") + if err != nil { + return "", err + } + dockerHost, err := containerWithDocker.EnvVariable(ctx, "DOCKER_HOST") + if err != nil { + return "", err + } + fmt.Printf("Docker Host: %s\n", dockerHost) + + goContainer = containerWithDocker. + WithMountedDirectory("/app", source). + WithWorkdir("/app"). + WithExec([]string{"go", "test", "./..."}) + + output, err := goContainer.Stdout(ctx) + if err != nil { + return output, err + } + fmt.Print(output) + return output, nil +} diff --git a/ci/main.go b/ci/main.go index aba0741..c2004c8 100644 --- a/ci/main.go +++ b/ci/main.go @@ -2,31 +2,71 @@ package main import ( "context" + "fmt" "log/slog" "os" - "dagger.io/dagger" + "container-registry.com/harbor-satellite/ci/internal/dagger" ) -func main() { - ctx := context.Background() +const ( + DEFAULT_GO = "golang:1.22" + PROJ_MOUNT = "/app" + DOCKER_PORT = 2375 + GORELEASER_VERSION = "v2.1.0" + GROUND_CONTROL_PATH = "./ground-control" + SATELLITE_PATH = "." +) + +type HarborSatellite struct{} + +// Build function would start the build process for the name provided. Source should be the path to the main.go file. +func (m *HarborSatellite) Build(ctx context.Context, source *dagger.Directory, name string) *dagger.Directory { + return m.build(source, name) +} + +// Release function would release the build to the github with the tags provided. Directory should be "." for both the satellite and the ground control. +func (m *HarborSatellite) Release(ctx context.Context, directory *dagger.Directory, token, name string, + // +optional + // +default="patch" + release_type string) (string, error) { - // initialize Dagger client - client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) + container := dag.Container(). + From("alpine/git"). + WithEnvVariable("GITHUB_TOKEN", token). + WithMountedDirectory(PROJ_MOUNT, directory). + WithWorkdir(PROJ_MOUNT). + WithExec([]string{"git", "config", "--global", "url.https://github.com/.insteadOf", "git@github.com:"}). + WithExec([]string{"git", "fetch", "--tags"}) + // Prepare the tags for the release + release_tag, err := m.get_release_tag(ctx, container, directory, name, release_type) if err != nil { - panic(err) + slog.Error("Failed to prepare for release: ", err, ".") + slog.Error("Tag Release Output:", release_tag, ".") + os.Exit(1) } - defer client.Close() - - // use a golang:1.19 container - // get version - // execute - golang := client.Container().From("golang:1.21").WithExec([]string{"go", "version"}) + slog.Info("Tag Release Output:", release_tag, ".") + pathToMain, err := m.getPathToReleaser(name) + if err != nil { + slog.Error("Failed to get path to main: ", err, ".") + os.Exit(1) + } + release_output, err := container. + From(fmt.Sprintf("goreleaser/goreleaser:%s", GORELEASER_VERSION)). + WithMountedDirectory(PROJ_MOUNT, directory). + WithWorkdir(PROJ_MOUNT). + WithEnvVariable("GITHUB_TOKEN", token). + WithEnvVariable("PATH_TO_MAIN", pathToMain). + WithEnvVariable("APP_NAME", name). + WithExec([]string{"git", "tag", release_tag}). + WithExec([]string{"goreleaser", "release", "-f", pathToMain, "--clean"}). + Stderr(ctx) - version, err := golang.Stdout(ctx) if err != nil { - panic(err) + slog.Error("Failed to release: ", err, ".") + slog.Error("Release Output:", release_output, ".") + os.Exit(1) } - // print output - slog.Info("Hello from Dagger!", "version", version) + + return release_output, nil } diff --git a/ci/satellite.go b/ci/satellite.go new file mode 100644 index 0000000..36d77de --- /dev/null +++ b/ci/satellite.go @@ -0,0 +1,37 @@ +package main + +import ( + "context" + "fmt" + + "container-registry.com/harbor-satellite/ci/internal/dagger" +) + +// Would execute the tests for the satellite. Source should be the path to the path to main.go file. +func (m *HarborSatellite) ExecuteTestsForSatellite(ctx context.Context, source *dagger.Directory) (string, error) { + goContainer := dag.Container(). + From("golang:1.22-alpine"). + WithExec([]string{"apk", "add", "--no-cache", "docker"}) + + containerWithDocker, err := m.Attach(ctx, goContainer, "24.0") + if err != nil { + return "", fmt.Errorf("failed to attach to container: %w", err) + } + dockerHost, err := containerWithDocker.EnvVariable(ctx, "DOCKER_HOST") + if err != nil { + return "", fmt.Errorf("failed to get DOCKER_HOST: %w", err) + } + fmt.Printf("Docker Host: %s\n", dockerHost) + + goContainer = containerWithDocker. + WithMountedDirectory(PROJ_MOUNT, source). + WithWorkdir(PROJ_MOUNT). + WithExec([]string{"go", "test", "./..."}) + + output, err := goContainer.Stdout(ctx) + if err != nil { + return output, err + } + fmt.Print(output) + return output, nil +} diff --git a/ci/utils.go b/ci/utils.go new file mode 100644 index 0000000..761a5d5 --- /dev/null +++ b/ci/utils.go @@ -0,0 +1,173 @@ +package main + +import ( + "context" + "fmt" + "log/slog" + "strconv" + "strings" + + "container-registry.com/harbor-satellite/ci/internal/dagger" +) + +// Attach would attach a docker as a service to the container provided. +func (m *HarborSatellite) Attach(ctx context.Context, container *dagger.Container, dockerVersion string) (*dagger.Container, error) { + dockerd := m.Service(dockerVersion) + + dockerd, err := dockerd.Start(ctx) + if err != nil { + return nil, err + } + + dockerHost, err := dockerd.Endpoint(ctx, dagger.ServiceEndpointOpts{ + Scheme: "tcp", + }) + if err != nil { + return nil, err + } + + return container. + WithServiceBinding("docker", dockerd). + WithEnvVariable("DOCKER_HOST", dockerHost), nil +} + +// Get a Service container running dockerd +func (m *HarborSatellite) Service( + // +optional + // +default="24.0" + dockerVersion string, +) *dagger.Service { + port := 2375 + return dag.Container(). + From(fmt.Sprintf("docker:%s", dockerVersion)). + WithMountedCache( + "/var/lib/docker", + dag.CacheVolume(dockerVersion+"-docker-lib"), + dagger.ContainerWithMountedCacheOpts{ + Sharing: dagger.Private, + }). + WithExposedPort(port). + WithExec([]string{ + "dockerd", + "--host=tcp://0.0.0.0:2375", + "--host=unix:///var/run/docker.sock", + "--tls=false", + }, dagger.ContainerWithExecOpts{ + InsecureRootCapabilities: true, + }). + AsService() +} + +/// Would build the project with the source provided. The name should be the name of the project. +func (m *HarborSatellite) build(source *dagger.Directory, name string) *dagger.Directory { + fmt.Printf("Building %s\n", name) + gooses := []string{"linux", "darwin"} + goarches := []string{"amd64", "arm64"} + binaryName := name // base name for the binary + + // create empty directory to put build artifacts + outputs := dag.Directory() + + golang := dag.Container(). + From(DEFAULT_GO). + WithDirectory(PROJ_MOUNT, source). + WithWorkdir(PROJ_MOUNT) + for _, goos := range gooses { + for _, goarch := range goarches { + // create the full binary name with OS and architecture + outputBinary := fmt.Sprintf("%s/%s-%s-%s", name, binaryName, goos, goarch) + + // build artifact with specified binary name + build := golang. + WithEnvVariable("GOOS", goos). + WithEnvVariable("GOARCH", goarch). + WithExec([]string{"go", "build", "-o", outputBinary}) + + // add build to outputs + outputs = outputs.WithDirectory(name, build.Directory(name)) + } + } + + // return build directory + return outputs +} + +// PrepareForRelease prepares the repository for a release by creating a new tag. The default release type is "patch". +func (m *HarborSatellite) get_release_tag(ctx context.Context, git_container *dagger.Container, source *dagger.Directory, name string, + // +optional + // +default="patch" + release_type string) (string, error) { + /// This would get the last tag that was created. Empty string if no tag was created. + getTagsOutput, err := git_container. + WithExec([]string{ + "/bin/sh", "-c", + fmt.Sprintf(`git tag --list "v*%s" | sort -V | tail -n 1`, name), + }). + Stdout(ctx) + + if err != nil { + slog.Error("Failed to get tags: ", err, ".") + slog.Error("Get Tags Output:", getTagsOutput, ".") + return getTagsOutput, err + } + + slog.Info("Get Tags Output:", getTagsOutput, ".") + latest_tag := strings.TrimSpace(getTagsOutput) + new_tag, err := generateNewTag(latest_tag, name, release_type) + if err != nil { + slog.Error("Failed to generate new tag: ", err.Error(), ".") + return "", err + } + + return new_tag, nil +} + + +func generateNewTag(latestTag, suffix, release_type string) (string, error) { + if latestTag == "" { + // If the latest tag is empty, this is the first release + return fmt.Sprintf("v0.0.1-%s", suffix), nil + } + versionWithoutSuffix := strings.TrimSuffix(latestTag, fmt.Sprintf("-%s", suffix)) + versionWithoutSuffix = strings.TrimPrefix(versionWithoutSuffix, "v") + fmt.Println("Version without suffix: ", versionWithoutSuffix) + parts := strings.Split(versionWithoutSuffix, ".") + major, err := strconv.Atoi(parts[0]) + if err != nil { + slog.Error("Failed to convert major version to integer: ", err.Error(), ".") + return "", err + } + minor, err := strconv.Atoi(parts[1]) + if err != nil { + slog.Error("Failed to convert minor version to integer: ", err.Error(), ".") + return "", err + } + patch, err := strconv.Atoi(parts[2]) + if err != nil { + slog.Error("Failed to convert patch version to integer: ", err.Error(), ".") + return "", err + } + // Increment the version according to the release type + switch release_type { + case "major": + major++ + case "minor": + minor++ + case "patch": + patch++ + } + newVersion := fmt.Sprintf("v%d.%d.%d-%s", major, minor, patch, suffix) + + return newVersion, nil +} + +func (m *HarborSatellite) getPathToReleaser(name string) (string, error) { + switch name { + case "satellite": + return ".goreleaser.yaml", nil + case "ground-control": + return "ground-control/.goreleaser.yaml", nil + default: + return "", fmt.Errorf("unknown name: %s", name) + } +} diff --git a/dagger.json b/dagger.json new file mode 100644 index 0000000..38c2cd1 --- /dev/null +++ b/dagger.json @@ -0,0 +1,6 @@ +{ + "name": "harbor-satellite", + "sdk": "go", + "source": "ci", + "engineVersion": "v0.12.4" +} diff --git a/go.mod b/go.mod index 91e4cf2..c5d15e3 100644 --- a/go.mod +++ b/go.mod @@ -17,17 +17,18 @@ require ( require ( github.com/rs/zerolog v1.33.0 github.com/spf13/viper v1.19.0 - go.uber.org/zap v1.27.0 - gopkg.in/natefinch/lumberjack.v2 v2.2.1 + github.com/stretchr/testify v1.9.0 ) +require golang.org/x/oauth2 v0.20.0 // indirect + require ( cloud.google.com/go v0.112.1 // indirect cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/iam v1.1.6 // indirect cloud.google.com/go/storage v1.39.1 // indirect dario.cat/mergo v1.0.0 // indirect - github.com/99designs/gqlgen v0.17.47 // indirect + github.com/99designs/gqlgen v0.17.49 github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect @@ -48,7 +49,7 @@ require ( github.com/GoogleCloudPlatform/docker-credential-gcr v2.0.5+incompatible // indirect github.com/Intevation/gval v1.3.0 // indirect github.com/Intevation/jsonpath v0.2.1 // indirect - github.com/Khan/genqlient v0.6.0 // indirect + github.com/Khan/genqlient v0.7.0 github.com/KyleBanks/depth v1.2.1 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect @@ -219,6 +220,7 @@ require ( github.com/gorilla/websocket v1.5.0 // indirect github.com/gosuri/uitable v0.0.4 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.4 // indirect @@ -371,7 +373,7 @@ require ( github.com/ulikunitz/xz v0.5.12 // indirect github.com/vbatts/tar-split v0.11.5 // indirect github.com/vbauerster/mpb/v8 v8.7.3 // indirect - github.com/vektah/gqlparser/v2 v2.5.12 // indirect + github.com/vektah/gqlparser/v2 v2.5.16 github.com/xanzy/go-gitlab v0.102.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect @@ -388,30 +390,36 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect - go.opentelemetry.io/otel v1.27.0 // indirect + go.opentelemetry.io/otel v1.27.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 + go.opentelemetry.io/otel/log v0.3.0 go.opentelemetry.io/otel/metric v1.27.0 // indirect - go.opentelemetry.io/otel/sdk v1.27.0 // indirect - go.opentelemetry.io/otel/trace v1.27.0 // indirect + go.opentelemetry.io/otel/sdk v1.27.0 + go.opentelemetry.io/otel/sdk/log v0.3.0 + go.opentelemetry.io/otel/trace v1.27.0 + go.opentelemetry.io/proto/otlp v1.3.1 go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.24.0 // indirect - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect - golang.org/x/mod v0.17.0 // indirect + golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 + golang.org/x/mod v0.18.0 // indirect golang.org/x/net v0.26.0 // indirect - golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/term v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + golang.org/x/tools v0.22.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/api v0.172.0 // indirect google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect - google.golang.org/grpc v1.64.0 // indirect + google.golang.org/grpc v1.64.0 google.golang.org/protobuf v1.34.2 // indirect gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect diff --git a/go.sum b/go.sum index b033410..0b366eb 100644 --- a/go.sum +++ b/go.sum @@ -195,8 +195,8 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= -github.com/99designs/gqlgen v0.17.47 h1:M9DTK8X3+3ATNBfZlHBwMwNngn4hhZWDxNmTiuQU5tQ= -github.com/99designs/gqlgen v0.17.47/go.mod h1:ejVkldSdtmuudqmtfaiqjwlGXWAhIv0DKXGXFY25F04= +github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ= +github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 h1:59MxjQVfjXsBpLy+dbd2/ELV5ofnUkUZBvWSC85sheA= @@ -257,8 +257,8 @@ github.com/Intevation/gval v1.3.0 h1:+Ze5sft5MmGbZrHj06NVUbcxCb67l9RaPTLMNr37mjw github.com/Intevation/gval v1.3.0/go.mod h1:xmGyGpP5be12EL0P12h+dqiYG8qn2j3PJxIgkoOHO5o= github.com/Intevation/jsonpath v0.2.1 h1:rINNQJ0Pts5XTFEG+zamtdL7l9uuE1z0FBA+r55Sw+A= github.com/Intevation/jsonpath v0.2.1/go.mod h1:WnZ8weMmwAx/fAO3SutjYFU+v7DFreNYnibV7CiaYIw= -github.com/Khan/genqlient v0.6.0 h1:Bwb1170ekuNIVIwTJEqvO8y7RxBxXu639VJOkKSrwAk= -github.com/Khan/genqlient v0.6.0/go.mod h1:rvChwWVTqXhiapdhLDV4bp9tz/Xvtewwkon4DpWWCRM= +github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w= +github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= @@ -918,7 +918,6 @@ github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY= github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= @@ -1458,8 +1457,8 @@ github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinC github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk= github.com/vbauerster/mpb/v8 v8.7.3 h1:n/mKPBav4FFWp5fH4U0lPpXfiOmCEgl5Yx/NM3tKJA0= github.com/vbauerster/mpb/v8 v8.7.3/go.mod h1:9nFlNpDGVoTmQ4QvNjSLtwLmAFjwmq0XaAF26toHGNM= -github.com/vektah/gqlparser/v2 v2.5.12 h1:COMhVVnql6RoaF7+aTBWiTADdpLGyZWU3K/NwW0ph98= -github.com/vektah/gqlparser/v2 v2.5.12/go.mod h1:WQQjFc+I1YIzoPvZBhUQX7waZgg3pMLi0r8KymvAE2w= +github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8= +github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww= github.com/veraison/go-cose v1.2.1 h1:Gj4x20D0YP79J2+cK3anjGEMwIkg2xX+TKVVGUXwNAc= github.com/veraison/go-cose v1.2.1/go.mod h1:t6V8WJzHm1PD5HNsuDjW3KLv577uWb6UTzbZGvdQHD8= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= @@ -1533,21 +1532,29 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 h1:9l89oX4 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0/go.mod h1:XLZfZboOJWHNKUv7eH0inh0E9VV6eWDFB/9yJyTLPp0= go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88/go.mod h1:JGG8ebaMO5nXOPnvKEl+DiA4MGwFjCbjsxT1WHIEBPY= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 h1:ccBrA8nCY5mM0y5uO7FT0ze4S0TuFcWdDB2FxGMTjkI= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0/go.mod h1:/9pb6634zi2Lk8LYg9Q0X8Ar6jka4dkFOylBLbVQPCE= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0/go.mod h1:nUeKExfxAQVbiVFn32YXpXZZHZ61Cc3s3Rn1pDBGAb0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0/go.mod h1:MOiCmryaYtc+V0Ei+Tx9o5S1ZjA7kzLucuVuyzBZloQ= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY= +go.opentelemetry.io/otel/log v0.3.0 h1:kJRFkpUFYtny37NQzL386WbznUByZx186DpEMKhEGZs= +go.opentelemetry.io/otel/log v0.3.0/go.mod h1:ziCwqZr9soYDwGNbIL+6kAvQC+ANvjgG367HVcyR/ys= go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI= go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A= +go.opentelemetry.io/otel/sdk/log v0.3.0 h1:GEjJ8iftz2l+XO1GF2856r7yYVh74URiF9JMcAacr5U= +go.opentelemetry.io/otel/sdk/log v0.3.0/go.mod h1:BwCxtmux6ACLuys1wlbc0+vGBd+xytjmjajwqqIul2g= go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94= -go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93VanwNIi5bIKnDrJdEY= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= go.step.sm/crypto v0.44.2 h1:t3p3uQ7raP2jp2ha9P6xkQF85TJZh+87xmjSLaib+jk= @@ -1618,8 +1625,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1915,8 +1922,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2163,8 +2170,6 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= -gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/resty.v1 v1.12.0 h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= diff --git a/ground-control/.goreleaser.yaml b/ground-control/.goreleaser.yaml new file mode 100644 index 0000000..74ab69a --- /dev/null +++ b/ground-control/.goreleaser.yaml @@ -0,0 +1,62 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 +project_name: ground-control + +git: + ignore_tags: + - "*-satellite" + +builds: + - main: "./main.go" + binary: "{{ .Env.APP_NAME }}" + dir: "./ground-control" + env: + - CGO_ENABLED=0 + ldflags: + - -w -s -X github.com/container-registry/harbor-satellite/internal/version.GitCommit={{.FullCommit}} + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + ignore: + - goos: windows + goarch: arm + - goos: windows + goarch: arm64 + mod_timestamp: "{{ .CommitTimestamp }}" + tags: + - "{{ .ProjectName }}-{{ .ShortCommit}}" + +release: + name_template: "{{ .Tag }}" + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .Env.APP_NAME }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..b89de17 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,34 @@ +package version + +import "runtime/debug" + +var ( + Version = "0.1.0" + GitCommit = "" + BuildTime = "" + ReleaseChannel = "dev" + GoVersion = "" + OS = func() string { + if info, ok := debug.ReadBuildInfo(); ok { + for _, setting := range info.Settings { + if setting.Key == "GOOS" { + return setting.Value + } + } + } + + return "" + } + Arch = func() string { + if info, ok := debug.ReadBuildInfo(); ok { + for _, setting := range info.Settings { + if setting.Key == "GOARCH" { + return setting.Value + } + } + } + + return "" + } + System = OS() + "/" + Arch() +)