From 5cbba4a4a663ec57ec436ab087cfb239b6cf8b2e Mon Sep 17 00:00:00 2001 From: Florian Eich Date: Thu, 7 Nov 2024 07:28:41 +0100 Subject: [PATCH] feat: update to latest runrs API and fix CI --- .github/workflows/test.yml | 24 +++++++++--------------- internal/clients/runrs.gen.go | 4 ++-- runrs-api.json | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d393a0..02e848b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,15 +23,15 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache: true - run: go mod download - run: go build -v . - name: Run linters - uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 + uses: golangci/golangci-lint-action@v6 with: version: latest @@ -45,20 +45,14 @@ jobs: ports: - 3000:3000 steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache: true - # Temporarily download Terraform 1.8 prerelease for function documentation support. - # When Terraform 1.8.0 final is released, this can be removed. - - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 - with: - terraform_version: '1.8.0-alpha20240216' - terraform_wrapper: false - name: pull latest OpenAPI schema for runrs and generate code run: | - curl -O http://0.0.0.0:3000/api-docs/runrs-api.json && go generate ./... + curl -O http://localhost:3000/api-docs/runrs-api.json && go generate ./... - name: git diff run: | git diff --compact-summary --exit-code || \ @@ -93,12 +87,12 @@ jobs: - '1.8.*' - '1.*.*' steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache: true - - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 + - uses: hashicorp/setup-terraform@v3 with: terraform_version: ${{ matrix.terraform }} terraform_wrapper: false diff --git a/internal/clients/runrs.gen.go b/internal/clients/runrs.gen.go index 34406b4..7733daa 100644 --- a/internal/clients/runrs.gen.go +++ b/internal/clients/runrs.gen.go @@ -68,8 +68,8 @@ type GitLabRunner struct { // Name Runner name (default: Docker-style random name) Name *string `json:"name,omitempty"` - // Token Runner token, obtained from the GitLab instance. Format: `glrt-` followed by 20 characters - // from the set `[0-9a-f_]`. + // Token Runner token, obtained from the GitLab instance. See [documentation of the `glrcfg` + // crate](https://docs.rs/glrcfg/latest/glrcfg/runner/struct.RunnerToken.html) for details. Token string `json:"token"` TokenObtainedAt *time.Time `json:"token_obtained_at,omitempty"` diff --git a/runrs-api.json b/runrs-api.json index ee7ecce..6d1ef50 100644 --- a/runrs-api.json +++ b/runrs-api.json @@ -1 +1 @@ -{"openapi":"3.0.3","info":{"title":"runrs","description":"A microservice to manage GitLab Runners in Docker via REST","contact":{"name":"bmc"},"license":{"name":"Apache-2.0"},"version":"0.6.0"},"servers":[{"url":"http://0.0.0.0:3000/","description":"Local development server"}],"paths":{"/gitlab-runners":{"post":{"tags":["gitlab_runners"],"operationId":"create","requestBody":{"description":"GitLabRunner to create","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}},"required":true},"responses":{"201":{"description":"Created new GitLab Runner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"400":{"description":"GitLab Runner already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/gitlab-runners/list":{"get":{"tags":["gitlab_runners"],"operationId":"list","responses":{"200":{"description":"Read all GitLabRunners","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"404":{"description":"GitLabRunner not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/gitlab-runners/{uuid}":{"get":{"tags":["gitlab_runners"],"operationId":"read","parameters":[{"name":"uuid","in":"path","description":"GitLabRunner UUID","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Read all GitLabRunners","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"404":{"description":"GitLabRunner not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["gitlab_runners"],"operationId":"update","parameters":[{"name":"uuid","in":"path","description":"GitLab Runner UUID","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"description":"GitLabRunner to update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}},"required":true},"responses":{"200":{"description":"Updated GitLabRunner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"204":{"description":"GitLabRunner already up-to-date"},"404":{"description":"GitLabRunner not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["gitlab_runners"],"operationId":"delete","parameters":[{"name":"uuid","in":"path","description":"GitLabRunner UUID","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Deleted GitLabRunner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"404":{"description":"GitLabRunner not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"Error":{"type":"object","required":["err_type","msg"],"properties":{"err_type":{"$ref":"#/components/schemas/ErrorType"},"msg":{"type":"string"}}},"ErrorType":{"type":"string","enum":["ConnectionFailed","InvalidArgument","AlreadyExists","Forbidden","Unchanged","NotFound","BadRequest","InternalError","Unimplemented","Other"]},"GitLabRunner":{"type":"object","description":"Public API for configuring a single CI/CD job executor, not the GitLab Runner service.\n\nGitLab publish a service binary they refer to as \"GitLab Runner\". You can install it locally or\non you server [as per its documentation](https://docs.gitlab.com/runner/install/). This binary\nis, however, *not* the CI/CD job executor; rather, it _manages_ the executors. As such, when you\n\"register a runner\" (as per [their documentation](https://docs.gitlab.com/runner/register/)),\nyou use the `gitlab-runner` binary to do so.\n\nThe `GitLabRunner` struct replicates the API of the `gitlab-runner` binary, albeit exposing a\nsmaller configuration surface. In other words: if you run `gitlab-runner register --help`, you\nget a list of options. We support a subset of those options, and those which are supported are\nnamed the same here as they are in `gitlab-runner`, except in `snake_case` instead of\n`kebab-case`. For example, `--docker-image` becomes `docker_image`.","required":["id","url","token","docker_image"],"properties":{"docker_image":{"type":"string","description":"Docker image to be used","example":"alpine:latest"},"id":{"type":"integer","format":"int32","description":"ID of the runner within the GitLab instance; unique for that GitLab instance","minimum":0},"name":{"type":"string","description":"Runner name (default: Docker-style random name)","example":"usain-bolt"},"token":{"type":"string","description":"Runner token, obtained from the GitLab instance. Format: `glrt-` followed by 20 characters\nfrom the set `[0-9a-f_]`.","example":"glrt-0123456789_abcdefXYZ"},"token_obtained_at":{"type":"string","format":"date-time","example":"2023-08-23T23:23:23Z"},"url":{"type":"string","format":"uri","description":"GitLab instance URL","example":"https://gitlab.your-company.com"},"uuid":{"type":"string","format":"uuid","example":"be924fdd-fb28-468c-8c70-1f0ed3af4485"}}}},"securitySchemes":{"api_token":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"security":[{"api_token":[]}],"tags":[{"name":"runrs","description":"GitLab Runners Docker API"}]} \ No newline at end of file +{"openapi":"3.0.3","info":{"title":"runrs","description":"A microservice to manage GitLab Runners in Docker via REST","contact":{"name":"bmc"},"license":{"name":"Apache-2.0"},"version":"0.6.2"},"servers":[{"url":"http://0.0.0.0:3000/","description":"Local development server"}],"paths":{"/gitlab-runners":{"post":{"tags":["gitlab_runners"],"operationId":"create","requestBody":{"description":"GitLabRunner to create","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}},"required":true},"responses":{"201":{"description":"Created new GitLab Runner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"400":{"description":"GitLab Runner already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/gitlab-runners/list":{"get":{"tags":["gitlab_runners"],"operationId":"list","responses":{"200":{"description":"Read all GitLabRunners","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"404":{"description":"GitLabRunner not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/gitlab-runners/{uuid}":{"get":{"tags":["gitlab_runners"],"operationId":"read","parameters":[{"name":"uuid","in":"path","description":"GitLabRunner UUID","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Read all GitLabRunners","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"404":{"description":"GitLabRunner not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["gitlab_runners"],"operationId":"update","parameters":[{"name":"uuid","in":"path","description":"GitLab Runner UUID","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"description":"GitLabRunner to update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}},"required":true},"responses":{"200":{"description":"Updated GitLabRunner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"204":{"description":"GitLabRunner already up-to-date"},"404":{"description":"GitLabRunner not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["gitlab_runners"],"operationId":"delete","parameters":[{"name":"uuid","in":"path","description":"GitLabRunner UUID","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Deleted GitLabRunner","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GitLabRunner"}}}},"404":{"description":"GitLabRunner not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"Error":{"type":"object","required":["err_type","msg"],"properties":{"err_type":{"$ref":"#/components/schemas/ErrorType"},"msg":{"type":"string"}}},"ErrorType":{"type":"string","enum":["ConnectionFailed","InvalidArgument","AlreadyExists","Forbidden","Unchanged","NotFound","BadRequest","InternalError","Unimplemented","Other"]},"GitLabRunner":{"type":"object","description":"Public API for configuring a single CI/CD job executor, not the GitLab Runner service.\n\nGitLab publish a service binary they refer to as \"GitLab Runner\". You can install it locally or\non you server [as per its documentation](https://docs.gitlab.com/runner/install/). This binary\nis, however, *not* the CI/CD job executor; rather, it _manages_ the executors. As such, when you\n\"register a runner\" (as per [their documentation](https://docs.gitlab.com/runner/register/)),\nyou use the `gitlab-runner` binary to do so.\n\nThe `GitLabRunner` struct replicates the API of the `gitlab-runner` binary, albeit exposing a\nsmaller configuration surface. In other words: if you run `gitlab-runner register --help`, you\nget a list of options. We support a subset of those options, and those which are supported are\nnamed the same here as they are in `gitlab-runner`, except in `snake_case` instead of\n`kebab-case`. For example, `--docker-image` becomes `docker_image`.","required":["id","url","token","docker_image"],"properties":{"docker_image":{"type":"string","description":"Docker image to be used","example":"alpine:latest"},"id":{"type":"integer","format":"int32","description":"ID of the runner within the GitLab instance; unique for that GitLab instance","minimum":0},"name":{"type":"string","description":"Runner name (default: Docker-style random name)","example":"usain-bolt"},"token":{"type":"string","description":"Runner token, obtained from the GitLab instance. See [documentation of the `glrcfg`\ncrate](https://docs.rs/glrcfg/latest/glrcfg/runner/struct.RunnerToken.html) for details.","example":"glrt-0123456789_abcdefXYZ"},"token_obtained_at":{"type":"string","format":"date-time","example":"2023-08-23T23:23:23Z"},"url":{"type":"string","format":"uri","description":"GitLab instance URL","example":"https://gitlab.your-company.com"},"uuid":{"type":"string","format":"uuid","example":"be924fdd-fb28-468c-8c70-1f0ed3af4485"}}}},"securitySchemes":{"api_token":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"security":[{"api_token":[]}],"tags":[{"name":"runrs","description":"GitLab Runners Docker API"}]} \ No newline at end of file