Compare commits

...

241 commits
v0.1.6 ... main

Author SHA1 Message Date
6608d0aa8c
refactor(params): ♻️ Simplify ForgeURL logic by removing redundant switch case
Some checks failed
CodeQL / Analyze (push) Failing after 2s
Go Tests / Linters (push) Successful in 3m26s
Go Tests / go-tests (push) Successful in 6m41s
Streamlines the ForgeURL method by removing an unnecessary nested switch case
on ForgeType, consolidating the logic to rely solely on EntityType. This change
reduces complexity and improves code readability without altering functionality.
2025-08-27 16:04:56 +02:00
Gabriel
29f2e2a2b9
Merge pull request #499 from gabriel-samfira/better-cli-log-formatting
Make the debug-log command more useful
2025-08-27 16:27:33 +03:00
Gabriel Adrian Samfira
0faeee703d Make the debug-log command more useful
The debug-log command now supports log level filtering and attribute
filtering. The log level filtering will only be able to set the minimum
log level as low as the server is configured to stream. If the server has
its log level set as INFO, then setting the log level in the CLI to DEBUG
will have no effect.

But anything above what the server sends, is within the control of the client
to filter. This is all done client side.

Attribute filters are useful if you need to watch the logs for a particular
worker, entity, etc.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-27 13:21:56 +00:00
Gabriel
e3a9fe7026
Merge pull request #498 from gabriel-samfira/preload-more-info
Preload more info for entity pools
2025-08-27 12:27:04 +03:00
Gabriel Adrian Samfira
9ef4566cae Preload more info for entity pools
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-27 09:14:45 +00:00
Gabriel
e79a5c1d50
Merge pull request #496 from cloudbase/dependabot/go_modules/github.com/stretchr/testify-1.11.0
Bump github.com/stretchr/testify from 1.10.0 to 1.11.0
2025-08-25 19:35:17 +03:00
Gabriel
89fecd9dcd
Merge pull request #497 from gabriel-samfira/fix-double-pool
Fix double creation of pools
2025-08-25 19:18:07 +03:00
Gabriel Adrian Samfira
6fee10c737 Fix double creation of pools
This change fixes the creation of pools though the UI. Both the modal and
the page were sending a request to create the pool, leading to double pool.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-25 16:12:01 +00:00
dependabot[bot]
642b3bbf92
Bump github.com/stretchr/testify from 1.10.0 to 1.11.0
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-version: 1.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-25 11:54:27 +00:00
Gabriel
1fceec374d
Merge pull request #495 from gabriel-samfira/caching-and-fixes
Attempt to use the scalset API and caching
2025-08-25 01:45:46 +03:00
Gabriel Adrian Samfira
d05df36868 Attempt to use the scalset API and caching
On github, attempt to use the scaleset API to list all runners without
pagination. This will avoid missing runners and accidentally removing them.

Fall back to paginated API if we can't use the scaleset API.

Add ability to retrieve all instances from cache, for an entity.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-24 22:36:44 +00:00
Gabriel
5c703f310b
Merge pull request #494 from gabriel-samfira/small-fixes
Small fixes
2025-08-24 11:53:21 +03:00
Gabriel Adrian Samfira
86a0b0cf4f Small fixes
* Shut down the web server first to prevent errors caused by clients trying
to use functionality that has already been shut down, causing errors and
potentially delaying the shutdown process.
* remove write timeout from the websocket Write() function.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-24 08:35:17 +00:00
Gabriel
5a26614acf
Merge pull request #493 from gabriel-samfira/ensure-scale-set
Ensure scale set exists
2025-08-23 22:12:30 +03:00
Gabriel Adrian Samfira
39003f006a Ensure scale set exists
Github will remove inactive scale sets after 7 days. This change
ensures the scale set exists in github before spinning up the listener.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-23 18:55:08 +00:00
Gabriel
c48bb50f2a
Merge pull request #492 from gabriel-samfira/add-webui-tests
Add webui tests
2025-08-22 00:18:57 +03:00
Gabriel Adrian Samfira
54c6571ccd Update test workflow
Add steps to test the Web UI and to run go generate.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-21 21:00:27 +00:00
Gabriel Adrian Samfira
8d5c6b6738 Bump go version to 1.24.6 and run go generate
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-21 20:36:50 +00:00
Gabriel Adrian Samfira
48769587bb Add web UI tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-21 20:36:50 +00:00
Gabriel
9aa2e297b9
Merge pull request #491 from igrikus/main
fix(jobs): Correctly handle workflow job IDs from webhooks
2025-08-21 22:04:35 +03:00
Gabriel Adrian Samfira
4341b4869c Fix erroneous calls to Job related functions
Some functions were left behind when we added WorkflowJobID.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-21 18:57:42 +00:00
igrikus
8bda81d6cc fix(jobs): Correctly handle workflow job IDs from webhooks 2025-08-21 14:54:38 +02:00
Gabriel
004c03962f
Merge pull request #488 from gabriel-samfira/remove-deprecated
Replace ${base} with resolve()
2025-08-18 16:09:32 +03:00
Gabriel Adrian Samfira
69a2c509a7 Replace ${base} with resolve()
This removes some deprecated code.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-18 13:08:58 +00:00
Gabriel
b8ff6d9e14
Merge pull request #487 from gabriel-samfira/small-fixes
Fix href for entities
2025-08-18 15:03:24 +03:00
Gabriel Adrian Samfira
9028ef64b1 Fix href for entities
The URL from scale sets and pools to the entity to which they belong
was not being properly resolved.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-18 12:02:08 +00:00
Gabriel
eeed5ae508
Merge pull request #486 from gabriel-samfira/small-fixes
Fix endpoint type name and update cookie
2025-08-18 01:28:47 +03:00
Gabriel Adrian Samfira
04d1042a4c Fix endpoint type name and update cookie
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-17 22:27:17 +00:00
Gabriel
102c430e1d
Merge pull request #485 from gabriel-samfira/ui-fixes
Slightly better error handling
2025-08-17 10:42:33 +03:00
Gabriel Adrian Samfira
7f647941f6 Slightly better error handling
Extract error details we get from the API when status code > 2xx.
Also, use toast messages to display the error, properly close delete
modals and prevent full page display of error messages.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-17 07:34:40 +00:00
Gabriel
8cf0b0a56e
Merge pull request #484 from gabriel-samfira/remove-all-flag-scalesets
Remove the --all flag for scalesets
2025-08-17 02:20:16 +03:00
Gabriel Adrian Samfira
f805123a85 Remove the --all flag for scalesets
Display all scalesets by default, similar to runners and pools.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-16 23:13:47 +00:00
Gabriel
6b49c21206
Merge pull request #483 from gabriel-samfira/fix-inconsistency
Allow referencing runners by ID
2025-08-17 02:08:02 +03:00
Gabriel Adrian Samfira
31ad45eeb6 Allow referencing runners by ID
Although runner names are unique, we still have an ID on the model
which is used as a primary key. We should allow using that ID to
reference a runner in the API.

This change allows users to specify ID or runner name.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-16 23:00:55 +00:00
Gabriel
b4113048bb
Merge pull request #482 from gabriel-samfira/switch-to-fmt-errorf
Switch to fmt.Errorf
2025-08-17 01:28:22 +03:00
Gabriel Adrian Samfira
118319c7c1 Switch to fmt.Errorf
Replace all instances of errors.Wrap() with fmt.Errorf.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-16 22:19:05 +00:00
Gabriel
10dcbec954
Merge pull request #481 from cloudbase/dependabot/npm_and_yarn/webapp/npm_and_yarn-2ea0fb2c37
Bump the npm_and_yarn group across 1 directory with 2 updates
2025-08-16 14:31:17 +03:00
dependabot[bot]
b58bf4c895
Bump the npm_and_yarn group across 1 directory with 2 updates
Bumps the npm_and_yarn group with 2 updates in the /webapp directory: [tmp](https://github.com/raszi/node-tmp) and [@openapitools/openapi-generator-cli](https://github.com/OpenAPITools/openapi-generator-cli).


Removes `tmp`

Updates `@openapitools/openapi-generator-cli` from 2.21.4 to 2.22.0
- [Release notes](https://github.com/OpenAPITools/openapi-generator-cli/releases)
- [Changelog](https://github.com/OpenAPITools/openapi-generator-cli/blob/master/.releaserc)
- [Commits](https://github.com/OpenAPITools/openapi-generator-cli/compare/v2.21.4...v2.22.0)

---
updated-dependencies:
- dependency-name: tmp
  dependency-version: 
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: "@openapitools/openapi-generator-cli"
  dependency-version: 2.22.0
  dependency-type: direct:development
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-16 10:25:06 +00:00
Gabriel
8cc96dbcd1
Merge pull request #479 from gabriel-samfira/spa-webapp
Spa webapp
2025-08-16 13:23:42 +03:00
Gabriel Adrian Samfira
eec158b32c Add SPA UI for GARM
This change adds a single page application front-end to GARM. It uses
a generated REST client, built from the swagger definitions, the websocket
interface for live updates of entities and eager loading of everything
except runners, as users may have many runners and we don't want to load
hundreds of runners in memory.

Proper pagination should be implemented in the API, in future commits,
to avoid loading lots of elements for no reason.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-16 09:09:13 +00:00
Gabriel Adrian Samfira
a811d129d0 Update .gitignore
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-12 12:48:48 +00:00
Gabriel Adrian Samfira
98a769b8d1 Allow cookie login to API endpoints
This change considers cookies as a source for the JWT token.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-12 12:48:48 +00:00
Gabriel Adrian Samfira
5a6ac12118 Fix for gitea tools and scale set cleanup
Filter out gitea tools to only consider archived downloads. This
should help in situations where bandwidth is more important than
CPU time used to unarchive the tools.

Also a drive by fix for scale sets cleanup.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-12 12:48:48 +00:00
Gabriel Adrian Samfira
325bca4af3 Add swagger annotations and updates
Add swagger annotations to models to allow generating a full swagger
definition. This will help generate clients in other languages if needed.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-12 12:48:48 +00:00
Gabriel Adrian Samfira
b2dee1d844 Preload missing resources
There are some inconsistencies in the way the API returns some
values for pools and scale sets. This is due to not preloading
the appropriate relations.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-12 12:48:48 +00:00
Gabriel
9f2764f614
Merge pull request #478 from cloudbase/dependabot/go_modules/github.com/go-openapi/errors-0.22.2
Bump github.com/go-openapi/errors from 0.22.1 to 0.22.2
2025-08-11 21:20:33 +03:00
dependabot[bot]
37eba0fed9
Bump github.com/go-openapi/errors from 0.22.1 to 0.22.2
Bumps [github.com/go-openapi/errors](https://github.com/go-openapi/errors) from 0.22.1 to 0.22.2.
- [Commits](https://github.com/go-openapi/errors/compare/v0.22.1...v0.22.2)

---
updated-dependencies:
- dependency-name: github.com/go-openapi/errors
  dependency-version: 0.22.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-11 10:34:11 +00:00
Gabriel
389a8538af
Merge pull request #476 from cloudbase/dependabot/go_modules/golang.org/x/crypto-0.41.0
Bump golang.org/x/crypto from 0.40.0 to 0.41.0
2025-08-08 12:54:56 +03:00
dependabot[bot]
f24a22d537
Bump golang.org/x/crypto from 0.40.0 to 0.41.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.40.0 to 0.41.0.
- [Commits](https://github.com/golang/crypto/compare/v0.40.0...v0.41.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.41.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-08 09:47:38 +00:00
Gabriel
dfa9848999
Merge pull request #477 from cloudbase/dependabot/go_modules/golang.org/x/mod-0.27.0
Bump golang.org/x/mod from 0.26.0 to 0.27.0
2025-08-08 12:46:12 +03:00
dependabot[bot]
3f51046279
Bump golang.org/x/mod from 0.26.0 to 0.27.0
Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.26.0 to 0.27.0.
- [Commits](https://github.com/golang/mod/compare/v0.26.0...v0.27.0)

---
updated-dependencies:
- dependency-name: golang.org/x/mod
  dependency-version: 0.27.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-08 06:49:58 +00:00
Gabriel
256521ac38
Merge pull request #475 from cloudbase/dependabot/go_modules/github.com/cloudbase/garm-provider-common-0.1.7
Bump github.com/cloudbase/garm-provider-common from 0.1.6 to 0.1.7
2025-08-07 15:34:27 +03:00
dependabot[bot]
e2169865a1
Bump github.com/cloudbase/garm-provider-common from 0.1.6 to 0.1.7
Bumps [github.com/cloudbase/garm-provider-common](https://github.com/cloudbase/garm-provider-common) from 0.1.6 to 0.1.7.
- [Release notes](https://github.com/cloudbase/garm-provider-common/releases)
- [Commits](https://github.com/cloudbase/garm-provider-common/compare/v0.1.6...v0.1.7)

---
updated-dependencies:
- dependency-name: github.com/cloudbase/garm-provider-common
  dependency-version: 0.1.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-07 07:05:40 +00:00
Gabriel
fd9a4d544a
Merge pull request #474 from gabriel-samfira/fix-image-tag
Get the image tag from supplied ref
2025-08-07 00:13:51 +03:00
Gabriel Adrian Samfira
20a16d923c
Get the image tag from supplied ref
We need to pass the ref used in the workflow. If we supply a tag,
we should just get that same tag. If we supply a branch, we should
get the latest release from that branch.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-07 00:12:35 +03:00
Gabriel
212f6fff42
Merge pull request #473 from gabriel-samfira/fix-build-image
Use the Dockerfile from the main branch
2025-08-06 23:11:29 +03:00
Gabriel Adrian Samfira
2ee2fca8ae
Use the Dockerfile from the main branch
There is no way to change the Dockerfile in a tag. We need to
use the Dockerfile in the main branch. So even if we're buildin
the image for a stable version, we need to check out the main branch.

The Dockerfile will take care of checking out the proper tags.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-06 23:09:01 +03:00
Gabriel Adrian Samfira
5915107446
WiP
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-06 23:03:45 +03:00
Gabriel
e43acd5b65
Merge pull request #472 from cloudbase/dependabot/go_modules/github.com/prometheus/client_golang-1.23.0
Bump github.com/prometheus/client_golang from 1.22.0 to 1.23.0
2025-08-01 10:10:35 +03:00
dependabot[bot]
f85fe3d63f
Bump github.com/prometheus/client_golang from 1.22.0 to 1.23.0
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.22.0 to 1.23.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/v1.23.0/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.22.0...v1.23.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-version: 1.23.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-01 06:26:29 +00:00
Gabriel
8082e1a30e
Merge pull request #456 from chickenkiller/feat/refactor-builds
Refactor CI/CD builds
2025-07-31 10:58:16 +03:00
Gabriel
daf2a13e48
Merge pull request #471 from cloudbase/dependabot/go_modules/github.com/golang-jwt/jwt/v5-5.3.0
Bump github.com/golang-jwt/jwt/v5 from 5.2.3 to 5.3.0
2025-07-31 10:14:59 +03:00
dependabot[bot]
4ad7d8e856
Bump github.com/golang-jwt/jwt/v5 from 5.2.3 to 5.3.0
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.2.3 to 5.3.0.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v5.2.3...v5.3.0)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v5
  dependency-version: 5.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-31 07:04:47 +00:00
Lionel ORRY
22f655f48d fixes after testing 2025-07-31 08:42:16 +02:00
Lionel ORRY
158b35db06 simplify workflows 2025-07-30 14:35:01 +02:00
Lionel ORRY
eb07ed3774 remove obsolete tech debt 2025-07-30 12:12:03 +02:00
Lionel ORRY
0f4f98dd03 put a better git version in providers 2025-07-30 12:12:02 +02:00
Lionel ORRY
f6f22cb686 small fixes 2025-07-30 12:09:34 +02:00
Lionel ORRY
af1c090db5 transfer providers branch computation inside Dockerfile 2025-07-30 12:09:32 +02:00
Lionel ORRY
be3026e87c fix branch names 2025-07-30 12:04:02 +02:00
Lionel ORRY
5152bab1b8 fix branch names 2025-07-30 12:04:02 +02:00
Lionel ORRY
3687c7fea4 activate release/v2 nightly build 2025-07-30 12:04:02 +02:00
Lionel ORRY
1e8d0d79a6 improvements after review comments 2025-07-30 12:04:02 +02:00
Lionel ORRY
97ef92706b refactor workflows to enable multiple docker images 2025-07-30 12:04:00 +02:00
Gabriel
53cdfd70a1
Merge pull request #470 from cloudbase/dependabot/go_modules/github.com/jedib0t/go-pretty/v6-6.6.8
Bump github.com/jedib0t/go-pretty/v6 from 6.6.7 to 6.6.8
2025-07-28 12:30:47 +03:00
dependabot[bot]
7817d20516
Bump github.com/jedib0t/go-pretty/v6 from 6.6.7 to 6.6.8
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.6.7 to 6.6.8.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.6.7...v6.6.8)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-version: 6.6.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-28 08:04:00 +00:00
Gabriel
daadad682b
Merge pull request #468 from cloudbase/dependabot/go_modules/gorm.io/gorm-1.30.1
Bump gorm.io/gorm from 1.30.0 to 1.30.1
2025-07-24 09:55:44 +03:00
dependabot[bot]
f4892be193
Bump gorm.io/gorm from 1.30.0 to 1.30.1
Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.30.0 to 1.30.1.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/compare/v1.30.0...v1.30.1)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  dependency-version: 1.30.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-24 06:47:05 +00:00
Gabriel
e687565671
Merge pull request #467 from cloudbase/dependabot/go_modules/github.com/cloudbase/garm-provider-common-0.1.6
Bump github.com/cloudbase/garm-provider-common from 0.1.5 to 0.1.6
2025-07-21 11:45:24 +03:00
dependabot[bot]
567c465ad7
Bump github.com/cloudbase/garm-provider-common from 0.1.5 to 0.1.6
Bumps [github.com/cloudbase/garm-provider-common](https://github.com/cloudbase/garm-provider-common) from 0.1.5 to 0.1.6.
- [Release notes](https://github.com/cloudbase/garm-provider-common/releases)
- [Commits](https://github.com/cloudbase/garm-provider-common/compare/v0.1.5...v0.1.6)

---
updated-dependencies:
- dependency-name: github.com/cloudbase/garm-provider-common
  dependency-version: 0.1.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-21 07:58:08 +00:00
Gabriel
f1fed3c462
Merge pull request #466 from gabriel-samfira/update-docs-and-defaults
Update docs and deprecate the --all flag
2025-07-20 23:38:50 +03:00
Gabriel Adrian Samfira
80735ac2eb Update docs and deprecate the --all flag
Update the docs to reflect the latest stable version and deprecate the
--all flag for runner list and pool list.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-07-20 20:31:56 +00:00
Gabriel
bb45324dcd
Merge pull request #459 from gabriel-samfira/account-for-job-id
Handle new jobID for scale sets
2025-07-18 11:39:06 +03:00
Gabriel Adrian Samfira
a984782fd7 Handle new jobID for scale sets
There seems to be a change in the scale set message. It now includes
a jobID and sets the runner request ID to 0. This change adds separate
job ID fields for workflow jobs and scaleset jobs.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-07-18 08:20:50 +00:00
Gabriel
d26973da2a
Merge pull request #458 from gabriel-samfira/fix-scaleset-param
Fix scale set param
2025-07-17 20:06:14 +03:00
Gabriel Adrian Samfira
69779a0a7d Fix scale set param
Do not look for a name when composing the scale set. Preload may not
have been called on an entity, but we still have the ID, which is the
only thing needed when GetEntity() is called.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-07-17 17:01:20 +00:00
Gabriel
c95252547e
Merge pull request #454 from gabriel-samfira/fix-encoding
Handle query args
2025-07-16 17:52:02 +03:00
Gabriel
d17b168b4e
Merge pull request #453 from cloudbase/dependabot/go_modules/github.com/golang-jwt/jwt/v5-5.2.3
Bump github.com/golang-jwt/jwt/v5 from 5.2.2 to 5.2.3
2025-07-16 10:36:26 +03:00
dependabot[bot]
a46c474640
Bump github.com/golang-jwt/jwt/v5 from 5.2.2 to 5.2.3
Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.2.2 to 5.2.3.
- [Release notes](https://github.com/golang-jwt/jwt/releases)
- [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md)
- [Commits](https://github.com/golang-jwt/jwt/compare/v5.2.2...v5.2.3)

---
updated-dependencies:
- dependency-name: github.com/golang-jwt/jwt/v5
  dependency-version: 5.2.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-16 06:41:38 +00:00
Gabriel Adrian Samfira
65d6d1ae87 Handle query args
Merge any query args from both the GH url and the supplied URL.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-07-16 06:39:46 +00:00
Gabriel
78547fefaa
Merge pull request #450 from cloudbase/dependabot/go_modules/golang.org/x/mod-0.26.0
Bump golang.org/x/mod from 0.25.0 to 0.26.0
2025-07-11 14:48:26 +03:00
dependabot[bot]
0cc51e48ef
Bump golang.org/x/mod from 0.25.0 to 0.26.0
---
updated-dependencies:
- dependency-name: golang.org/x/mod
  dependency-version: 0.26.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-11 09:34:59 +00:00
Gabriel
86b8ac9e94
Merge pull request #451 from cloudbase/dependabot/go_modules/golang.org/x/crypto-0.40.0
Bump golang.org/x/crypto from 0.39.0 to 0.40.0
2025-07-11 12:33:37 +03:00
dependabot[bot]
f9b1b26f80
Bump golang.org/x/crypto from 0.39.0 to 0.40.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.39.0 to 0.40.0.
- [Commits](https://github.com/golang/crypto/compare/v0.39.0...v0.40.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.40.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-11 06:28:17 +00:00
Gabriel
19e025c2be
Merge pull request #448 from gabriel-samfira/fix-sleep
Fix sleepWithCancel and ensure closed channel
2025-07-07 08:02:32 +03:00
Gabriel Adrian Samfira
b23bca73bc Fix sleepWithCancel and ensure closed channel
* time.NewTicker will panic if the duration is 0. Make it return
early if duration is 0.
* Return a pre-closed channel in Wait() instead of nil. Ensures receiver
will not block forever.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-07-07 04:54:10 +00:00
Gabriel
20d4e68fd4
Merge pull request #447 from gabriel-samfira/fix-makefile
Use the -v flag on podman only
2025-07-07 00:26:46 +03:00
Gabriel Adrian Samfira
6ae3b25b4d Use the -v flag on podman only
Docker does not support the --volume flag at build time. This needs
to be done in the Dockerfile directly on the RUN stanza. Will update
in a future PR, until then, just set the flag for podman.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-07-06 21:17:31 +00:00
Gabriel
e14f3858ef
Merge pull request #446 from gabriel-samfira/fix-url-composition
Use JoinPath() and relative paths
2025-07-06 22:56:35 +03:00
Gabriel Adrian Samfira
18902f884a Use JoinPath() and relative paths
Use JoinPath() in newActionsRequest() and make sure we pass relative
paths to it. This should fix scale sets on GHES.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-07-06 19:22:43 +00:00
Gabriel
379c39095e
Merge pull request #444 from chickenkiller/fix-podman
improve usability of podman in Makefile
2025-07-02 15:15:16 +03:00
Lionel ORRY
3853f8bd94 improve usability of podman in Makefile 2025-07-02 14:04:41 +02:00
Gabriel
9f5cf64542
Merge pull request #441 from cloudbase/dependabot/go_modules/gorm.io/datatypes-1.2.6
Bump gorm.io/datatypes from 1.2.5 to 1.2.6
2025-07-01 12:50:30 +03:00
dependabot[bot]
7c8241579d
Bump gorm.io/datatypes from 1.2.5 to 1.2.6
Bumps [gorm.io/datatypes](https://github.com/go-gorm/datatypes) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/go-gorm/datatypes/releases)
- [Commits](https://github.com/go-gorm/datatypes/compare/v1.2.5...v1.2.6)

---
updated-dependencies:
- dependency-name: gorm.io/datatypes
  dependency-version: 1.2.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-01 09:02:05 +00:00
Gabriel
25e7befa08
Merge pull request #440 from gabriel-samfira/forward-port-439
Set http transport config
2025-06-27 11:27:48 +03:00
Gabriel Adrian Samfira
529ce8b7a8 Set http transport config
This change sets the github client http transport options to mirror those
of the default transport from Go, with the addition of the TLSClientConfig.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-06-27 08:19:45 +00:00
Gabriel
42839917f3
Merge pull request #437 from gabriel-samfira/several-fixes
Some cleanup
2025-06-21 20:54:03 +03:00
Gabriel Adrian Samfira
1ec99e8695 Some cleanup
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-06-21 17:31:26 +00:00
Gabriel
6c104b6ece
Merge pull request #432 from gabriel-samfira/use-friendly-names
Allow usage of friendly names in most commands
2025-06-21 20:15:14 +03:00
Gabriel Adrian Samfira
808af82e0d Add endpoint option to all relevant commands
In case of ambiguity when using the name of a repo, org or enterprise,
an --endpoint flag can be used to uniquely identify an entity against
an endpoint.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-06-21 17:05:22 +00:00
Gabriel
7c2086bc64
Merge pull request #436 from cloudbase/dependabot/go_modules/github.com/cloudbase/garm-provider-common-0.1.5
Bump github.com/cloudbase/garm-provider-common from 0.1.5-0.20250417155201-8ef03502d06e to 0.1.5
2025-06-20 14:08:02 +03:00
dependabot[bot]
ed924e8034
Bump github.com/cloudbase/garm-provider-common
Bumps [github.com/cloudbase/garm-provider-common](https://github.com/cloudbase/garm-provider-common) from 0.1.5-0.20250417155201-8ef03502d06e to 0.1.5.
- [Release notes](https://github.com/cloudbase/garm-provider-common/releases)
- [Commits](https://github.com/cloudbase/garm-provider-common/commits/v0.1.5)

---
updated-dependencies:
- dependency-name: github.com/cloudbase/garm-provider-common
  dependency-version: 0.1.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-20 07:08:08 +00:00
Gabriel Adrian Samfira
e92b2c1111 Allow usage of friendly names in most commands
This change adds the ability to use the repo/org/enterprise names
instead of UUID in most garm-cli commands, at the expense of an extra
list API call, leveraging the recently added filter options.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-06-19 09:27:18 +00:00
Gabriel
43a2343828
Merge pull request #431 from gabriel-samfira/add-filter-option
Add a rudimentary filter option when listing entities
2025-06-19 00:34:56 +03:00
Gabriel Adrian Samfira
499fbde60c Add a rudimentary filter option when listing entities
This change adds the ability to filter the list of entities returned
by the API by entity owner, name or endpoint, depending on the entity
type.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-06-18 21:23:34 +00:00
Gabriel
2fd0e720e6
Merge pull request #430 from gabriel-samfira/update-deps
Update dependencies
2025-06-18 00:15:19 +03:00
Gabriel Adrian Samfira
d42160cab2 Update dependencies
This change updates all dependencies.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-06-17 21:09:05 +00:00
Gabriel
e3833e5e48
Merge pull request #429 from tormath1/tormath1/doc
doc/gitea: remove 'version'
2025-06-12 20:17:43 +03:00
Mathieu Tortuyaux
98fa085bc7
doc/gitea: remove 'version'
This field is deprecated:
```
$ docker compose version
Docker Compose version v2.36.2
...
WARN[0000] /home/core/docker-compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
```

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2025-06-12 09:53:59 +02:00
Gabriel
d13ea92a54
Merge pull request #428 from tormath1/tormath1/linode
readme: add akamai/linode experimental external provider
2025-06-11 07:25:13 +03:00
Mathieu Tortuyaux
4c536f2584
readme: add Akamai/Linode external provider
The provider is quite new and awaits for feedback, let's mention the
"experimental" status.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2025-06-10 17:59:29 +02:00
Mathieu Tortuyaux
043359936b
readme: sort external providers
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2025-06-10 17:58:11 +02:00
Gabriel
1c2f349d56
Merge pull request #413 from cloudbase/dependabot/go_modules/gorm.io/gorm-1.30.0
Bump gorm.io/gorm from 1.26.1 to 1.30.0
2025-05-29 21:38:15 +03:00
Gabriel
be86709bdf
Merge pull request #419 from gabriel-samfira/enable-tests-in-release
Trigger tests on release branches
2025-05-29 20:15:00 +03:00
Gabriel Adrian Samfira
48c4ea7d15 Trigger tests on release branches
This change triggers tests for PRs created against release/* branches.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-29 17:07:46 +00:00
Gabriel
c19bf2f9f8
Merge pull request #416 from ChristopherHX/optional-forge-type-for-gitea
Create Repo / Org make --forge-type optional
2025-05-29 20:04:51 +03:00
Christopher Homberger
efd725ea94 Create Repo / Org make --forge-type optional
* This makes gitea garm usage unnessary complex

Signed-off-by: Christopher Homberger <christopher.homberger@web.de>
2025-05-29 18:36:25 +02:00
dependabot[bot]
914f7fbd49
Bump gorm.io/gorm from 1.26.1 to 1.30.0
Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.26.1 to 1.30.0.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/compare/v1.26.1...v1.30.0)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  dependency-version: 1.30.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 06:15:56 +00:00
Gabriel
18ef27bb91
Merge pull request #412 from gabriel-samfira/allow-deleting-default-ep
Make the default github endpoint mutable
2025-05-25 01:32:23 +03:00
Gabriel Adrian Samfira
87055f23da Make the default github endpoint mutable
This change allows users to remove the default github endpoint
if no credentials are set on it.

A new protection is added on URLs of any endpoint that prevents their
update if the endpoint has credentials set.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-24 22:26:01 +00:00
Gabriel
b5bd373061
Merge pull request #411 from gabriel-samfira/add-logo
Experiment with a logo
2025-05-24 23:35:06 +03:00
Gabriel Adrian Samfira
ae69e8c473 Experiment with a logo
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-24 20:13:05 +00:00
Gabriel
451e7c4556
Merge pull request #408 from gabriel-samfira/fix-add-entity-event
Fix AddInstanceEvent and expose events
2025-05-22 22:24:36 +03:00
Gabriel Adrian Samfira
9921a7bfc8 Fix AddInstanceEvent and expose events
* We were passing the wrong type to GORM for events
* We now expose entity events in the API and CLI

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-22 19:19:24 +00:00
Gabriel
ed8e11e244
Merge pull request #405 from gabriel-samfira/ensure-token
Ensure that admin token exists
2025-05-22 00:38:47 +03:00
Gabriel Adrian Samfira
7e576dc631 Ensure that admin token exists
Make sure that the admin info is populated when calling GenerateJitRunnerConfig.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-21 21:29:43 +00:00
Gabriel
d8cb1c5acd
Merge pull request #404 from gabriel-samfira/fix-cli
Avoid nil pointer dereference in CLI
2025-05-21 23:58:56 +03:00
Gabriel Adrian Samfira
9660b28019 Avoid nil pointer dereference in CLI
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-21 20:58:21 +00:00
Gabriel
f5c3363249
Merge pull request #403 from cloudbase/gabriel-samfira-patch-1
Update Dockerfile
2025-05-21 23:46:43 +03:00
Gabriel
4e157fc4cc
Update Dockerfile 2025-05-21 23:46:29 +03:00
Gabriel
ac0caa2ed9
Merge pull request #402 from gabriel-samfira/fix-parse-error
Fix potential nil pointer dereference
2025-05-21 22:50:44 +03:00
Gabriel Adrian Samfira
cfe707e522 Fix potential nil pointer dereference
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-21 19:45:23 +00:00
Gabriel
8c16ee92b3
Merge pull request #400 from kaspar030/patch-1
Fix some typos in scalesets.md
2025-05-21 17:45:25 +03:00
Kaspar Schleiser
8e8d7fd364
Fix some typos in scalesets.md 2025-05-21 16:39:22 +02:00
Gabriel
7646ff4429
Merge pull request #399 from cloudbase/gabriel-samfira-patch-1
Update gitea.md
2025-05-21 13:52:45 +03:00
Gabriel
93768a2796
Update gitea.md 2025-05-21 13:52:15 +03:00
Gabriel
65aa92f517
Merge pull request #398 from gabriel-samfira/add-docker-compose-example
Add examples for setting up GARM with Gitea
2025-05-21 13:28:48 +03:00
Gabriel Adrian Samfira
1c758d010a Add examples for setting up GARM with Gitea
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-21 10:27:59 +00:00
Gabriel
c85aea2d26
Merge pull request #396 from cloudbase/fix-schedule
Use default values for ref and push to project
2025-05-21 11:10:53 +03:00
Gabriel
f95bfee0d9
Merge pull request #397 from cloudbase/dependabot/go_modules/golang.org/x/mod-0.24.0
Bump golang.org/x/mod from 0.17.0 to 0.24.0
2025-05-21 09:43:07 +03:00
dependabot[bot]
4cf1468907
Bump golang.org/x/mod from 0.17.0 to 0.24.0
Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.17.0 to 0.24.0.
- [Commits](https://github.com/golang/mod/compare/v0.17.0...v0.24.0)

---
updated-dependencies:
- dependency-name: golang.org/x/mod
  dependency-version: 0.24.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-21 06:30:29 +00:00
Gabriel Adrian Samfira
c5c35f1324 Use default values for ref and push to project
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-21 05:03:07 +00:00
Gabriel
0068119c34
Merge pull request #395 from gabriel-samfira/add-cli-to-docker-image
Add CLI to docker image
2025-05-21 00:15:54 +03:00
Gabriel Adrian Samfira
269c6064e7 Add CLI to docker image
This change adds the GARM cli to the docker image.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-20 21:15:08 +00:00
Gabriel
b7798404f8
Merge pull request #394 from cloudbase/update-build-and-push
Allow for nightly builds
2025-05-20 23:20:55 +03:00
Gabriel Adrian Samfira
bdcc817def Enable daily cron
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-20 20:10:08 +00:00
Gabriel Adrian Samfira
b41318c948 Allow for nightly builds
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-20 17:00:59 +00:00
Gabriel
dee6bf7c9a
Merge pull request #393 from gabriel-samfira/add-gitea
Add gitea
2025-05-20 19:26:46 +03:00
Gabriel Adrian Samfira
1fc72ab5c8 Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-20 16:12:45 +00:00
Gabriel Adrian Samfira
1fe09548bc Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-20 13:52:16 +00:00
Gabriel Adrian Samfira
b4268e6bab Fix tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-20 09:52:13 +00:00
Gabriel Adrian Samfira
6994c8ce05 Add copyright header
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-20 09:43:29 +00:00
Gabriel Adrian Samfira
f0753eeb22 Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-20 09:22:55 +00:00
Gabriel Adrian Samfira
b2d5609352 Add some tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-19 19:45:45 +00:00
Gabriel Adrian Samfira
bb798a288a Properly set webhook secret
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-16 23:58:39 +00:00
Gabriel Adrian Samfira
6a168ba813 Enable orgs
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-16 23:02:01 +00:00
Gabriel Adrian Samfira
5dfcfc542e Implement webhooks install for gitea
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-16 20:24:11 +00:00
Gabriel Adrian Samfira
08511e2e7f Account for gitea credentials in cache and watchers
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-15 09:15:44 +00:00
Gabriel Adrian Samfira
b4e92a69c9 Fix existing tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-14 23:20:18 +00:00
Gabriel Adrian Samfira
0270117e8d Fix lint errors
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-14 22:01:11 +00:00
Gabriel Adrian Samfira
39ac658527 Add forge type to repo list
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-14 21:33:46 +00:00
Gabriel Adrian Samfira
3fe4cef884 Cleanup unused code
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-14 21:14:31 +00:00
Gabriel Adrian Samfira
f66b651b59 Fix findEndpointForJob
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-14 21:09:02 +00:00
Gabriel Adrian Samfira
56be5eb698 Do not load scalesets and runners in parallel
Both functions read and write to the same map. We should switch
to sync.Map

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-14 15:36:53 +00:00
Gabriel Adrian Samfira
8538a4ae8a Make sure websocket hub exits properly
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-14 15:22:27 +00:00
Gabriel Adrian Samfira
823a9e4b82 Add Gitea endpoints and credentials
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-14 00:34:54 +00:00
Gabriel Adrian Samfira
40e6581a75 Rename GitHub specific types
This change renames a lot of variables, types and functions to be more
generic. The goal is to allow GARM to add more forges in the future.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-12 21:47:13 +00:00
Gabriel Adrian Samfira
4890eb4732 Add EndpointType
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-12 17:32:37 +00:00
Gabriel Adrian Samfira
ef676488b7 Use cache for github client
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-10 20:08:51 +00:00
Gabriel
5dbaa351d2
Merge pull request #392 from gabriel-samfira/docs
Slight rewording
2025-05-10 09:15:11 +03:00
Gabriel Adrian Samfira
41700cd958 Slight rewording
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-10 06:14:38 +00:00
Gabriel
fd6f01d2c0
Merge pull request #391 from gabriel-samfira/add-some-docs
Add some info about scale sets
2025-05-10 00:29:19 +03:00
Gabriel Adrian Samfira
979c07adbe Add some info about scale sets
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-09 21:28:29 +00:00
Gabriel
6b4c4f610e
Merge pull request #390 from gabriel-samfira/add-some-parallel-startup
Load entities in parallel
2025-05-09 01:31:10 +03:00
Gabriel Adrian Samfira
68183384dc Load entities in parallel
This change uses an error group to load different DB resources
in parallel.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-08 22:26:40 +00:00
Gabriel
49147a015a
Merge pull request #389 from gabriel-samfira/fixes-and-rate-limits
Add rate limit cache and fixes
2025-05-09 00:49:28 +03:00
Gabriel Adrian Samfira
1a719567ff Add rate limit cache and fixes
This change adds a loop that keeps a cache of credentials rate limits
as reported by the github API. The cache is updated every 30 seconds
and is purely informational for the user.

This change also adds some caching improvements. Functions that return
values from the cache as lists, will now sort by ID or creation date.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-08 21:39:55 +00:00
Gabriel
16af8fd97f
Merge pull request #387 from gabriel-samfira/add-tools-update
Add tools update routine and cleanup logging
2025-05-08 11:35:41 +03:00
Gabriel Adrian Samfira
2e9535530d Fix entity update handler
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-08 08:27:41 +00:00
Gabriel Adrian Samfira
a38d72a01c Add runner group to the scale set list output
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-08 08:12:29 +00:00
Gabriel Adrian Samfira
52007f4ffa Add tools update routine and cleanup logging
This change adds an update routine in the cache worker, for github tools
downloads.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-07 23:07:58 +00:00
Gabriel
ffbb3b8d41
Merge pull request #386 from gabriel-samfira/add-cache-worker
Add cache worker
2025-05-07 11:31:18 +03:00
Gabriel Adrian Samfira
90200ffa71 Do not clobber pools and scaleset caches on update
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-07 08:15:29 +00:00
Gabriel Adrian Samfira
d0c9462a5d Add cache worker
Add dedicated worker to maintain cache.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-07 08:01:36 +00:00
Gabriel
e49b35d3d0
Merge pull request #376 from gabriel-samfira/scalesets
Add scale sets
2025-05-07 00:12:57 +03:00
Gabriel Adrian Samfira
2f2ff62411 Deduplicate code
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-06 20:59:41 +00:00
Gabriel Adrian Samfira
f7cd743a9c Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-06 19:37:07 +00:00
Gabriel Adrian Samfira
a80b900ee9 Update dependencies
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-06 18:27:20 +00:00
Gabriel Adrian Samfira
0e1fa0018b Add some more caching, record scaleset jobs
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-06 17:50:12 +00:00
Gabriel Adrian Samfira
2f3c74562e Add instance cache
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-05 23:34:53 +00:00
Gabriel Adrian Samfira
9f640965e2 revert main
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-05 21:12:20 +00:00
Gabriel Adrian Samfira
1d093cc336 Slight refactor; add creds cache worker
* Split the main function into a couple of more functions
* Add credentials, entity, pool and scaleset cache
* add credentials worker that updates the cache

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-05 18:21:57 +00:00
Gabriel Adrian Samfira
3b3095c546 Scale sets are unique within a runner group
You can have multiple scale sets with the same name, as long as
they live in different runner groups.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:57:50 +00:00
Gabriel Adrian Samfira
77895d9c89 Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:41 +00:00
Gabriel Adrian Samfira
ff383ea493 Add db scaleset tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:41 +00:00
Gabriel Adrian Samfira
2a5e374ae6 Remove unused field
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:41 +00:00
Gabriel Adrian Samfira
c601f88cf7 Add more tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:41 +00:00
Gabriel Adrian Samfira
92d04c8e8d Add tests for cache and locking
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
059734f064 Add runner periodic cleanup check
Adds a periodic cleanup function that cross checks runners between github,
the provider and the GARM database. If an inconsistency is found, GARM will
attempt to fix it.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
73340da322 Add RateLimit() function to gh client
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
fafe98e62f Update go-github
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
22302fdd7a Add scaleset watcher to provider
Fixes provider not spawning runners for newly added scale set

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
64d1501b0e DeleteInstance should noop if error not found
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
4b1d51f1d0 Fix nil pointer deref
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
55b4e74066 Update mocks
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
884be62a4d Fix lint errors
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
a4ac85aa4a Update CLI to show scale sets
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
f2ad7a3481 Fix leftover instances and refactor
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
004ad1f124 Add provider worker code
Runners now get created and cleaned up in scale sets.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
436fd7746f WiP
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
020210d6ad Handle scale up and down; add provider worker
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
7376a5fe74 Fix scale set restart logic
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
bc470c5f78 WiP
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
8c62b6de8c Obey enabled/disabled status
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
d949cecbe7 Keep a cache of runners in the scaleset worker
We will need to run various checks against the runners that are managed
by a scale set. The runners are updated by the DB watcher, so we should
always have an up to date view of their state. We can then confidently
monitor them without needing to query the DB.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
94f264d444 Handle JobStarted and JobCompleted
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
8d10dd4716 Update garm-provider-common
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
fc4bd863aa Add some db functions to handle scaleset instances
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
c177c31147 Add some message handling
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
12f40a5352 Fix refresh session
It seems that Status is a string when you create a session, but a number
when you refresh it (?).

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
19ba210804 Several fixes
* Close response body in scaleset client
* Wait for message listener loop to exit before attempting restart
* Add LastMessageID field to scaleset model and function to update it

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
a2aeac731c Scale set workers properly come online
This adds the workers needed to start listening for scale set messages.
There is no handling of messages yet.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
6a5c309399 Add some worker code
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
7174e030e2 Add scaleset commands
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
7e1a83c79a Add API endpoint for some scaleset ops
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
85eac363d5 Add ScaleSet models, functions and types
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
5ba53adf84 Switch to locking package
The locking logic was added to its own package as it may need to be used
by other parts of the code.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
e51f19acc8 Fix lint errors
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
d7d6d1e31a Add mocks
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
51c7d2a806 Add scaleset types
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
Gabriel Adrian Samfira
79b9a1583c Add scaleset client
This change moves the github client to a subpackage in utils
and adds the scaleset github client code.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-05-03 22:29:40 +00:00
1118 changed files with 110337 additions and 71524 deletions

View file

@ -1,14 +1,16 @@
name: "Build GARM images"
name: "Build and push GARM images"
on:
workflow_dispatch:
workflow_call:
inputs:
push_to_project:
description: "Project to build images for"
required: true
required: false
type: string
default: "ghcr.io/cloudbase"
ref:
description: "Ref to build"
required: true
required: false
type: string
default: "main"
permissions:
@ -22,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: src/github.com/cloudbase/garm
fetch-depth: 0
@ -37,16 +39,23 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
- name: Build and push image
env:
IMAGE_REGISTRY: ${{ inputs.push_to_project }}
GH_REF: ${{ inputs.ref }}
working-directory: src/github.com/cloudbase/garm
run: |
cd src/github.com/cloudbase/garm
VERSION=$(git describe --tags --match='v[0-9]*' --always ${{ github.event.inputs.ref }})
if [ "$GH_REF" == "main" ]; then
IMAGE_TAG="nightly"
else
IMAGE_TAG=$(git describe --tags --match='v[0-9]*' --always ${GH_REF})
fi
docker buildx build \
--provenance=false \
--platform linux/amd64,linux/arm64 \
--label "org.opencontainers.image.source=https://github.com/cloudbase/garm/tree/${{ github.event.inputs.ref }}" \
--label "org.opencontainers.image.description=GARM ${{ github.event.inputs.ref }}" \
--label "org.opencontainers.image.source=https://github.com/cloudbase/garm/tree/${GH_REF}" \
--label "org.opencontainers.image.description=GARM ${GH_REF}" \
--label "org.opencontainers.image.licenses=Apache 2.0" \
--build-arg="GARM_REF=${{ github.event.inputs.ref }}" \
-t ${{ github.event.inputs.push_to_project }}/garm:"${VERSION}" \
--build-arg="GARM_REF=${GH_REF}" \
-t ${IMAGE_REGISTRY}/garm:"${IMAGE_TAG}" \
--push .

View file

@ -4,9 +4,11 @@ on:
push:
branches:
- main
- 'release/**'
pull_request:
branches:
- main
- 'release/**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
@ -26,10 +28,11 @@ jobs:
sudo apt-get update
sudo apt-get install -y libbtrfs-dev build-essential apg jq
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: '^1.22.3'
- uses: actions/checkout@v3
go-version-file: go.mod
- name: make lint
run: make golangci-lint && GOLANGCI_LINT_EXTRA_ARGS="--timeout=8m --build-tags=testing,integration" make lint
- name: Verify go vendor, go modules and gofmt
@ -41,15 +44,39 @@ jobs:
runs-on: ubuntu-latest
needs: [linters]
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libbtrfs-dev build-essential apg jq default-jre
- uses: actions/setup-node@v4
with:
node-version: '>=v24.5.0'
- name: Set up openapi-generator-cli
run: |
mkdir -p $HOME/openapi-generator
cd $HOME/openapi-generator
npm install @openapitools/openapi-generator-cli
echo "$HOME/openapi-generator/node_modules/.bin" >> $GITHUB_PATH
- name: Checkout
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go version
- name: Run go generate
run: |
GOTOOLCHAIN=go1.24.6 make generate
- name: Run GARM Go Tests
run: make go-test
- name: Run web UI tests
run: |
make webui-test

View file

@ -107,7 +107,6 @@ jobs:
with:
name: garm-logs
path: /artifacts-logs
merge-multiple: true
- name: Cleanup orphan GARM resources via GitHub API
if: always()

19
.github/workflows/trigger-manual.yml vendored Normal file
View file

@ -0,0 +1,19 @@
name: Manual build of GARM images
on:
workflow_dispatch:
inputs:
push_to_project:
description: "Project to build images for"
required: true
default: "ghcr.io/cloudbase"
ref:
description: "Ref to build"
required: true
default: "main"
jobs:
call-build-and-push:
uses: ./.github/workflows/build-and-push.yml
with:
push_to_project: ${{ inputs.push_to_project }}
ref: ${{ inputs.ref }}

10
.github/workflows/trigger-nightly.yml vendored Normal file
View file

@ -0,0 +1,10 @@
name: Nightly build of GARM images
on:
schedule:
- cron: "0 2 * * *"
jobs:
call-build-and-push:
uses: ./.github/workflows/build-and-push.yml
with:
ref: "main"

6
.gitignore vendored
View file

@ -19,3 +19,9 @@ bin/
cmd/temp
build/
release/
node_modules/
.svelte-kit/
debug.html
git_push.sh
webapp/src/lib/api/generated/docs
.env

27
.mockery.yaml Normal file
View file

@ -0,0 +1,27 @@
with-expecter: true
dir: "mocks"
mockname: "{{ .InterfaceName }}"
outpkg: "mocks"
filename: "{{ .InterfaceName }}.go"
# V3 compatibility settings
resolve-type-alias: false
disable-version-string: true
issue-845-fix: true
packages:
# Database store interfaces
github.com/cloudbase/garm/database/common:
interfaces:
Store:
config:
dir: "{{ .InterfaceDir }}/mocks"
# Runner interfaces
github.com/cloudbase/garm/runner:
interfaces:
PoolManagerController:
config:
dir: "{{ .InterfaceDir }}/mocks"
# Runner common interfaces (generate all interfaces in this package)
github.com/cloudbase/garm/runner/common:
config:
dir: "{{ .InterfaceDir }}/mocks"
all: true

View file

@ -3,39 +3,66 @@ ARG GARM_REF
LABEL stage=builder
RUN apk add musl-dev gcc libtool m4 autoconf g++ make libblkid util-linux-dev git linux-headers upx
RUN git config --global --add safe.directory /build
RUN apk add --no-cache musl-dev gcc libtool m4 autoconf g++ make libblkid util-linux-dev git linux-headers upx curl jq
RUN git config --global --add safe.directory /build && git config --global --add advice.detachedHead false
RUN echo ${GARM_REF}
ADD . /build/garm
RUN cd /build/garm && git checkout ${GARM_REF}
RUN git clone --depth 1 --branch v0.1.0 https://github.com/cloudbase/garm-provider-azure /build/garm-provider-azure
RUN git clone --depth 1 --branch v0.1.0 https://github.com/cloudbase/garm-provider-openstack /build/garm-provider-openstack
RUN git clone --depth 1 --branch v0.1.0 https://github.com/cloudbase/garm-provider-lxd /build/garm-provider-lxd
RUN git clone --depth 1 --branch v0.1.0 https://github.com/cloudbase/garm-provider-incus /build/garm-provider-incus
RUN git clone --depth 1 --branch v0.1.0 https://github.com/cloudbase/garm-provider-aws /build/garm-provider-aws
RUN git clone --depth 1 --branch v0.1.0 https://github.com/cloudbase/garm-provider-gcp /build/garm-provider-gcp
RUN git clone --depth 1 --branch v0.1.0 https://github.com/cloudbase/garm-provider-equinix /build/garm-provider-equinix
RUN git clone --depth 1 --branch v0.3.1 https://github.com/mercedes-benz/garm-provider-k8s /build/garm-provider-k8s
RUN cd /build/garm && go build -o /bin/garm \
-tags osusergo,netgo,sqlite_omit_load_extension \
-ldflags "-linkmode external -extldflags '-static' -s -w -X github.com/cloudbase/garm/util/appdefaults.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" \
/build/garm/cmd/garm && upx /bin/garm
RUN mkdir -p /opt/garm/providers.d
RUN cd /build/garm-provider-azure && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=v0.1.0" -o /opt/garm/providers.d/garm-provider-azure . && upx /opt/garm/providers.d/garm-provider-azure
RUN cd /build/garm-provider-openstack && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=v0.1.0" -o /opt/garm/providers.d/garm-provider-openstack . && upx /opt/garm/providers.d/garm-provider-openstack
RUN cd /build/garm-provider-lxd && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=v0.1.0" -o /opt/garm/providers.d/garm-provider-lxd . && upx /opt/garm/providers.d/garm-provider-lxd
RUN cd /build/garm-provider-incus && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=v0.1.0" -o /opt/garm/providers.d/garm-provider-incus . && upx /opt/garm/providers.d/garm-provider-incus
RUN cd /build/garm-provider-aws && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=v0.1.0" -o /opt/garm/providers.d/garm-provider-aws . && upx /opt/garm/providers.d/garm-provider-aws
RUN cd /build/garm-provider-gcp && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=v0.1.0" -o /opt/garm/providers.d/garm-provider-gcp . && upx /opt/garm/providers.d/garm-provider-gcp
RUN cd /build/garm-provider-equinix && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=v0.1.0" -o /opt/garm/providers.d/garm-provider-equinix . && upx /opt/garm/providers.d/garm-provider-equinix
RUN cd /build/garm-provider-k8s/cmd/garm-provider-k8s && go build -ldflags="-linkmode external -extldflags '-static' -s -w" -o /opt/garm/providers.d/garm-provider-k8s . && upx /opt/garm/providers.d/garm-provider-k8s
RUN git -C /build/garm checkout ${GARM_REF}
RUN cd /build/garm \
&& go build -o /bin/garm \
-tags osusergo,netgo,sqlite_omit_load_extension \
-ldflags "-linkmode external -extldflags '-static' -s -w -X github.com/cloudbase/garm/util/appdefaults.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" \
/build/garm/cmd/garm && upx /bin/garm
RUN cd /build/garm/cmd/garm-cli \
&& go build -o /bin/garm-cli \
-tags osusergo,netgo,sqlite_omit_load_extension \
-ldflags "-linkmode external -extldflags '-static' -s -w -X github.com/cloudbase/garm/util/appdefaults.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" \
. && upx /bin/garm-cli
RUN set -ex; \
mkdir -p /opt/garm/providers.d; \
for repo in \
cloudbase/garm-provider-azure \
cloudbase/garm-provider-openstack \
cloudbase/garm-provider-lxd \
cloudbase/garm-provider-incus \
cloudbase/garm-provider-aws \
cloudbase/garm-provider-gcp \
cloudbase/garm-provider-equinix \
flatcar/garm-provider-linode \
mercedes-benz/garm-provider-k8s; \
do \
export PROVIDER_NAME="$(basename $repo)"; \
export PROVIDER_SUBDIR=""; \
if [ "$GARM_REF" == "main" ]; then \
export PROVIDER_REF="main"; \
else \
export PROVIDER_REF="$(curl -s -L https://api.github.com/repos/$repo/releases/latest | jq -r '.tag_name')"; \
fi; \
git clone --branch "$PROVIDER_REF" "https://github.com/$repo" "/build/$PROVIDER_NAME"; \
case $PROVIDER_NAME in \
"garm-provider-k8s") \
export PROVIDER_SUBDIR="cmd/garm-provider-k8s"; \
export PROVIDER_LDFLAGS="-linkmode external -extldflags \"-static\" -s -w"; \
;; \
"garm-provider-linode") \
export PROVIDER_LDFLAGS="-linkmode external -extldflags \"-static\" -s -w"; \
;; \
*) \
export PROVIDER_VERSION=$(git -C /build/$PROVIDER_NAME describe --tags --match='v[0-9]*' --dirty --always); \
export PROVIDER_LDFLAGS="-linkmode external -extldflags \"-static\" -s -w -X main.Version=$PROVIDER_VERSION"; \
;; \
esac; \
cd "/build/$PROVIDER_NAME/$PROVIDER_SUBDIR" \
&& go build -ldflags="$PROVIDER_LDFLAGS" -o /opt/garm/providers.d/$PROVIDER_NAME . \
&& upx /opt/garm/providers.d/$PROVIDER_NAME; \
done
FROM busybox
COPY --from=builder /bin/garm /bin/garm
COPY --from=builder /bin/garm-cli /bin/garm-cli
COPY --from=builder /opt/garm/providers.d/garm-provider-openstack /opt/garm/providers.d/garm-provider-openstack
COPY --from=builder /opt/garm/providers.d/garm-provider-lxd /opt/garm/providers.d/garm-provider-lxd
COPY --from=builder /opt/garm/providers.d/garm-provider-incus /opt/garm/providers.d/garm-provider-incus

View file

@ -6,8 +6,10 @@ export SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit
GEN_PASSWORD=$(shell (/usr/bin/apg -n1 -m32))
IMAGE_TAG = garm-build
USER_ID=$(shell ((docker --version | grep -q podman) && echo "0" || id -u))
USER_GROUP=$(shell ((docker --version | grep -q podman) && echo "0" || id -g))
IMAGE_BUILDER=$(shell (which docker || which podman))
IS_PODMAN=$(shell (($(IMAGE_BUILDER) --version | grep -q podman) && echo "yes" || echo "no"))
USER_ID=$(if $(filter yes,$(IS_PODMAN)),0,$(shell id -u))
USER_GROUP=$(if $(filter yes,$(IS_PODMAN)),0,$(shell id -g))
ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
GOPATH ?= $(shell go env GOPATH)
VERSION ?= $(shell git describe --tags --match='v[0-9]*' --dirty --always)
@ -20,6 +22,11 @@ export CREDENTIALS_NAME ?= test-garm-creds
export WORKFLOW_FILE_NAME ?= test.yml
export GARM_ADMIN_USERNAME ?= admin
ifeq ($(IS_PODMAN),yes)
EXTRA_ARGS := -v /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt
endif
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@ -32,9 +39,9 @@ default: build
.PHONY : build-static test install-lint-deps lint go-test fmt fmtcheck verify-vendor verify create-release-files release
build-static: ## Build garm statically
@echo Building garm
docker build --tag $(IMAGE_TAG) -f Dockerfile.build-static .
$(IMAGE_BUILDER) build $(EXTRA_ARGS) --tag $(IMAGE_TAG) -f Dockerfile.build-static .
mkdir -p build
docker run --rm -e USER_ID=$(USER_ID) -e GARM_REF=$(GARM_REF) -e USER_GROUP=$(USER_GROUP) -v $(PWD)/build:/build/output:z $(IMAGE_TAG) /build-static.sh
$(IMAGE_BUILDER) run --rm -e USER_ID=$(USER_ID) -e GARM_REF=$(GARM_REF) -e USER_GROUP=$(USER_GROUP) -v $(PWD)/build:/build/output:z $(IMAGE_TAG) /build-static.sh
@echo Binaries are available in $(PWD)/build
clean: ## Clean up build artifacts
@ -48,6 +55,20 @@ build: ## Build garm
@$(GO) build -ldflags "-s -w -X github.com/cloudbase/garm/util/appdefaults.Version=${VERSION}" -tags osusergo,netgo,sqlite_omit_load_extension -o bin/garm-cli ./cmd/garm-cli
@echo Binaries are available in $(PWD)/bin
.PHONY: build-webui
build-webui:
@echo Building GARM web ui
./build-webapp.sh
rm -rf webapp/assets/_app
cp -r webapp/build/* webapp/assets/
.PHONY: generate
generate: ## Run go generate after checking required tools are in PATH
@echo Checking required tools...
@which openapi-generator-cli > /dev/null || (echo "Error: openapi-generator-cli not found in PATH" && exit 1)
@echo Running go generate
@$(GO) generate ./...
test: verify go-test ## Run tests
##@ Release
@ -67,7 +88,7 @@ lint-fix: golangci-lint $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixer
verify-vendor: ## verify if all the go.mod/go.sum files are up-to-date
$(eval TMPDIR := $(shell mktemp -d))
@cp -R ${ROOTDIR} ${TMPDIR}
@cp -R ${ROOTDIR} ${TMPDIR}/.
@(cd ${TMPDIR}/garm && ${GO} mod tidy)
@diff -r -u -q ${ROOTDIR} ${TMPDIR}/garm >/dev/null 2>&1; if [ "$$?" -ne 0 ];then echo "please run: go mod tidy && go mod vendor"; exit 1; fi
@rm -rf ${TMPDIR}
@ -94,6 +115,9 @@ go-test: ## Run tests
fmt: ## Run go fmt against code.
@$(GO) fmt $$(go list ./...)
webui-test:
(cd webapp && npm install)
(cd webapp && npm run test:run)
##@ Build Dependencies
@ -106,7 +130,7 @@ $(LOCALBIN):
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
## Tool Versions
GOLANGCI_LINT_VERSION ?= v1.61.0
GOLANGCI_LINT_VERSION ?= v1.64.8
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. If wrong version is installed, it will be overwritten.

View file

@ -1,19 +1,29 @@
<p align="center">
<img src="doc/images/garm-light.svg#gh-light-mode-only" width="384px" alt="Light mode image" />
<img src="doc/images/garm-dark.svg#gh-dark-mode-only" width="384px" alt="Dark mode image" />
</p>
# GitHub Actions Runner Manager (GARM)
[![Go Tests](https://github.com/cloudbase/garm/actions/workflows/go-tests.yml/badge.svg)](https://github.com/cloudbase/garm/actions/workflows/go-tests.yml)
<!-- TOC -->
- [About GARM](#about-garm)
- [Join us on slack](#join-us-on-slack)
- [Installing](#installing)
- [Quickstart](#quickstart)
- [Installing on Kubernetes](#installing-on-kubernetes)
- [Using GARM](#using-garm)
- [Supported providers](#supported-providers)
- [Installing external providers](#installing-external-providers)
- [Optimizing your runners](#optimizing-your-runners)
- [Write your own provider](#write-your-own-provider)
- [GitHub Actions Runner Manager GARM](#github-actions-runner-manager-garm)
- [About GARM](#about-garm)
- [Join us on slack](#join-us-on-slack)
- [Installing](#installing)
- [Quickstart](#quickstart)
- [Installing on Kubernetes](#installing-on-kubernetes)
- [Configuring GARM for GHES](#configuring-garm-for-ghes)
- [Configuring GARM for Gitea](#configuring-garm-for-gitea)
- [Enabling the web UI](#enabling-the-web-ui)
- [Using GARM](#using-garm)
- [Supported providers](#supported-providers)
- [Installing external providers](#installing-external-providers)
- [Optimizing your runners](#optimizing-your-runners)
- [Write your own provider](#write-your-own-provider)
<!-- /TOC -->
@ -21,20 +31,29 @@
Welcome to GARM!
GARM enables you to create and automatically maintain pools of [self-hosted GitHub runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners), with auto-scaling that can be used inside your github workflow runs.
GARM enables you to create and automatically maintain pools of self-hosted runners in both [Github](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) and [Gitea](https://github.com/go-gitea/gitea/) with auto-scaling that can be used inside your workflow runs.
The goal of ```GARM``` is to be simple to set up, simple to configure and simple to use. The server itself is a single binary that can run on any GNU/Linux machine without any other requirements other than the providers you want to enable in your setup. It is intended to be easy to deploy in any environment and can create runners in virtually any system you can write a provider for. There is no complicated setup process and no extremely complex concepts to understand. Once set up, it's meant to stay out of your way.
The goal of ```GARM``` is to be simple to set up, simple to configure and simple to use. The server itself is a single binary that can run on any GNU/Linux machine without any other requirements other than the providers you want to enable in your setup. It is intended to be easy to deploy in any environment and can create runners in virtually any system you can write a provider for (if one does not alreay exist). There is no complicated setup process and no extremely complex concepts to understand. Once set up, it's meant to stay out of your way.
GARM supports creating pools in either GitHub itself or in your own deployment of [GitHub Enterprise Server](https://docs.github.com/en/enterprise-server@3.10/admin/overview/about-github-enterprise-server). For instructions on how to use ```GARM``` with GHE, see the [credentials](/doc/github_credentials.md) section of the documentation.
Through the use of providers, `GARM` can create runners in a variety of environments using the same `GARM` instance. Whether you want to create runners in your OpenStack cloud, your Azure cloud or your Kubernetes cluster, that is easily achieved by installing the appropriate providers, configuring them in `GARM` and creating pools that use them. You can create zero-runner pools for instances with high costs (large VMs, GPU enabled instances, etc) and have them spin up on demand, or you can create large pools of eagerly created k8s backed runners that can be used for your CI/CD pipelines at a moment's notice. You can mix them up and create pools in any combination of providers or resource allocations you want.
Through the use of providers, `GARM` can create runners in a variety of environments using the same `GARM` instance. Whether you want to create pools of runners in your OpenStack cloud, your Azure cloud or your Kubernetes cluster, that is easily achieved by just installing the appropriate providers, configuring them in `GARM` and creating pools that use them. You can create zero-runner pools for instances with high costs (large VMs, GPU enabled instances, etc) and have them spin up on demand, or you can create large pools of eagerly created k8s backed runners that can be used for your CI/CD pipelines at a moment's notice. You can mix them up and create pools in any combination of providers or resource allocations you want.
GARM supports two modes of operation:
Here is a brief architectural diagram of how GARM reacts to workflows triggered in GitHub (click the image to see a larger version):
* Pools
* Scale sets
![GARM architecture diagram](/doc/images/garm-light.drawio.svg?raw=true#gh-light-mode-only)
![GARM architecture diagram](/doc/images/garm-dark.drawio.svg?raw=true#gh-dark-mode-only)
Here is a brief architectural diagram of how pools work and how GARM reacts to workflows triggered in GitHub (click the image to see a larger version):
:warning: **Important note**: The README and documentation in the `main` branch are relevant to the not yet released code that is present in `main`. Following the documentation from the `main` branch for a stable release of GARM, may lead to errors. To view the documentation for the latest stable release, please switch to the appropriate tag. For information about setting up `v0.1.5`, please refer to the [v0.1.5 tag](https://github.com/cloudbase/garm/tree/v0.1.5).
![GARM architecture diagram](/doc/images/garm-light.diagram.svg?raw=true#gh-light-mode-only)
![GARM architecture diagram](/doc/images/garm-dark.diagram.svg?raw=true#gh-dark-mode-only)
**Scale sets** work differently. While pools (as they are defined in GARM) rely on webhooks to know when a job was started and GARM needs to internally make the right decission in terms of which pool should handle that runner, scale sets have a lot of the scheduling and decission making logic done in GitHub itself.
> [!IMPORTANT]
> The README and documentation in the `main` branch are relevant to the not yet released code that is present in `main`. Following the documentation from the `main` branch for a stable release of GARM, may lead to errors. To view the documentation for the latest stable release, please switch to the appropriate tag. For information about setting up `v0.1.6`, please refer to the [v0.1.6 tag](https://github.com/cloudbase/garm/tree/v0.1.6).
> [!CAUTION]
> The `main` branch holds the latest code and is not guaranteed to be stable. If you are looking for a stable release, please check the releases page. If you plan to use the `main` branch, please do so on a new instance. Do not upgrade from a stable release to `main`.
## Join us on slack
@ -52,6 +71,25 @@ Check out the [quickstart](/doc/quickstart.md) document for instructions on how
Thanks to the efforts of the amazing folks at [@mercedes-benz](https://github.com/mercedes-benz/), GARM can now be integrated into k8s via their operator. Check out the [GARM operator](https://github.com/mercedes-benz/garm-operator/) for more details.
## Configuring GARM for GHES
GARM supports creating pools and scale sets in either GitHub itself or in your own deployment of [GitHub Enterprise Server](https://docs.github.com/en/enterprise-server@3.10/admin/overview/about-github-enterprise-server). For instructions on how to use ```GARM``` with GHE, see the [credentials](/doc/github_credentials.md) section of the documentation.
## Configuring GARM for Gitea
GARM now has support for Gitea (>=1.24.0). For information on getting started with Gitea, see the [Gitea quickstart](/doc/gitea.md) document.
## Enabling the web UI
GARM now ships with a single page application. To enable it, add the following to your GARM config:
```toml
[apiserver.webui]
enable = true
```
Check the [README.md](/webapp/README.md) file for details on the web UI.
## Using GARM
GARM is designed with simplicity in mind. At least we try to keep it as simple as possible. We're aware that adding a new tool in your workflow can be painful, especially when you already have to deal with so many. The cognitive load for OPS has reached a level where it feels overwhelming at times to even wrap your head around a new tool. As such, we believe that tools should be simple, should take no more than a few hours to understand and set up and if you absolutely need to interact with the tool, it should be as intuitive as possible. Although we try our best to make this happen, we're aware that GARM has some rough edges, especially for new users. If you encounter issues or feel like the setup process was too complicated, please let us know. We're always looking to improve the user experience.
@ -70,14 +108,15 @@ GARM uses providers to create runners in a particular IaaS. The providers are ex
External providers are binaries that GARM calls into to create runners in a particular IaaS. There are several external providers available:
* [OpenStack](https://github.com/cloudbase/garm-provider-openstack)
* [Akamai/Linode](https://github.com/flatcar/garm-provider-linode) - Experimental
* [Amazon EC2](https://github.com/cloudbase/garm-provider-aws)
* [Azure](https://github.com/cloudbase/garm-provider-azure)
* [Equinix Metal](https://github.com/cloudbase/garm-provider-equinix)
* [Google Cloud Platform (GCP)](https://github.com/cloudbase/garm-provider-gcp)
* [Incus](https://github.com/cloudbase/garm-provider-incus)
* [Kubernetes](https://github.com/mercedes-benz/garm-provider-k8s) - Thanks to the amazing folks at @mercedes-benz for sharing their awesome provider!
* [LXD](https://github.com/cloudbase/garm-provider-lxd)
* [Incus](https://github.com/cloudbase/garm-provider-incus)
* [Equinix Metal](https://github.com/cloudbase/garm-provider-equinix)
* [Amazon EC2](https://github.com/cloudbase/garm-provider-aws)
* [Google Cloud Platform (GCP)](https://github.com/cloudbase/garm-provider-gcp)
* [OpenStack](https://github.com/cloudbase/garm-provider-openstack)
* [Oracle Cloud Infrastructure (OCI)](https://github.com/cloudbase/garm-provider-oci)
Follow the instructions in the README of each provider to install them.

View file

@ -17,30 +17,57 @@ package controllers
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"log/slog"
"net/http"
"net/url"
"strings"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
gErrors "github.com/cloudbase/garm-provider-common/errors"
"github.com/cloudbase/garm-provider-common/util"
"github.com/cloudbase/garm/apiserver/events"
"github.com/cloudbase/garm/apiserver/params"
"github.com/cloudbase/garm/auth"
"github.com/cloudbase/garm/config"
"github.com/cloudbase/garm/metrics"
runnerParams "github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/runner" //nolint:typecheck
garmUtil "github.com/cloudbase/garm/util"
wsWriter "github.com/cloudbase/garm/websocket"
"github.com/cloudbase/garm/workers/websocket/events"
)
func NewAPIController(r *runner.Runner, authenticator *auth.Authenticator, hub *wsWriter.Hub) (*APIController, error) {
func NewAPIController(r *runner.Runner, authenticator *auth.Authenticator, hub *wsWriter.Hub, apiCfg config.APIServer) (*APIController, error) {
controllerInfo, err := r.GetControllerInfo(auth.GetAdminContext(context.Background()))
if err != nil {
return nil, errors.Wrap(err, "failed to get controller info")
return nil, fmt.Errorf("failed to get controller info: %w", err)
}
var checkOrigin func(r *http.Request) bool
if len(apiCfg.CORSOrigins) > 0 {
checkOrigin = func(r *http.Request) bool {
origin := r.Header["Origin"]
if len(origin) == 0 {
return true
}
u, err := url.Parse(origin[0])
if err != nil {
return false
}
for _, val := range apiCfg.CORSOrigins {
corsVal, err := url.Parse(val)
if err != nil {
continue
}
if garmUtil.ASCIIEqualFold(u.Host, corsVal.Host) {
return true
}
}
return false
}
}
return &APIController{
r: r,
@ -49,6 +76,7 @@ func NewAPIController(r *runner.Runner, authenticator *auth.Authenticator, hub *
upgrader: websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 16384,
CheckOrigin: checkOrigin,
},
controllerID: controllerInfo.ControllerID.String(),
}, nil
@ -64,24 +92,22 @@ type APIController struct {
func handleError(ctx context.Context, w http.ResponseWriter, err error) {
w.Header().Set("Content-Type", "application/json")
origErr := errors.Cause(err)
apiErr := params.APIErrorResponse{
Details: origErr.Error(),
Details: err.Error(),
}
switch origErr.(type) {
case *gErrors.NotFoundError:
switch {
case errors.Is(err, gErrors.ErrNotFound):
w.WriteHeader(http.StatusNotFound)
apiErr.Error = "Not Found"
case *gErrors.UnauthorizedError:
case errors.Is(err, gErrors.ErrUnauthorized):
w.WriteHeader(http.StatusUnauthorized)
apiErr.Error = "Not Authorized"
// Don't include details on 401 errors.
apiErr.Details = ""
case *gErrors.BadRequestError:
case errors.Is(err, gErrors.ErrBadRequest):
w.WriteHeader(http.StatusBadRequest)
apiErr.Error = "Bad Request"
case *gErrors.DuplicateUserError, *gErrors.ConflictError:
case errors.Is(err, gErrors.ErrDuplicateEntity), errors.Is(err, &gErrors.ConflictError{}):
w.WriteHeader(http.StatusConflict)
apiErr.Error = "Conflict"
default:
@ -106,8 +132,15 @@ func (a *APIController) handleWorkflowJobEvent(ctx context.Context, w http.Respo
signature := r.Header.Get("X-Hub-Signature-256")
hookType := r.Header.Get("X-Github-Hook-Installation-Target-Type")
giteaTargetType := r.Header.Get("X-Gitea-Hook-Installation-Target-Type")
if err := a.r.DispatchWorkflowJob(hookType, signature, body); err != nil {
forgeType := runnerParams.GithubEndpointType
if giteaTargetType != "" {
forgeType = runnerParams.GiteaEndpointType
hookType = giteaTargetType
}
if err := a.r.DispatchWorkflowJob(hookType, signature, forgeType, body); err != nil {
switch {
case errors.Is(err, gErrors.ErrNotFound):
metrics.WebhooksReceived.WithLabelValues(

View file

@ -66,13 +66,30 @@ func (a *APIController) CreateEnterpriseHandler(w http.ResponseWriter, r *http.R
//
// List all enterprises.
//
// Parameters:
// + name: name
// description: Exact enterprise name to filter by
// type: string
// in: query
// required: false
//
// + name: endpoint
// description: Exact endpoint name to filter by
// type: string
// in: query
// required: false
//
// Responses:
// 200: Enterprises
// default: APIErrorResponse
func (a *APIController) ListEnterprisesHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
enterprise, err := a.r.ListEnterprises(ctx)
filter := runnerParams.EnterpriseFilter{
Name: r.URL.Query().Get("name"),
Endpoint: r.URL.Query().Get("endpoint"),
}
enterprise, err := a.r.ListEnterprises(ctx, filter)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing enterprise")
handleError(ctx, w, err)
@ -277,6 +294,62 @@ func (a *APIController) CreateEnterprisePoolHandler(w http.ResponseWriter, r *ht
}
}
// swagger:route POST /enterprises/{enterpriseID}/scalesets enterprises scalesets CreateEnterpriseScaleSet
//
// Create enterprise pool with the parameters given.
//
// Parameters:
// + name: enterpriseID
// description: Enterprise ID.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when creating the enterprise scale set.
// type: CreateScaleSetParams
// in: body
// required: true
//
// Responses:
// 200: ScaleSet
// default: APIErrorResponse
func (a *APIController) CreateEnterpriseScaleSetHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
enterpriseID, ok := vars["enterpriseID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No enterprise ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
var scaleSetData runnerParams.CreateScaleSetParams
if err := json.NewDecoder(r.Body).Decode(&scaleSetData); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to decode")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
scaleSet, err := a.r.CreateEntityScaleSet(ctx, runnerParams.ForgeEntityTypeEnterprise, enterpriseID, scaleSetData)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "error creating enterprise scale set")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scaleSet); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /enterprises/{enterpriseID}/pools enterprises pools ListEnterprisePools
//
// List enterprise pools.
@ -319,6 +392,48 @@ func (a *APIController) ListEnterprisePoolsHandler(w http.ResponseWriter, r *htt
}
}
// swagger:route GET /enterprises/{enterpriseID}/scalesets enterprises scalesets ListEnterpriseScaleSets
//
// List enterprise scale sets.
//
// Parameters:
// + name: enterpriseID
// description: Enterprise ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: ScaleSets
// default: APIErrorResponse
func (a *APIController) ListEnterpriseScaleSetsHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
enterpriseID, ok := vars["enterpriseID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No enterprise ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
scaleSets, err := a.r.ListEntityScaleSets(ctx, runnerParams.ForgeEntityTypeEnterprise, enterpriseID)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing scale sets")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scaleSets); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /enterprises/{enterpriseID}/pools/{poolID} enterprises pools GetEnterprisePool
//
// Get enterprise pool by ID.

View file

@ -0,0 +1,241 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package controllers
import (
"encoding/json"
"log/slog"
"math"
"net/http"
"strconv"
"github.com/gorilla/mux"
gErrors "github.com/cloudbase/garm-provider-common/errors"
"github.com/cloudbase/garm/params"
)
// swagger:route GET /gitea/credentials credentials ListGiteaCredentials
//
// List all credentials.
//
// Responses:
// 200: Credentials
// 400: APIErrorResponse
func (a *APIController) ListGiteaCredentials(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
creds, err := a.r.ListGiteaCredentials(ctx)
if err != nil {
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(creds); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route POST /gitea/credentials credentials CreateGiteaCredentials
//
// Create a Gitea credential.
//
// Parameters:
// + name: Body
// description: Parameters used when creating a Gitea credential.
// type: CreateGiteaCredentialsParams
// in: body
// required: true
//
// Responses:
// 200: ForgeCredentials
// 400: APIErrorResponse
func (a *APIController) CreateGiteaCredential(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var params params.CreateGiteaCredentialsParams
if err := json.NewDecoder(r.Body).Decode(&params); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to decode request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
cred, err := a.r.CreateGiteaCredentials(ctx, params)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to create Gitea credential")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(cred); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /gitea/credentials/{id} credentials GetGiteaCredentials
//
// Get a Gitea credential.
//
// Parameters:
// + name: id
// description: ID of the Gitea credential.
// type: integer
// in: path
// required: true
//
// Responses:
// 200: ForgeCredentials
// 400: APIErrorResponse
func (a *APIController) GetGiteaCredential(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
idParam, ok := vars["id"]
if !ok {
slog.ErrorContext(ctx, "missing id in request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
id, err := strconv.ParseUint(idParam, 10, 64)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to parse id")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
if id > math.MaxUint {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "id is too large")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
cred, err := a.r.GetGiteaCredentials(ctx, uint(id))
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to get Gitea credential")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(cred); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route DELETE /gitea/credentials/{id} credentials DeleteGiteaCredentials
//
// Delete a Gitea credential.
//
// Parameters:
// + name: id
// description: ID of the Gitea credential.
// type: integer
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteGiteaCredential(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
idParam, ok := vars["id"]
if !ok {
slog.ErrorContext(ctx, "missing id in request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
id, err := strconv.ParseUint(idParam, 10, 64)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to parse id")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
if id > math.MaxUint {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "id is too large")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
if err := a.r.DeleteGiteaCredentials(ctx, uint(id)); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to delete Gitea credential")
handleError(ctx, w, err)
return
}
w.WriteHeader(http.StatusNoContent)
}
// swagger:route PUT /gitea/credentials/{id} credentials UpdateGiteaCredentials
//
// Update a Gitea credential.
//
// Parameters:
// + name: id
// description: ID of the Gitea credential.
// type: integer
// in: path
// required: true
// + name: Body
// description: Parameters used when updating a Gitea credential.
// type: UpdateGiteaCredentialsParams
// in: body
// required: true
//
// Responses:
// 200: ForgeCredentials
// 400: APIErrorResponse
func (a *APIController) UpdateGiteaCredential(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
idParam, ok := vars["id"]
if !ok {
slog.ErrorContext(ctx, "missing id in request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
id, err := strconv.ParseUint(idParam, 10, 64)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to parse id")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
if id > math.MaxUint {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "id is too large")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
var params params.UpdateGiteaCredentialsParams
if err := json.NewDecoder(r.Body).Decode(&params); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to decode request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
cred, err := a.r.UpdateGiteaCredentials(ctx, uint(id), params)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to update Gitea credential")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(cred); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}

View file

@ -0,0 +1,199 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package controllers
import (
"encoding/json"
"log/slog"
"net/http"
"github.com/gorilla/mux"
gErrors "github.com/cloudbase/garm-provider-common/errors"
"github.com/cloudbase/garm/params"
)
// swagger:route POST /gitea/endpoints endpoints CreateGiteaEndpoint
//
// Create a Gitea Endpoint.
//
// Parameters:
// + name: Body
// description: Parameters used when creating a Gitea endpoint.
// type: CreateGiteaEndpointParams
// in: body
// required: true
//
// Responses:
// 200: ForgeEndpoint
// default: APIErrorResponse
func (a *APIController) CreateGiteaEndpoint(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var params params.CreateGiteaEndpointParams
if err := json.NewDecoder(r.Body).Decode(&params); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to decode request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
endpoint, err := a.r.CreateGiteaEndpoint(ctx, params)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to create Gitea endpoint")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(endpoint); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /gitea/endpoints endpoints ListGiteaEndpoints
//
// List all Gitea Endpoints.
//
// Responses:
// 200: ForgeEndpoints
// default: APIErrorResponse
func (a *APIController) ListGiteaEndpoints(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
endpoints, err := a.r.ListGiteaEndpoints(ctx)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to list Gitea endpoints")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(endpoints); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /gitea/endpoints/{name} endpoints GetGiteaEndpoint
//
// Get a Gitea Endpoint.
//
// Parameters:
// + name: name
// description: The name of the Gitea endpoint.
// type: string
// in: path
// required: true
//
// Responses:
// 200: ForgeEndpoint
// default: APIErrorResponse
func (a *APIController) GetGiteaEndpoint(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
name, ok := vars["name"]
if !ok {
slog.ErrorContext(ctx, "missing name in request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
endpoint, err := a.r.GetGiteaEndpoint(ctx, name)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to get Gitea endpoint")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(endpoint); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route DELETE /gitea/endpoints/{name} endpoints DeleteGiteaEndpoint
//
// Delete a Gitea Endpoint.
//
// Parameters:
// + name: name
// description: The name of the Gitea endpoint.
// type: string
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteGiteaEndpoint(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
name, ok := vars["name"]
if !ok {
slog.ErrorContext(ctx, "missing name in request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
if err := a.r.DeleteGiteaEndpoint(ctx, name); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to delete Gitea endpoint")
handleError(ctx, w, err)
return
}
w.WriteHeader(http.StatusNoContent)
}
// swagger:route PUT /gitea/endpoints/{name} endpoints UpdateGiteaEndpoint
//
// Update a Gitea Endpoint.
//
// Parameters:
// + name: name
// description: The name of the Gitea endpoint.
// type: string
// in: path
// required: true
// + name: Body
// description: Parameters used when updating a Gitea endpoint.
// type: UpdateGiteaEndpointParams
// in: body
// required: true
//
// Responses:
// 200: ForgeEndpoint
// default: APIErrorResponse
func (a *APIController) UpdateGiteaEndpoint(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
name, ok := vars["name"]
if !ok {
slog.ErrorContext(ctx, "missing name in request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
var params params.UpdateGiteaEndpointParams
if err := json.NewDecoder(r.Body).Decode(&params); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to decode request")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
endpoint, err := a.r.UpdateGiteaEndpoint(ctx, name, params)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to update GitHub endpoint")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(endpoint); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}

View file

@ -1,3 +1,16 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package controllers
import (
@ -47,7 +60,7 @@ func (a *APIController) ListCredentials(w http.ResponseWriter, r *http.Request)
// required: true
//
// Responses:
// 200: GithubCredentials
// 200: ForgeCredentials
// 400: APIErrorResponse
func (a *APIController) CreateGithubCredential(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -83,7 +96,7 @@ func (a *APIController) CreateGithubCredential(w http.ResponseWriter, r *http.Re
// required: true
//
// Responses:
// 200: GithubCredentials
// 200: ForgeCredentials
// 400: APIErrorResponse
func (a *APIController) GetGithubCredential(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -183,7 +196,7 @@ func (a *APIController) DeleteGithubCredential(w http.ResponseWriter, r *http.Re
// required: true
//
// Responses:
// 200: GithubCredentials
// 200: ForgeCredentials
// 400: APIErrorResponse
func (a *APIController) UpdateGithubCredential(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

View file

@ -1,3 +1,16 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package controllers
import (
@ -23,7 +36,7 @@ import (
// required: true
//
// Responses:
// 200: GithubEndpoint
// 200: ForgeEndpoint
// default: APIErrorResponse
func (a *APIController) CreateGithubEndpoint(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -52,7 +65,7 @@ func (a *APIController) CreateGithubEndpoint(w http.ResponseWriter, r *http.Requ
// List all GitHub Endpoints.
//
// Responses:
// 200: GithubEndpoints
// 200: ForgeEndpoints
// default: APIErrorResponse
func (a *APIController) ListGithubEndpoints(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -81,7 +94,7 @@ func (a *APIController) ListGithubEndpoints(w http.ResponseWriter, r *http.Reque
// required: true
//
// Responses:
// 200: GithubEndpoint
// 200: ForgeEndpoint
// default: APIErrorResponse
func (a *APIController) GetGithubEndpoint(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -153,7 +166,7 @@ func (a *APIController) DeleteGithubEndpoint(w http.ResponseWriter, r *http.Requ
// required: true
//
// Responses:
// 200: GithubEndpoint
// 200: ForgeEndpoint
// default: APIErrorResponse
func (a *APIController) UpdateGithubEndpoint(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

View file

@ -69,6 +69,54 @@ func (a *APIController) ListPoolInstancesHandler(w http.ResponseWriter, r *http.
}
}
// swagger:route GET /scalesets/{scalesetID}/instances instances ListScaleSetInstances
//
// List runner instances in a scale set.
//
// Parameters:
// + name: scalesetID
// description: Runner scale set ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Instances
// default: APIErrorResponse
func (a *APIController) ListScaleSetInstancesHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
scalesetID, ok := vars["scalesetID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No pool ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
id, err := strconv.ParseUint(scalesetID, 10, 32)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to parse id")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
instances, err := a.r.ListScaleSetInstances(ctx, uint(id))
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing pool instances")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(instances); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /instances/{instanceName} instances GetInstance
//
// Get runner instance by name.

View file

@ -67,13 +67,30 @@ func (a *APIController) CreateOrgHandler(w http.ResponseWriter, r *http.Request)
//
// List organizations.
//
// Parameters:
// + name: name
// description: Exact organization name to filter by
// type: string
// in: query
// required: false
//
// + name: endpoint
// description: Exact endpoint name to filter by
// type: string
// in: query
// required: false
//
// Responses:
// 200: Organizations
// default: APIErrorResponse
func (a *APIController) ListOrgsHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
orgs, err := a.r.ListOrganizations(ctx)
filter := runnerParams.OrganizationFilter{
Name: r.URL.Query().Get("name"),
Endpoint: r.URL.Query().Get("endpoint"),
}
orgs, err := a.r.ListOrganizations(ctx, filter)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing orgs")
handleError(ctx, w, err)
@ -287,6 +304,62 @@ func (a *APIController) CreateOrgPoolHandler(w http.ResponseWriter, r *http.Requ
}
}
// swagger:route POST /organizations/{orgID}/scalesets organizations scalesets CreateOrgScaleSet
//
// Create organization scale set with the parameters given.
//
// Parameters:
// + name: orgID
// description: Organization ID.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when creating the organization scale set.
// type: CreateScaleSetParams
// in: body
// required: true
//
// Responses:
// 200: ScaleSet
// default: APIErrorResponse
func (a *APIController) CreateOrgScaleSetHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
orgID, ok := vars["orgID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No org ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
var scalesetData runnerParams.CreateScaleSetParams
if err := json.NewDecoder(r.Body).Decode(&scalesetData); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to decode")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
scaleSet, err := a.r.CreateEntityScaleSet(ctx, runnerParams.ForgeEntityTypeOrganization, orgID, scalesetData)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "error creating organization scale set")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scaleSet); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /organizations/{orgID}/pools organizations pools ListOrgPools
//
// List organization pools.
@ -329,6 +402,48 @@ func (a *APIController) ListOrgPoolsHandler(w http.ResponseWriter, r *http.Reque
}
}
// swagger:route GET /organizations/{orgID}/scalesets organizations scalesets ListOrgScaleSets
//
// List organization scale sets.
//
// Parameters:
// + name: orgID
// description: Organization ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: ScaleSets
// default: APIErrorResponse
func (a *APIController) ListOrgScaleSetsHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
orgID, ok := vars["orgID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No org ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
scaleSets, err := a.r.ListEntityScaleSets(ctx, runnerParams.ForgeEntityTypeOrganization, orgID)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing scale sets")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scaleSets); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /organizations/{orgID}/pools/{poolID} organizations pools GetOrgPool
//
// Get organization pool by ID.

View file

@ -67,13 +67,37 @@ func (a *APIController) CreateRepoHandler(w http.ResponseWriter, r *http.Request
//
// List repositories.
//
// Parameters:
// + name: owner
// description: Exact owner name to filter by
// type: string
// in: query
// required: false
//
// + name: name
// description: Exact repository name to filter by
// type: string
// in: query
// required: false
//
// + name: endpoint
// description: Exact endpoint name to filter by
// type: string
// in: query
// required: false
//
// Responses:
// 200: Repositories
// default: APIErrorResponse
func (a *APIController) ListReposHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
repos, err := a.r.ListRepositories(ctx)
filter := runnerParams.RepositoryFilter{
Name: r.URL.Query().Get("name"),
Owner: r.URL.Query().Get("owner"),
Endpoint: r.URL.Query().Get("endpoint"),
}
repos, err := a.r.ListRepositories(ctx, filter)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing repositories")
handleError(ctx, w, err)
@ -286,6 +310,62 @@ func (a *APIController) CreateRepoPoolHandler(w http.ResponseWriter, r *http.Req
}
}
// swagger:route POST /repositories/{repoID}/scalesets repositories scalesets CreateRepoScaleSet
//
// Create repository scale set with the parameters given.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when creating the repository scale set.
// type: CreateScaleSetParams
// in: body
// required: true
//
// Responses:
// 200: ScaleSet
// default: APIErrorResponse
func (a *APIController) CreateRepoScaleSetHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
repoID, ok := vars["repoID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No repo ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
var scaleSetData runnerParams.CreateScaleSetParams
if err := json.NewDecoder(r.Body).Decode(&scaleSetData); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to decode")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
scaleSet, err := a.r.CreateEntityScaleSet(ctx, runnerParams.ForgeEntityTypeRepository, repoID, scaleSetData)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "error creating repository scale set")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scaleSet); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /repositories/{repoID}/pools repositories pools ListRepoPools
//
// List repository pools.
@ -328,6 +408,48 @@ func (a *APIController) ListRepoPoolsHandler(w http.ResponseWriter, r *http.Requ
}
}
// swagger:route GET /repositories/{repoID}/scalesets repositories scalesets ListRepoScaleSets
//
// List repository scale sets.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: ScaleSets
// default: APIErrorResponse
func (a *APIController) ListRepoScaleSetsHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
repoID, ok := vars["repoID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No repo ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
scaleSets, err := a.r.ListEntityScaleSets(ctx, runnerParams.ForgeEntityTypeRepository, repoID)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing scale sets")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scaleSets); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /repositories/{repoID}/pools/{poolID} repositories pools GetRepoPool
//
// Get repository pool by ID.

View file

@ -0,0 +1,211 @@
// Copyright 2022 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package controllers
import (
"encoding/json"
"log/slog"
"net/http"
"strconv"
"github.com/gorilla/mux"
gErrors "github.com/cloudbase/garm-provider-common/errors"
"github.com/cloudbase/garm/apiserver/params"
runnerParams "github.com/cloudbase/garm/params"
)
// swagger:route GET /scalesets scalesets ListScalesets
//
// List all scalesets.
//
// Responses:
// 200: ScaleSets
// default: APIErrorResponse
func (a *APIController) ListAllScaleSetsHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
scalesets, err := a.r.ListAllScaleSets(ctx)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing scale sets")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scalesets); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route GET /scalesets/{scalesetID} scalesets GetScaleSet
//
// Get scale set by ID.
//
// Parameters:
// + name: scalesetID
// description: ID of the scale set to fetch.
// type: string
// in: path
// required: true
//
// Responses:
// 200: ScaleSet
// default: APIErrorResponse
func (a *APIController) GetScaleSetByIDHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
scaleSetID, ok := vars["scalesetID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No scale set ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
id, err := strconv.ParseUint(scaleSetID, 10, 32)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to parse id")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
scaleSet, err := a.r.GetScaleSetByID(ctx, uint(id))
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "fetching scale set")
handleError(ctx, w, err)
return
}
scaleSet.RunnerBootstrapTimeout = scaleSet.RunnerTimeout()
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scaleSet); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}
// swagger:route DELETE /scalesets/{scalesetID} scalesets DeleteScaleSet
//
// Delete scale set by ID.
//
// Parameters:
// + name: scalesetID
// description: ID of the scale set to delete.
// type: string
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteScaleSetByIDHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
scalesetID, ok := vars["scalesetID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No scale set ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
id, err := strconv.ParseUint(scalesetID, 10, 32)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to parse id")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
if err := a.r.DeleteScaleSetByID(ctx, uint(id)); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "removing scale set")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
}
// swagger:route PUT /scalesets/{scalesetID} scalesets UpdateScaleSet
//
// Update scale set by ID.
//
// Parameters:
// + name: scalesetID
// description: ID of the scale set to update.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters to update the scale set with.
// type: UpdateScaleSetParams
// in: body
// required: true
//
// Responses:
// 200: ScaleSet
// default: APIErrorResponse
func (a *APIController) UpdateScaleSetByIDHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
scalesetID, ok := vars["scalesetID"]
if !ok {
w.WriteHeader(http.StatusBadRequest)
if err := json.NewEncoder(w).Encode(params.APIErrorResponse{
Error: "Bad Request",
Details: "No scale set ID specified",
}); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
return
}
id, err := strconv.ParseUint(scalesetID, 10, 32)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to parse id")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
var scaleSetData runnerParams.UpdateScaleSetParams
if err := json.NewDecoder(r.Body).Decode(&scaleSetData); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to decode")
handleError(ctx, w, gErrors.ErrBadRequest)
return
}
scaleSet, err := a.r.UpdateScaleSetByID(ctx, uint(id), scaleSetData)
if err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "updating scale set")
handleError(ctx, w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(scaleSet); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
}
}

View file

@ -14,6 +14,7 @@
package params
// swagger:model APIErrorResponse
// APIErrorResponse holds information about an error, returned by the API
type APIErrorResponse struct {
Error string `json:"error"`

View file

@ -57,6 +57,8 @@ import (
"github.com/cloudbase/garm/apiserver/controllers"
"github.com/cloudbase/garm/auth"
"github.com/cloudbase/garm/config"
spaAssets "github.com/cloudbase/garm/webapp/assets"
)
func WithMetricsRouter(parentRouter *mux.Router, disableAuth bool, metricsMiddlerware auth.Middleware) *mux.Router {
@ -82,6 +84,30 @@ func WithDebugServer(parentRouter *mux.Router) *mux.Router {
return parentRouter
}
func WithWebUI(parentRouter *mux.Router, apiConfig config.APIServer) *mux.Router {
if parentRouter == nil {
return nil
}
if apiConfig.WebUI.EnableWebUI {
slog.Info("WebUI is enabled, adding webapp routes")
webappPath := apiConfig.WebUI.GetWebappPath()
slog.Info("Using webapp path", "path", webappPath)
// Accessing / should redirect to the UI
parentRouter.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, webappPath, http.StatusMovedPermanently) // 301
})
// Serve the SPA with dynamic path
parentRouter.PathPrefix(webappPath).HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
spaAssets.ServeSPAWithPath(w, r, webappPath)
}).Methods("GET")
} else {
slog.Info("WebUI is disabled, skipping webapp routes")
}
return parentRouter
}
func requestLogger(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// gathers metrics from the upstream handlers
@ -214,6 +240,25 @@ func NewAPIRouter(han *controllers.APIController, authMiddleware, initMiddleware
apiRouter.Handle("/pools/{poolID}/instances/", http.HandlerFunc(han.ListPoolInstancesHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/pools/{poolID}/instances", http.HandlerFunc(han.ListPoolInstancesHandler)).Methods("GET", "OPTIONS")
////////////////
// Scale sets //
////////////////
// List all pools
apiRouter.Handle("/scalesets/", http.HandlerFunc(han.ListAllScaleSetsHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/scalesets", http.HandlerFunc(han.ListAllScaleSetsHandler)).Methods("GET", "OPTIONS")
// Get one pool
apiRouter.Handle("/scalesets/{scalesetID}/", http.HandlerFunc(han.GetScaleSetByIDHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/scalesets/{scalesetID}", http.HandlerFunc(han.GetScaleSetByIDHandler)).Methods("GET", "OPTIONS")
// Delete one pool
apiRouter.Handle("/scalesets/{scalesetID}/", http.HandlerFunc(han.DeleteScaleSetByIDHandler)).Methods("DELETE", "OPTIONS")
apiRouter.Handle("/scalesets/{scalesetID}", http.HandlerFunc(han.DeleteScaleSetByIDHandler)).Methods("DELETE", "OPTIONS")
// Update one pool
apiRouter.Handle("/scalesets/{scalesetID}/", http.HandlerFunc(han.UpdateScaleSetByIDHandler)).Methods("PUT", "OPTIONS")
apiRouter.Handle("/scalesets/{scalesetID}", http.HandlerFunc(han.UpdateScaleSetByIDHandler)).Methods("PUT", "OPTIONS")
// List pool instances
apiRouter.Handle("/scalesets/{scalesetID}/instances/", http.HandlerFunc(han.ListScaleSetInstancesHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/scalesets/{scalesetID}/instances", http.HandlerFunc(han.ListScaleSetInstancesHandler)).Methods("GET", "OPTIONS")
/////////////
// Runners //
/////////////
@ -246,6 +291,14 @@ func NewAPIRouter(han *controllers.APIController, authMiddleware, initMiddleware
apiRouter.Handle("/repositories/{repoID}/pools/", http.HandlerFunc(han.CreateRepoPoolHandler)).Methods("POST", "OPTIONS")
apiRouter.Handle("/repositories/{repoID}/pools", http.HandlerFunc(han.CreateRepoPoolHandler)).Methods("POST", "OPTIONS")
// Create scale set
apiRouter.Handle("/repositories/{repoID}/scalesets/", http.HandlerFunc(han.CreateRepoScaleSetHandler)).Methods("POST", "OPTIONS")
apiRouter.Handle("/repositories/{repoID}/scalesets", http.HandlerFunc(han.CreateRepoScaleSetHandler)).Methods("POST", "OPTIONS")
// List scale sets
apiRouter.Handle("/repositories/{repoID}/scalesets/", http.HandlerFunc(han.ListRepoScaleSetsHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/repositories/{repoID}/scalesets", http.HandlerFunc(han.ListRepoScaleSetsHandler)).Methods("GET", "OPTIONS")
// Repo instances list
apiRouter.Handle("/repositories/{repoID}/instances/", http.HandlerFunc(han.ListRepoInstancesHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/repositories/{repoID}/instances", http.HandlerFunc(han.ListRepoInstancesHandler)).Methods("GET", "OPTIONS")
@ -296,6 +349,14 @@ func NewAPIRouter(han *controllers.APIController, authMiddleware, initMiddleware
apiRouter.Handle("/organizations/{orgID}/pools/", http.HandlerFunc(han.CreateOrgPoolHandler)).Methods("POST", "OPTIONS")
apiRouter.Handle("/organizations/{orgID}/pools", http.HandlerFunc(han.CreateOrgPoolHandler)).Methods("POST", "OPTIONS")
// Create org scale set
apiRouter.Handle("/organizations/{orgID}/scalesets/", http.HandlerFunc(han.CreateOrgScaleSetHandler)).Methods("POST", "OPTIONS")
apiRouter.Handle("/organizations/{orgID}/scalesets", http.HandlerFunc(han.CreateOrgScaleSetHandler)).Methods("POST", "OPTIONS")
// List org scale sets
apiRouter.Handle("/organizations/{orgID}/scalesets/", http.HandlerFunc(han.ListOrgScaleSetsHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/organizations/{orgID}/scalesets", http.HandlerFunc(han.ListOrgScaleSetsHandler)).Methods("GET", "OPTIONS")
// Org instances list
apiRouter.Handle("/organizations/{orgID}/instances/", http.HandlerFunc(han.ListOrgInstancesHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/organizations/{orgID}/instances", http.HandlerFunc(han.ListOrgInstancesHandler)).Methods("GET", "OPTIONS")
@ -346,6 +407,14 @@ func NewAPIRouter(han *controllers.APIController, authMiddleware, initMiddleware
apiRouter.Handle("/enterprises/{enterpriseID}/pools/", http.HandlerFunc(han.CreateEnterprisePoolHandler)).Methods("POST", "OPTIONS")
apiRouter.Handle("/enterprises/{enterpriseID}/pools", http.HandlerFunc(han.CreateEnterprisePoolHandler)).Methods("POST", "OPTIONS")
// Create enterprise scale sets
apiRouter.Handle("/enterprises/{enterpriseID}/scalesets/", http.HandlerFunc(han.CreateEnterpriseScaleSetHandler)).Methods("POST", "OPTIONS")
apiRouter.Handle("/enterprises/{enterpriseID}/scalesets", http.HandlerFunc(han.CreateEnterpriseScaleSetHandler)).Methods("POST", "OPTIONS")
// List enterprise scale sets
apiRouter.Handle("/enterprises/{enterpriseID}/scalesets/", http.HandlerFunc(han.ListEnterpriseScaleSetsHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/enterprises/{enterpriseID}/scalesets", http.HandlerFunc(han.ListEnterpriseScaleSetsHandler)).Methods("GET", "OPTIONS")
// Enterprise instances list
apiRouter.Handle("/enterprises/{enterpriseID}/instances/", http.HandlerFunc(han.ListEnterpriseInstancesHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/enterprises/{enterpriseID}/instances", http.HandlerFunc(han.ListEnterpriseInstancesHandler)).Methods("GET", "OPTIONS")
@ -411,6 +480,44 @@ func NewAPIRouter(han *controllers.APIController, authMiddleware, initMiddleware
apiRouter.Handle("/github/credentials/{id}/", http.HandlerFunc(han.UpdateGithubCredential)).Methods("PUT", "OPTIONS")
apiRouter.Handle("/github/credentials/{id}", http.HandlerFunc(han.UpdateGithubCredential)).Methods("PUT", "OPTIONS")
//////////////////////
// Gitea Endpoints //
//////////////////////
// Create Gitea Endpoint
apiRouter.Handle("/gitea/endpoints/", http.HandlerFunc(han.CreateGiteaEndpoint)).Methods("POST", "OPTIONS")
apiRouter.Handle("/gitea/endpoints", http.HandlerFunc(han.CreateGiteaEndpoint)).Methods("POST", "OPTIONS")
// List Gitea Endpoints
apiRouter.Handle("/gitea/endpoints/", http.HandlerFunc(han.ListGiteaEndpoints)).Methods("GET", "OPTIONS")
apiRouter.Handle("/gitea/endpoints", http.HandlerFunc(han.ListGiteaEndpoints)).Methods("GET", "OPTIONS")
// Get Gitea Endpoint
apiRouter.Handle("/gitea/endpoints/{name}/", http.HandlerFunc(han.GetGiteaEndpoint)).Methods("GET", "OPTIONS")
apiRouter.Handle("/gitea/endpoints/{name}", http.HandlerFunc(han.GetGiteaEndpoint)).Methods("GET", "OPTIONS")
// Delete Gitea Endpoint
apiRouter.Handle("/gitea/endpoints/{name}/", http.HandlerFunc(han.DeleteGiteaEndpoint)).Methods("DELETE", "OPTIONS")
apiRouter.Handle("/gitea/endpoints/{name}", http.HandlerFunc(han.DeleteGiteaEndpoint)).Methods("DELETE", "OPTIONS")
// Update Gitea Endpoint
apiRouter.Handle("/gitea/endpoints/{name}/", http.HandlerFunc(han.UpdateGiteaEndpoint)).Methods("PUT", "OPTIONS")
apiRouter.Handle("/gitea/endpoints/{name}", http.HandlerFunc(han.UpdateGiteaEndpoint)).Methods("PUT", "OPTIONS")
////////////////////////
// Gitea credentials //
////////////////////////
// List Gitea Credentials
apiRouter.Handle("/gitea/credentials/", http.HandlerFunc(han.ListGiteaCredentials)).Methods("GET", "OPTIONS")
apiRouter.Handle("/gitea/credentials", http.HandlerFunc(han.ListGiteaCredentials)).Methods("GET", "OPTIONS")
// Create Gitea Credentials
apiRouter.Handle("/gitea/credentials/", http.HandlerFunc(han.CreateGiteaCredential)).Methods("POST", "OPTIONS")
apiRouter.Handle("/gitea/credentials", http.HandlerFunc(han.CreateGiteaCredential)).Methods("POST", "OPTIONS")
// Get Gitea Credential
apiRouter.Handle("/gitea/credentials/{id}/", http.HandlerFunc(han.GetGiteaCredential)).Methods("GET", "OPTIONS")
apiRouter.Handle("/gitea/credentials/{id}", http.HandlerFunc(han.GetGiteaCredential)).Methods("GET", "OPTIONS")
// Delete Gitea Credential
apiRouter.Handle("/gitea/credentials/{id}/", http.HandlerFunc(han.DeleteGiteaCredential)).Methods("DELETE", "OPTIONS")
apiRouter.Handle("/gitea/credentials/{id}", http.HandlerFunc(han.DeleteGiteaCredential)).Methods("DELETE", "OPTIONS")
// Update Gitea Credential
apiRouter.Handle("/gitea/credentials/{id}/", http.HandlerFunc(han.UpdateGiteaCredential)).Methods("PUT", "OPTIONS")
apiRouter.Handle("/gitea/credentials/{id}", http.HandlerFunc(han.UpdateGiteaCredential)).Methods("PUT", "OPTIONS")
/////////////////////////
// Websocket endpoints //
/////////////////////////
@ -424,7 +531,7 @@ func NewAPIRouter(han *controllers.APIController, authMiddleware, initMiddleware
apiRouter.Handle("/ws/events/", http.HandlerFunc(han.EventsHandler)).Methods("GET")
apiRouter.Handle("/ws/events", http.HandlerFunc(han.EventsHandler)).Methods("GET")
// NotFound handler
// NotFound handler - this should be last
apiRouter.PathPrefix("/").HandlerFunc(han.NotFoundHandler).Methods("GET", "POST", "PUT", "DELETE", "OPTIONS")
return router
}

View file

@ -74,11 +74,11 @@ definitions:
package: github.com/cloudbase/garm/params
alias: garm_params
items:
$ref: '#/definitions/GithubCredentials'
GithubCredentials:
$ref: '#/definitions/ForgeCredentials'
ForgeCredentials:
type: object
x-go-type:
type: GithubCredentials
type: ForgeCredentials
import:
package: github.com/cloudbase/garm/params
alias: garm_params
@ -130,6 +130,22 @@ definitions:
import:
package: github.com/cloudbase/garm/params
alias: garm_params
ScaleSets:
type: array
x-go-type:
type: ScaleSets
import:
package: github.com/cloudbase/garm/params
alias: garm_params
items:
$ref: '#/definitions/ScaleSet'
ScaleSet:
type: object
x-go-type:
type: ScaleSet
import:
package: github.com/cloudbase/garm/params
alias: garm_params
Repositories:
type: array
x-go-type:
@ -213,6 +229,13 @@ definitions:
import:
package: github.com/cloudbase/garm/params
alias: garm_params
CreateScaleSetParams:
type: object
x-go-type:
type: CreateScaleSetParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
UpdatePoolParams:
type: object
x-go-type:
@ -220,6 +243,13 @@ definitions:
import:
package: github.com/cloudbase/garm/params
alias: garm_params
UpdateScaleSetParams:
type: object
x-go-type:
type: UpdateScaleSetParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
APIErrorResponse:
type: object
x-go-type:
@ -241,22 +271,29 @@ definitions:
import:
package: github.com/cloudbase/garm/params
alias: garm_params
GithubEndpoint:
UpdateGiteaEndpointParams:
type: object
x-go-type:
type: GithubEndpoint
type: UpdateGiteaEndpointParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
GithubEndpoints:
ForgeEndpoint:
type: object
x-go-type:
type: ForgeEndpoint
import:
package: github.com/cloudbase/garm/params
alias: garm_params
ForgeEndpoints:
type: array
x-go-type:
type: GithubEndpoints
type: ForgeEndpoints
import:
package: github.com/cloudbase/garm/params
alias: garm_params
items:
$ref: '#/definitions/GithubEndpoint'
$ref: '#/definitions/ForgeEndpoint'
CreateGithubEndpointParams:
type: object
x-go-type:
@ -264,6 +301,13 @@ definitions:
import:
package: github.com/cloudbase/garm/params
alias: garm_params
CreateGiteaEndpointParams:
type: object
x-go-type:
type: CreateGiteaEndpointParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
CreateGithubCredentialsParams:
type: object
x-go-type:
@ -271,6 +315,13 @@ definitions:
import:
package: github.com/cloudbase/garm/params
alias: garm_params
CreateGiteaCredentialsParams:
type: object
x-go-type:
type: CreateGiteaCredentialsParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
UpdateGithubCredentialsParams:
type: object
x-go-type:
@ -278,6 +329,13 @@ definitions:
import:
package: github.com/cloudbase/garm/params
alias: garm_params
UpdateGiteaCredentialsParams:
type: object
x-go-type:
type: UpdateGiteaCredentialsParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
UpdateControllerParams:
type: object
x-go-type:

View file

@ -23,6 +23,20 @@ definitions:
alias: garm_params
package: github.com/cloudbase/garm/params
type: CreateEnterpriseParams
CreateGiteaCredentialsParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: CreateGiteaCredentialsParams
CreateGiteaEndpointParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: CreateGiteaEndpointParams
CreateGithubCredentialsParams:
type: object
x-go-type:
@ -65,9 +79,16 @@ definitions:
alias: garm_params
package: github.com/cloudbase/garm/params
type: CreateRepoParams
CreateScaleSetParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: CreateScaleSetParams
Credentials:
items:
$ref: '#/definitions/GithubCredentials'
$ref: '#/definitions/ForgeCredentials'
type: array
x-go-type:
import:
@ -90,29 +111,29 @@ definitions:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Enterprises
GithubCredentials:
ForgeCredentials:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: GithubCredentials
GithubEndpoint:
type: ForgeCredentials
ForgeEndpoint:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: GithubEndpoint
GithubEndpoints:
type: ForgeEndpoint
ForgeEndpoints:
items:
$ref: '#/definitions/GithubEndpoint'
$ref: '#/definitions/ForgeEndpoint'
type: array
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: GithubEndpoints
type: ForgeEndpoints
HookInfo:
type: object
x-go-type:
@ -244,6 +265,22 @@ definitions:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Repository
ScaleSet:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: ScaleSet
ScaleSets:
items:
$ref: '#/definitions/ScaleSet'
type: array
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: ScaleSets
UpdateControllerParams:
type: object
x-go-type:
@ -258,6 +295,20 @@ definitions:
alias: garm_params
package: github.com/cloudbase/garm/params
type: UpdateEntityParams
UpdateGiteaCredentialsParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: UpdateGiteaCredentialsParams
UpdateGiteaEndpointParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: UpdateGiteaEndpointParams
UpdateGithubCredentialsParams:
type: object
x-go-type:
@ -279,6 +330,13 @@ definitions:
alias: garm_params
package: github.com/cloudbase/garm/params
type: UpdatePoolParams
UpdateScaleSetParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: UpdateScaleSetParams
User:
type: object
x-go-type:
@ -360,6 +418,15 @@ paths:
/enterprises:
get:
operationId: ListEnterprises
parameters:
- description: Exact enterprise name to filter by
in: query
name: name
type: string
- description: Exact endpoint name to filter by
in: query
name: endpoint
type: string
responses:
"200":
description: Enterprises
@ -616,6 +683,57 @@ paths:
tags:
- enterprises
- pools
/enterprises/{enterpriseID}/scalesets:
get:
operationId: ListEnterpriseScaleSets
parameters:
- description: Enterprise ID.
in: path
name: enterpriseID
required: true
type: string
responses:
"200":
description: ScaleSets
schema:
$ref: '#/definitions/ScaleSets'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List enterprise scale sets.
tags:
- enterprises
- scalesets
post:
operationId: CreateEnterpriseScaleSet
parameters:
- description: Enterprise ID.
in: path
name: enterpriseID
required: true
type: string
- description: Parameters used when creating the enterprise scale set.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/CreateScaleSetParams'
description: Parameters used when creating the enterprise scale set.
type: object
responses:
"200":
description: ScaleSet
schema:
$ref: '#/definitions/ScaleSet'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Create enterprise pool with the parameters given.
tags:
- enterprises
- scalesets
/first-run:
post:
operationId: FirstRun
@ -640,6 +758,212 @@ paths:
summary: Initialize the first run of the controller.
tags:
- first-run
/gitea/credentials:
get:
operationId: ListGiteaCredentials
responses:
"200":
description: Credentials
schema:
$ref: '#/definitions/Credentials'
"400":
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List all credentials.
tags:
- credentials
post:
operationId: CreateGiteaCredentials
parameters:
- description: Parameters used when creating a Gitea credential.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/CreateGiteaCredentialsParams'
description: Parameters used when creating a Gitea credential.
type: object
responses:
"200":
description: ForgeCredentials
schema:
$ref: '#/definitions/ForgeCredentials'
"400":
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Create a Gitea credential.
tags:
- credentials
/gitea/credentials/{id}:
delete:
operationId: DeleteGiteaCredentials
parameters:
- description: ID of the Gitea credential.
in: path
name: id
required: true
type: integer
responses:
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Delete a Gitea credential.
tags:
- credentials
get:
operationId: GetGiteaCredentials
parameters:
- description: ID of the Gitea credential.
in: path
name: id
required: true
type: integer
responses:
"200":
description: ForgeCredentials
schema:
$ref: '#/definitions/ForgeCredentials'
"400":
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Get a Gitea credential.
tags:
- credentials
put:
operationId: UpdateGiteaCredentials
parameters:
- description: ID of the Gitea credential.
in: path
name: id
required: true
type: integer
- description: Parameters used when updating a Gitea credential.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/UpdateGiteaCredentialsParams'
description: Parameters used when updating a Gitea credential.
type: object
responses:
"200":
description: ForgeCredentials
schema:
$ref: '#/definitions/ForgeCredentials'
"400":
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Update a Gitea credential.
tags:
- credentials
/gitea/endpoints:
get:
operationId: ListGiteaEndpoints
responses:
"200":
description: ForgeEndpoints
schema:
$ref: '#/definitions/ForgeEndpoints'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List all Gitea Endpoints.
tags:
- endpoints
post:
operationId: CreateGiteaEndpoint
parameters:
- description: Parameters used when creating a Gitea endpoint.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/CreateGiteaEndpointParams'
description: Parameters used when creating a Gitea endpoint.
type: object
responses:
"200":
description: ForgeEndpoint
schema:
$ref: '#/definitions/ForgeEndpoint'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Create a Gitea Endpoint.
tags:
- endpoints
/gitea/endpoints/{name}:
delete:
operationId: DeleteGiteaEndpoint
parameters:
- description: The name of the Gitea endpoint.
in: path
name: name
required: true
type: string
responses:
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Delete a Gitea Endpoint.
tags:
- endpoints
get:
operationId: GetGiteaEndpoint
parameters:
- description: The name of the Gitea endpoint.
in: path
name: name
required: true
type: string
responses:
"200":
description: ForgeEndpoint
schema:
$ref: '#/definitions/ForgeEndpoint'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Get a Gitea Endpoint.
tags:
- endpoints
put:
operationId: UpdateGiteaEndpoint
parameters:
- description: The name of the Gitea endpoint.
in: path
name: name
required: true
type: string
- description: Parameters used when updating a Gitea endpoint.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/UpdateGiteaEndpointParams'
description: Parameters used when updating a Gitea endpoint.
type: object
responses:
"200":
description: ForgeEndpoint
schema:
$ref: '#/definitions/ForgeEndpoint'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Update a Gitea Endpoint.
tags:
- endpoints
/github/credentials:
get:
operationId: ListCredentials
@ -668,9 +992,9 @@ paths:
type: object
responses:
"200":
description: GithubCredentials
description: ForgeCredentials
schema:
$ref: '#/definitions/GithubCredentials'
$ref: '#/definitions/ForgeCredentials'
"400":
description: APIErrorResponse
schema:
@ -705,9 +1029,9 @@ paths:
type: integer
responses:
"200":
description: GithubCredentials
description: ForgeCredentials
schema:
$ref: '#/definitions/GithubCredentials'
$ref: '#/definitions/ForgeCredentials'
"400":
description: APIErrorResponse
schema:
@ -733,9 +1057,9 @@ paths:
type: object
responses:
"200":
description: GithubCredentials
description: ForgeCredentials
schema:
$ref: '#/definitions/GithubCredentials'
$ref: '#/definitions/ForgeCredentials'
"400":
description: APIErrorResponse
schema:
@ -748,9 +1072,9 @@ paths:
operationId: ListGithubEndpoints
responses:
"200":
description: GithubEndpoints
description: ForgeEndpoints
schema:
$ref: '#/definitions/GithubEndpoints'
$ref: '#/definitions/ForgeEndpoints'
default:
description: APIErrorResponse
schema:
@ -771,9 +1095,9 @@ paths:
type: object
responses:
"200":
description: GithubEndpoint
description: ForgeEndpoint
schema:
$ref: '#/definitions/GithubEndpoint'
$ref: '#/definitions/ForgeEndpoint'
default:
description: APIErrorResponse
schema:
@ -808,9 +1132,9 @@ paths:
type: string
responses:
"200":
description: GithubEndpoint
description: ForgeEndpoint
schema:
$ref: '#/definitions/GithubEndpoint'
$ref: '#/definitions/ForgeEndpoint'
default:
description: APIErrorResponse
schema:
@ -836,9 +1160,9 @@ paths:
type: object
responses:
"200":
description: GithubEndpoint
description: ForgeEndpoint
schema:
$ref: '#/definitions/GithubEndpoint'
$ref: '#/definitions/ForgeEndpoint'
default:
description: APIErrorResponse
schema:
@ -939,6 +1263,15 @@ paths:
/organizations:
get:
operationId: ListOrgs
parameters:
- description: Exact organization name to filter by
in: query
name: name
type: string
- description: Exact endpoint name to filter by
in: query
name: endpoint
type: string
responses:
"200":
description: Organizations
@ -1199,6 +1532,57 @@ paths:
tags:
- organizations
- pools
/organizations/{orgID}/scalesets:
get:
operationId: ListOrgScaleSets
parameters:
- description: Organization ID.
in: path
name: orgID
required: true
type: string
responses:
"200":
description: ScaleSets
schema:
$ref: '#/definitions/ScaleSets'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List organization scale sets.
tags:
- organizations
- scalesets
post:
operationId: CreateOrgScaleSet
parameters:
- description: Organization ID.
in: path
name: orgID
required: true
type: string
- description: Parameters used when creating the organization scale set.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/CreateScaleSetParams'
description: Parameters used when creating the organization scale set.
type: object
responses:
"200":
description: ScaleSet
schema:
$ref: '#/definitions/ScaleSet'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Create organization scale set with the parameters given.
tags:
- organizations
- scalesets
/organizations/{orgID}/webhook:
delete:
operationId: UninstallOrgWebhook
@ -1388,6 +1772,19 @@ paths:
/repositories:
get:
operationId: ListRepos
parameters:
- description: Exact owner name to filter by
in: query
name: owner
type: string
- description: Exact repository name to filter by
in: query
name: name
type: string
- description: Exact endpoint name to filter by
in: query
name: endpoint
type: string
responses:
"200":
description: Repositories
@ -1648,6 +2045,57 @@ paths:
tags:
- repositories
- pools
/repositories/{repoID}/scalesets:
get:
operationId: ListRepoScaleSets
parameters:
- description: Repository ID.
in: path
name: repoID
required: true
type: string
responses:
"200":
description: ScaleSets
schema:
$ref: '#/definitions/ScaleSets'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List repository scale sets.
tags:
- repositories
- scalesets
post:
operationId: CreateRepoScaleSet
parameters:
- description: Repository ID.
in: path
name: repoID
required: true
type: string
- description: Parameters used when creating the repository scale set.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/CreateScaleSetParams'
description: Parameters used when creating the repository scale set.
type: object
responses:
"200":
description: ScaleSet
schema:
$ref: '#/definitions/ScaleSet'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Create repository scale set with the parameters given.
tags:
- repositories
- scalesets
/repositories/{repoID}/webhook:
delete:
operationId: UninstallRepoWebhook
@ -1718,6 +2166,107 @@ paths:
tags:
- repositories
- hooks
/scalesets:
get:
operationId: ListScalesets
responses:
"200":
description: ScaleSets
schema:
$ref: '#/definitions/ScaleSets'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List all scalesets.
tags:
- scalesets
/scalesets/{scalesetID}:
delete:
operationId: DeleteScaleSet
parameters:
- description: ID of the scale set to delete.
in: path
name: scalesetID
required: true
type: string
responses:
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Delete scale set by ID.
tags:
- scalesets
get:
operationId: GetScaleSet
parameters:
- description: ID of the scale set to fetch.
in: path
name: scalesetID
required: true
type: string
responses:
"200":
description: ScaleSet
schema:
$ref: '#/definitions/ScaleSet'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Get scale set by ID.
tags:
- scalesets
put:
operationId: UpdateScaleSet
parameters:
- description: ID of the scale set to update.
in: path
name: scalesetID
required: true
type: string
- description: Parameters to update the scale set with.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/UpdateScaleSetParams'
description: Parameters to update the scale set with.
type: object
responses:
"200":
description: ScaleSet
schema:
$ref: '#/definitions/ScaleSet'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Update scale set by ID.
tags:
- scalesets
/scalesets/{scalesetID}/instances:
get:
operationId: ListScaleSetInstances
parameters:
- description: Runner scale set ID.
in: path
name: scalesetID
required: true
type: string
responses:
"200":
description: Instances
schema:
$ref: '#/definitions/Instances'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List runner instances in a scale set.
tags:
- instances
produces:
- application/json
security:

View file

@ -1,3 +1,16 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package auth
import "net/http"

View file

@ -16,11 +16,12 @@ package auth
import (
"context"
"errors"
"fmt"
"time"
jwt "github.com/golang-jwt/jwt/v5"
"github.com/nbutton23/zxcvbn-go"
"github.com/pkg/errors"
"golang.org/x/crypto/bcrypt"
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
@ -49,7 +50,7 @@ func (a *Authenticator) IsInitialized() bool {
func (a *Authenticator) GetJWTToken(ctx context.Context) (string, error) {
tokenID, err := util.GetRandomString(16)
if err != nil {
return "", errors.Wrap(err, "generating random string")
return "", fmt.Errorf("error generating random string: %w", err)
}
expireToken := time.Now().Add(a.cfg.TimeToLive.Duration())
expires := &jwt.NumericDate{
@ -72,7 +73,7 @@ func (a *Authenticator) GetJWTToken(ctx context.Context) (string, error) {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
tokenString, err := token.SignedString([]byte(a.cfg.Secret))
if err != nil {
return "", errors.Wrap(err, "fetching token string")
return "", fmt.Errorf("error fetching token string: %w", err)
}
return tokenString, nil
@ -87,7 +88,7 @@ func (a *Authenticator) GetJWTMetricsToken(ctx context.Context) (string, error)
tokenID, err := util.GetRandomString(16)
if err != nil {
return "", errors.Wrap(err, "generating random string")
return "", fmt.Errorf("error generating random string: %w", err)
}
// nolint:golangci-lint,godox
// TODO: currently this is the same TTL as the normal Token
@ -111,7 +112,7 @@ func (a *Authenticator) GetJWTMetricsToken(ctx context.Context) (string, error)
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
tokenString, err := token.SignedString([]byte(a.cfg.Secret))
if err != nil {
return "", errors.Wrap(err, "fetching token string")
return "", fmt.Errorf("error fetching token string: %w", err)
}
return tokenString, nil
@ -121,7 +122,7 @@ func (a *Authenticator) InitController(ctx context.Context, param params.NewUser
_, err := a.store.ControllerInfo()
if err != nil {
if !errors.Is(err, runnerErrors.ErrNotFound) {
return params.User{}, errors.Wrap(err, "initializing controller")
return params.User{}, fmt.Errorf("error initializing controller: %w", err)
}
}
if a.store.HasAdminUser(ctx) {
@ -151,7 +152,7 @@ func (a *Authenticator) InitController(ctx context.Context, param params.NewUser
hashed, err := util.PaswsordToBcrypt(param.Password)
if err != nil {
return params.User{}, errors.Wrap(err, "creating user")
return params.User{}, fmt.Errorf("error creating user: %w", err)
}
param.Password = hashed
@ -169,7 +170,7 @@ func (a *Authenticator) AuthenticateUser(ctx context.Context, info params.Passwo
if errors.Is(err, runnerErrors.ErrNotFound) {
return ctx, runnerErrors.ErrUnauthorized
}
return ctx, errors.Wrap(err, "authenticating")
return ctx, fmt.Errorf("error authenticating: %w", err)
}
if !user.Enabled {

View file

@ -44,8 +44,21 @@ const (
instanceTokenFetched contextFlags = "tokenFetched"
instanceHasJITConfig contextFlags = "hasJITConfig"
instanceParams contextFlags = "instanceParams"
instanceForgeTypeKey contextFlags = "forge_type"
)
func SetInstanceForgeType(ctx context.Context, val string) context.Context {
return context.WithValue(ctx, instanceForgeTypeKey, val)
}
func InstanceForgeType(ctx context.Context) params.EndpointType {
elem := ctx.Value(instanceForgeTypeKey)
if elem == nil {
return ""
}
return elem.(params.EndpointType)
}
func SetInstanceID(ctx context.Context, id string) context.Context {
return context.WithValue(ctx, instanceIDKey, id)
}
@ -159,7 +172,7 @@ func InstanceEntity(ctx context.Context) string {
return elem.(string)
}
func PopulateInstanceContext(ctx context.Context, instance params.Instance) context.Context {
func PopulateInstanceContext(ctx context.Context, instance params.Instance, claims *InstanceJWTClaims) context.Context {
ctx = SetInstanceID(ctx, instance.ID)
ctx = SetInstanceName(ctx, instance.Name)
ctx = SetInstancePoolID(ctx, instance.PoolID)
@ -167,6 +180,7 @@ func PopulateInstanceContext(ctx context.Context, instance params.Instance) cont
ctx = SetInstanceTokenFetched(ctx, instance.TokenFetched)
ctx = SetInstanceHasJITConfig(ctx, instance.JitConfiguration)
ctx = SetInstanceParams(ctx, instance)
ctx = SetInstanceForgeType(ctx, claims.ForgeType)
return ctx
}

View file

@ -38,8 +38,8 @@ type initRequired struct {
func (i *initRequired) Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
ctrlInfo, err := i.store.ControllerInfo()
if err != nil || ctrlInfo.ControllerID.String() == "" {
if !i.store.HasAdminUser(ctx) {
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusConflict)
if err := json.NewEncoder(w).Encode(params.InitializationRequired); err != nil {

View file

@ -18,12 +18,12 @@ import (
"context"
"fmt"
"log/slog"
"math"
"net/http"
"strings"
"time"
jwt "github.com/golang-jwt/jwt/v5"
"github.com/pkg/errors"
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
commonParams "github.com/cloudbase/garm-provider-common/params"
@ -39,10 +39,11 @@ type InstanceJWTClaims struct {
Name string `json:"name"`
PoolID string `json:"provider_id"`
// Scope is either repository or organization
Scope params.GithubEntityType `json:"scope"`
Scope params.ForgeEntityType `json:"scope"`
// Entity is the repo or org name
Entity string `json:"entity"`
CreateAttempt int `json:"create_attempt"`
ForgeType string `json:"forge_type"`
jwt.RegisteredClaims
}
@ -59,11 +60,17 @@ type instanceToken struct {
jwtSecret string
}
func (i *instanceToken) NewInstanceJWTToken(instance params.Instance, entity string, poolType params.GithubEntityType, ttlMinutes uint) (string, error) {
func (i *instanceToken) NewInstanceJWTToken(instance params.Instance, entity params.ForgeEntity, entityType params.ForgeEntityType, ttlMinutes uint) (string, error) {
// Token expiration is equal to the bootstrap timeout set on the pool plus the polling
// interval garm uses to check for timed out runners. Runners that have not sent their info
// by the end of this interval are most likely failed and will be reaped by garm anyway.
expireToken := time.Now().Add(time.Duration(ttlMinutes)*time.Minute + common.PoolReapTimeoutInterval)
var ttl int
if ttlMinutes > math.MaxInt {
ttl = math.MaxInt
} else {
ttl = int(ttlMinutes)
}
expireToken := time.Now().Add(time.Duration(ttl)*time.Minute + common.PoolReapTimeoutInterval)
expires := &jwt.NumericDate{
Time: expireToken,
}
@ -75,14 +82,15 @@ func (i *instanceToken) NewInstanceJWTToken(instance params.Instance, entity str
ID: instance.ID,
Name: instance.Name,
PoolID: instance.PoolID,
Scope: poolType,
Entity: entity,
Scope: entityType,
Entity: entity.String(),
ForgeType: string(entity.Credentials.ForgeType),
CreateAttempt: instance.CreateAttempt,
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
tokenString, err := token.SignedString([]byte(i.jwtSecret))
if err != nil {
return "", errors.Wrap(err, "signing token")
return "", fmt.Errorf("error signing token: %w", err)
}
return tokenString, nil
@ -112,12 +120,12 @@ func (amw *instanceMiddleware) claimsToContext(ctx context.Context, claims *Inst
return nil, runnerErrors.ErrUnauthorized
}
instanceInfo, err := amw.store.GetInstanceByName(ctx, claims.Name)
instanceInfo, err := amw.store.GetInstance(ctx, claims.Name)
if err != nil {
return ctx, runnerErrors.ErrUnauthorized
}
ctx = PopulateInstanceContext(ctx, instanceInfo)
ctx = PopulateInstanceContext(ctx, instanceInfo, claims)
return ctx, nil
}

View file

@ -26,5 +26,5 @@ type Middleware interface {
}
type InstanceTokenGetter interface {
NewInstanceJWTToken(instance params.Instance, entity string, poolType params.GithubEntityType, ttlMinutes uint) (string, error)
NewInstanceJWTToken(instance params.Instance, entity params.ForgeEntity, poolType params.ForgeEntityType, ttlMinutes uint) (string, error)
}

View file

@ -97,26 +97,37 @@ func invalidAuthResponse(ctx context.Context, w http.ResponseWriter) {
}
}
func (amw *jwtMiddleware) getTokenFromRequest(r *http.Request) (string, error) {
authorizationHeader := r.Header.Get("authorization")
if authorizationHeader == "" {
cookie, err := r.Cookie("garm_token")
if err != nil {
return "", fmt.Errorf("failed to get cookie: %w", err)
}
return cookie.Value, nil
}
bearerToken := strings.Split(authorizationHeader, " ")
if len(bearerToken) != 2 {
return "", fmt.Errorf("invalid auth header")
}
return bearerToken[1], nil
}
// Middleware implements the middleware interface
func (amw *jwtMiddleware) Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// nolint:golangci-lint,godox
// TODO: Log error details when authentication fails
ctx := r.Context()
authorizationHeader := r.Header.Get("authorization")
if authorizationHeader == "" {
authToken, err := amw.getTokenFromRequest(r)
if err != nil {
slog.ErrorContext(ctx, "failed to get auth token", "error", err)
invalidAuthResponse(ctx, w)
return
}
bearerToken := strings.Split(authorizationHeader, " ")
if len(bearerToken) != 2 {
invalidAuthResponse(ctx, w)
return
}
claims := &JWTClaims{}
token, err := jwt.ParseWithClaims(bearerToken[1], claims, func(token *jwt.Token) (interface{}, error) {
token, err := jwt.ParseWithClaims(authToken, claims, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
return nil, fmt.Errorf("invalid signing method")
}

View file

@ -1,3 +1,16 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package auth
import (

16
build-webapp.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
set -e
echo "Building GARM SPA (SvelteKit)..."
# Navigate to webapp directory
cd webapp
# Install dependencies if node_modules doesn't exist
npm install
# Build the SPA
echo "Building SPA..."
npm run build
echo "SPA built successfully!"

1040
cache/cache_test.go vendored Normal file

File diff suppressed because it is too large Load diff

148
cache/credentials_cache.go vendored Normal file
View file

@ -0,0 +1,148 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cache
import (
"sync"
"github.com/cloudbase/garm/params"
)
var (
credentialsCache *CredentialCache
giteaCredentialsCache *CredentialCache
)
func init() {
ghCredentialsCache := &CredentialCache{
cache: make(map[uint]params.ForgeCredentials),
}
gtCredentialsCache := &CredentialCache{
cache: make(map[uint]params.ForgeCredentials),
}
credentialsCache = ghCredentialsCache
giteaCredentialsCache = gtCredentialsCache
}
type CredentialCache struct {
mux sync.Mutex
cache map[uint]params.ForgeCredentials
}
func (g *CredentialCache) SetCredentialsRateLimit(credsID uint, rateLimit params.GithubRateLimit) {
g.mux.Lock()
defer g.mux.Unlock()
if creds, ok := g.cache[credsID]; ok {
creds.RateLimit = &rateLimit
g.cache[credsID] = creds
}
}
func (g *CredentialCache) SetCredentials(credentials params.ForgeCredentials) {
g.mux.Lock()
defer g.mux.Unlock()
g.cache[credentials.ID] = credentials
UpdateCredentialsInAffectedEntities(credentials)
}
func (g *CredentialCache) GetCredentials(id uint) (params.ForgeCredentials, bool) {
g.mux.Lock()
defer g.mux.Unlock()
if creds, ok := g.cache[id]; ok {
return creds, true
}
return params.ForgeCredentials{}, false
}
func (g *CredentialCache) DeleteCredentials(id uint) {
g.mux.Lock()
defer g.mux.Unlock()
delete(g.cache, id)
}
func (g *CredentialCache) GetAllCredentials() []params.ForgeCredentials {
g.mux.Lock()
defer g.mux.Unlock()
creds := make([]params.ForgeCredentials, 0, len(g.cache))
for _, cred := range g.cache {
creds = append(creds, cred)
}
// Sort the credentials by ID
sortByID(creds)
return creds
}
func (g *CredentialCache) GetAllCredentialsAsMap() map[uint]params.ForgeCredentials {
g.mux.Lock()
defer g.mux.Unlock()
creds := make(map[uint]params.ForgeCredentials, len(g.cache))
for id, cred := range g.cache {
creds[id] = cred
}
return creds
}
func SetGithubCredentials(credentials params.ForgeCredentials) {
credentialsCache.SetCredentials(credentials)
}
func GetGithubCredentials(id uint) (params.ForgeCredentials, bool) {
return credentialsCache.GetCredentials(id)
}
func DeleteGithubCredentials(id uint) {
credentialsCache.DeleteCredentials(id)
}
func GetAllGithubCredentials() []params.ForgeCredentials {
return credentialsCache.GetAllCredentials()
}
func SetCredentialsRateLimit(credsID uint, rateLimit params.GithubRateLimit) {
credentialsCache.SetCredentialsRateLimit(credsID, rateLimit)
}
func GetAllGithubCredentialsAsMap() map[uint]params.ForgeCredentials {
return credentialsCache.GetAllCredentialsAsMap()
}
func SetGiteaCredentials(credentials params.ForgeCredentials) {
giteaCredentialsCache.SetCredentials(credentials)
}
func GetGiteaCredentials(id uint) (params.ForgeCredentials, bool) {
return giteaCredentialsCache.GetCredentials(id)
}
func DeleteGiteaCredentials(id uint) {
giteaCredentialsCache.DeleteCredentials(id)
}
func GetAllGiteaCredentials() []params.ForgeCredentials {
return giteaCredentialsCache.GetAllCredentials()
}
func GetAllGiteaCredentialsAsMap() map[uint]params.ForgeCredentials {
return giteaCredentialsCache.GetAllCredentialsAsMap()
}

435
cache/entity_cache.go vendored Normal file
View file

@ -0,0 +1,435 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cache
import (
"sync"
"time"
"github.com/cloudbase/garm/params"
)
var entityCache *EntityCache
func init() {
ghEntityCache := &EntityCache{
entities: make(map[string]EntityItem),
}
entityCache = ghEntityCache
}
type RunnerGroupEntry struct {
RunnerGroupID int64
time time.Time
}
type EntityItem struct {
Entity params.ForgeEntity
Pools map[string]params.Pool
ScaleSets map[uint]params.ScaleSet
RunnerGroups map[string]RunnerGroupEntry
}
type EntityCache struct {
mux sync.Mutex
// entity IDs are UUID4s. It is highly unlikely they will collide (🤞).
entities map[string]EntityItem
}
func (e *EntityCache) UpdateCredentialsInAffectedEntities(creds params.ForgeCredentials) {
e.mux.Lock()
defer e.mux.Unlock()
for entityID, cache := range e.entities {
if cache.Entity.Credentials.GetID() == creds.GetID() {
cache.Entity.Credentials = creds
e.entities[entityID] = cache
}
}
}
func (e *EntityCache) GetEntity(entityID string) (params.ForgeEntity, bool) {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
var creds params.ForgeCredentials
var ok bool
switch cache.Entity.Credentials.ForgeType {
case params.GithubEndpointType:
creds, ok = GetGithubCredentials(cache.Entity.Credentials.ID)
case params.GiteaEndpointType:
creds, ok = GetGiteaCredentials(cache.Entity.Credentials.ID)
}
if ok {
cache.Entity.Credentials = creds
}
return cache.Entity, true
}
return params.ForgeEntity{}, false
}
func (e *EntityCache) SetEntity(entity params.ForgeEntity) {
e.mux.Lock()
defer e.mux.Unlock()
cache, ok := e.entities[entity.ID]
if !ok {
e.entities[entity.ID] = EntityItem{
Entity: entity,
Pools: make(map[string]params.Pool),
ScaleSets: make(map[uint]params.ScaleSet),
RunnerGroups: make(map[string]RunnerGroupEntry),
}
return
}
cache.Entity = entity
e.entities[entity.ID] = cache
}
func (e *EntityCache) ReplaceEntityPools(entityID string, pools []params.Pool) {
e.mux.Lock()
defer e.mux.Unlock()
cache, ok := e.entities[entityID]
if !ok {
return
}
poolsByID := map[string]params.Pool{}
for _, pool := range pools {
poolsByID[pool.ID] = pool
}
cache.Pools = poolsByID
e.entities[entityID] = cache
}
func (e *EntityCache) ReplaceEntityScaleSets(entityID string, scaleSets []params.ScaleSet) {
e.mux.Lock()
defer e.mux.Unlock()
cache, ok := e.entities[entityID]
if !ok {
return
}
scaleSetsByID := map[uint]params.ScaleSet{}
for _, scaleSet := range scaleSets {
scaleSetsByID[scaleSet.ID] = scaleSet
}
cache.ScaleSets = scaleSetsByID
e.entities[entityID] = cache
}
func (e *EntityCache) DeleteEntity(entityID string) {
e.mux.Lock()
defer e.mux.Unlock()
delete(e.entities, entityID)
}
func (e *EntityCache) SetEntityPool(entityID string, pool params.Pool) {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
cache.Pools[pool.ID] = pool
e.entities[entityID] = cache
}
}
func (e *EntityCache) SetEntityScaleSet(entityID string, scaleSet params.ScaleSet) {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
cache.ScaleSets[scaleSet.ID] = scaleSet
e.entities[entityID] = cache
}
}
func (e *EntityCache) DeleteEntityPool(entityID string, poolID string) {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
delete(cache.Pools, poolID)
e.entities[entityID] = cache
}
}
func (e *EntityCache) DeleteEntityScaleSet(entityID string, scaleSetID uint) {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
delete(cache.ScaleSets, scaleSetID)
e.entities[entityID] = cache
}
}
func (e *EntityCache) GetEntityPool(entityID string, poolID string) (params.Pool, bool) {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
if pool, ok := cache.Pools[poolID]; ok {
return pool, true
}
}
return params.Pool{}, false
}
func (e *EntityCache) GetEntityScaleSet(entityID string, scaleSetID uint) (params.ScaleSet, bool) {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
if scaleSet, ok := cache.ScaleSets[scaleSetID]; ok {
return scaleSet, true
}
}
return params.ScaleSet{}, false
}
func (e *EntityCache) FindPoolsMatchingAllTags(entityID string, tags []string) []params.Pool {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
var pools []params.Pool
for _, pool := range cache.Pools {
if pool.HasRequiredLabels(tags) {
pools = append(pools, pool)
}
}
// Sort the pools by creation date.
sortByCreationDate(pools)
return pools
}
return nil
}
func (e *EntityCache) GetEntityPools(entityID string) []params.Pool {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
var pools []params.Pool
for _, pool := range cache.Pools {
pools = append(pools, pool)
}
// Sort the pools by creation date.
sortByCreationDate(pools)
return pools
}
return nil
}
func (e *EntityCache) GetEntityScaleSets(entityID string) []params.ScaleSet {
e.mux.Lock()
defer e.mux.Unlock()
if cache, ok := e.entities[entityID]; ok {
var scaleSets []params.ScaleSet
for _, scaleSet := range cache.ScaleSets {
scaleSets = append(scaleSets, scaleSet)
}
// Sort the scale sets by creation date.
sortByID(scaleSets)
return scaleSets
}
return nil
}
func (e *EntityCache) GetEntitiesUsingCredentials(creds params.ForgeCredentials) []params.ForgeEntity {
e.mux.Lock()
defer e.mux.Unlock()
var entities []params.ForgeEntity
for _, cache := range e.entities {
if cache.Entity.Credentials.ForgeType != creds.ForgeType {
continue
}
if cache.Entity.Credentials.GetID() == creds.GetID() {
entities = append(entities, cache.Entity)
}
}
sortByCreationDate(entities)
return entities
}
func (e *EntityCache) GetAllEntities() []params.ForgeEntity {
e.mux.Lock()
defer e.mux.Unlock()
var entities []params.ForgeEntity
for _, cache := range e.entities {
// Get the credentials from the credentials cache.
var creds params.ForgeCredentials
var ok bool
switch cache.Entity.Credentials.ForgeType {
case params.GithubEndpointType:
creds, ok = GetGithubCredentials(cache.Entity.Credentials.ID)
case params.GiteaEndpointType:
creds, ok = GetGiteaCredentials(cache.Entity.Credentials.ID)
}
if ok {
cache.Entity.Credentials = creds
}
entities = append(entities, cache.Entity)
}
sortByCreationDate(entities)
return entities
}
func (e *EntityCache) GetAllPools() []params.Pool {
e.mux.Lock()
defer e.mux.Unlock()
var pools []params.Pool
for _, cache := range e.entities {
for _, pool := range cache.Pools {
pools = append(pools, pool)
}
}
sortByCreationDate(pools)
return pools
}
func (e *EntityCache) GetAllScaleSets() []params.ScaleSet {
e.mux.Lock()
defer e.mux.Unlock()
var scaleSets []params.ScaleSet
for _, cache := range e.entities {
for _, scaleSet := range cache.ScaleSets {
scaleSets = append(scaleSets, scaleSet)
}
}
sortByID(scaleSets)
return scaleSets
}
func (e *EntityCache) SetEntityRunnerGroup(entityID, runnerGroupName string, runnerGroupID int64) {
e.mux.Lock()
defer e.mux.Unlock()
if _, ok := e.entities[entityID]; ok {
e.entities[entityID].RunnerGroups[runnerGroupName] = RunnerGroupEntry{
RunnerGroupID: runnerGroupID,
time: time.Now().UTC(),
}
}
}
func (e *EntityCache) GetEntityRunnerGroup(entityID, runnerGroupName string) (int64, bool) {
e.mux.Lock()
defer e.mux.Unlock()
if _, ok := e.entities[entityID]; ok {
if runnerGroup, ok := e.entities[entityID].RunnerGroups[runnerGroupName]; ok {
if time.Now().UTC().After(runnerGroup.time.Add(1 * time.Hour)) {
delete(e.entities[entityID].RunnerGroups, runnerGroupName)
return 0, false
}
return runnerGroup.RunnerGroupID, true
}
}
return 0, false
}
func SetEntityRunnerGroup(entityID, runnerGroupName string, runnerGroupID int64) {
entityCache.SetEntityRunnerGroup(entityID, runnerGroupName, runnerGroupID)
}
func GetEntityRunnerGroup(entityID, runnerGroupName string) (int64, bool) {
return entityCache.GetEntityRunnerGroup(entityID, runnerGroupName)
}
func GetEntity(entityID string) (params.ForgeEntity, bool) {
return entityCache.GetEntity(entityID)
}
func SetEntity(entity params.ForgeEntity) {
entityCache.SetEntity(entity)
}
func ReplaceEntityPools(entityID string, pools []params.Pool) {
entityCache.ReplaceEntityPools(entityID, pools)
}
func ReplaceEntityScaleSets(entityID string, scaleSets []params.ScaleSet) {
entityCache.ReplaceEntityScaleSets(entityID, scaleSets)
}
func DeleteEntity(entityID string) {
entityCache.DeleteEntity(entityID)
}
func SetEntityPool(entityID string, pool params.Pool) {
entityCache.SetEntityPool(entityID, pool)
}
func SetEntityScaleSet(entityID string, scaleSet params.ScaleSet) {
entityCache.SetEntityScaleSet(entityID, scaleSet)
}
func DeleteEntityPool(entityID string, poolID string) {
entityCache.DeleteEntityPool(entityID, poolID)
}
func DeleteEntityScaleSet(entityID string, scaleSetID uint) {
entityCache.DeleteEntityScaleSet(entityID, scaleSetID)
}
func GetEntityPool(entityID string, poolID string) (params.Pool, bool) {
return entityCache.GetEntityPool(entityID, poolID)
}
func GetEntityScaleSet(entityID string, scaleSetID uint) (params.ScaleSet, bool) {
return entityCache.GetEntityScaleSet(entityID, scaleSetID)
}
func FindPoolsMatchingAllTags(entityID string, tags []string) []params.Pool {
return entityCache.FindPoolsMatchingAllTags(entityID, tags)
}
func GetEntityPools(entityID string) []params.Pool {
return entityCache.GetEntityPools(entityID)
}
func GetEntityScaleSets(entityID string) []params.ScaleSet {
return entityCache.GetEntityScaleSets(entityID)
}
func UpdateCredentialsInAffectedEntities(creds params.ForgeCredentials) {
entityCache.UpdateCredentialsInAffectedEntities(creds)
}
func GetEntitiesUsingCredentials(creds params.ForgeCredentials) []params.ForgeEntity {
return entityCache.GetEntitiesUsingCredentials(creds)
}
func GetAllEntities() []params.ForgeEntity {
return entityCache.GetAllEntities()
}
func GetAllPools() []params.Pool {
return entityCache.GetAllPools()
}
func GetAllScaleSets() []params.ScaleSet {
return entityCache.GetAllScaleSets()
}

60
cache/github_client.go vendored Normal file
View file

@ -0,0 +1,60 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cache
import (
"sync"
"github.com/cloudbase/garm/runner/common"
)
var ghClientCache *GithubClientCache
type GithubClientCache struct {
mux sync.Mutex
cache map[string]common.GithubClient
}
func init() {
clientCache := &GithubClientCache{
cache: make(map[string]common.GithubClient),
}
ghClientCache = clientCache
}
func (g *GithubClientCache) SetClient(entityID string, client common.GithubClient) {
g.mux.Lock()
defer g.mux.Unlock()
g.cache[entityID] = client
}
func (g *GithubClientCache) GetClient(entityID string) (common.GithubClient, bool) {
g.mux.Lock()
defer g.mux.Unlock()
if client, ok := g.cache[entityID]; ok {
return client, true
}
return nil, false
}
func SetGithubClient(entityID string, client common.GithubClient) {
ghClientCache.SetClient(entityID, client)
}
func GetGithubClient(entityID string) (common.GithubClient, bool) {
return ghClientCache.GetClient(entityID)
}

143
cache/instance_cache.go vendored Normal file
View file

@ -0,0 +1,143 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cache
import (
"sync"
"github.com/cloudbase/garm/params"
)
var instanceCache *InstanceCache
func init() {
cache := &InstanceCache{
cache: make(map[string]params.Instance),
}
instanceCache = cache
}
type InstanceCache struct {
mux sync.Mutex
cache map[string]params.Instance
}
func (i *InstanceCache) SetInstance(instance params.Instance) {
i.mux.Lock()
defer i.mux.Unlock()
i.cache[instance.Name] = instance
}
func (i *InstanceCache) GetInstance(name string) (params.Instance, bool) {
i.mux.Lock()
defer i.mux.Unlock()
if instance, ok := i.cache[name]; ok {
return instance, true
}
return params.Instance{}, false
}
func (i *InstanceCache) DeleteInstance(name string) {
i.mux.Lock()
defer i.mux.Unlock()
delete(i.cache, name)
}
func (i *InstanceCache) GetAllInstances() []params.Instance {
i.mux.Lock()
defer i.mux.Unlock()
instances := make([]params.Instance, 0, len(i.cache))
for _, instance := range i.cache {
instances = append(instances, instance)
}
sortByCreationDate(instances)
return instances
}
func (i *InstanceCache) GetInstancesForPool(poolID string) []params.Instance {
i.mux.Lock()
defer i.mux.Unlock()
var filteredInstances []params.Instance
for _, instance := range i.cache {
if instance.PoolID == poolID {
filteredInstances = append(filteredInstances, instance)
}
}
sortByCreationDate(filteredInstances)
return filteredInstances
}
func (i *InstanceCache) GetInstancesForScaleSet(scaleSetID uint) []params.Instance {
i.mux.Lock()
defer i.mux.Unlock()
var filteredInstances []params.Instance
for _, instance := range i.cache {
if instance.ScaleSetID == scaleSetID {
filteredInstances = append(filteredInstances, instance)
}
}
sortByCreationDate(filteredInstances)
return filteredInstances
}
func (i *InstanceCache) GetEntityInstances(entityID string) []params.Instance {
pools := GetEntityPools(entityID)
poolsAsMap := map[string]bool{}
for _, pool := range pools {
poolsAsMap[pool.ID] = true
}
ret := []params.Instance{}
for _, val := range i.GetAllInstances() {
if _, ok := poolsAsMap[val.PoolID]; ok {
ret = append(ret, val)
}
}
return ret
}
func SetInstanceCache(instance params.Instance) {
instanceCache.SetInstance(instance)
}
func GetInstanceCache(name string) (params.Instance, bool) {
return instanceCache.GetInstance(name)
}
func DeleteInstanceCache(name string) {
instanceCache.DeleteInstance(name)
}
func GetAllInstancesCache() []params.Instance {
return instanceCache.GetAllInstances()
}
func GetInstancesForPool(poolID string) []params.Instance {
return instanceCache.GetInstancesForPool(poolID)
}
func GetInstancesForScaleSet(scaleSetID uint) []params.Instance {
return instanceCache.GetInstancesForScaleSet(scaleSetID)
}
func GetEntityInstances(entityID string) []params.Instance {
return instanceCache.GetEntityInstances(entityID)
}

116
cache/tools_cache.go vendored Normal file
View file

@ -0,0 +1,116 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cache
import (
"fmt"
"sync"
"time"
commonParams "github.com/cloudbase/garm-provider-common/params"
"github.com/cloudbase/garm/params"
)
var githubToolsCache *GithubToolsCache
func init() {
ghToolsCache := &GithubToolsCache{
entities: make(map[string]GithubEntityTools),
}
githubToolsCache = ghToolsCache
}
type GithubEntityTools struct {
updatedAt time.Time
expiresAt time.Time
err error
entity params.ForgeEntity
tools []commonParams.RunnerApplicationDownload
}
type GithubToolsCache struct {
mux sync.Mutex
// entity IDs are UUID4s. It is highly unlikely they will collide (🤞).
entities map[string]GithubEntityTools
}
func (g *GithubToolsCache) Get(entityID string) ([]commonParams.RunnerApplicationDownload, error) {
g.mux.Lock()
defer g.mux.Unlock()
if cache, ok := g.entities[entityID]; ok {
if cache.entity.Credentials.ForgeType == params.GithubEndpointType {
if time.Now().UTC().After(cache.expiresAt.Add(-5 * time.Minute)) {
// Stale cache, remove it.
delete(g.entities, entityID)
return nil, fmt.Errorf("cache expired for entity %s", entityID)
}
}
if cache.err != nil {
return nil, cache.err
}
return cache.tools, nil
}
return nil, fmt.Errorf("no cache found for entity %s", entityID)
}
func (g *GithubToolsCache) Set(entity params.ForgeEntity, tools []commonParams.RunnerApplicationDownload) {
g.mux.Lock()
defer g.mux.Unlock()
forgeTools := GithubEntityTools{
updatedAt: time.Now(),
entity: entity,
tools: tools,
err: nil,
}
if entity.Credentials.ForgeType == params.GithubEndpointType {
forgeTools.expiresAt = time.Now().Add(1 * time.Hour)
}
g.entities[entity.ID] = forgeTools
}
func (g *GithubToolsCache) SetToolsError(entity params.ForgeEntity, err error) {
g.mux.Lock()
defer g.mux.Unlock()
// If the entity is not in the cache, add it with the error.
cache, ok := g.entities[entity.ID]
if !ok {
g.entities[entity.ID] = GithubEntityTools{
updatedAt: time.Now(),
entity: entity,
err: err,
}
return
}
// Update the error for the existing entity.
cache.err = err
g.entities[entity.ID] = cache
}
func SetGithubToolsCache(entity params.ForgeEntity, tools []commonParams.RunnerApplicationDownload) {
githubToolsCache.Set(entity, tools)
}
func GetGithubToolsCache(entityID string) ([]commonParams.RunnerApplicationDownload, error) {
return githubToolsCache.Get(entityID)
}
func SetGithubToolsCacheError(entity params.ForgeEntity, err error) {
githubToolsCache.SetToolsError(entity, err)
}

32
cache/util.go vendored Normal file
View file

@ -0,0 +1,32 @@
// Copyright 2025 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cache
import (
"sort"
"github.com/cloudbase/garm/params"
)
func sortByID[T params.IDGetter](s []T) {
sort.Slice(s, func(i, j int) bool {
return s[i].GetID() < s[j].GetID()
})
}
func sortByCreationDate[T params.CreationDateGetter](s []T) {
sort.Slice(s, func(i, j int) bool {
return s[i].GetCreatedAt().Before(s[j].GetCreatedAt())
})
}

View file

@ -50,10 +50,10 @@ func NewCreateCredentialsOK() *CreateCredentialsOK {
/*
CreateCredentialsOK describes a response with status code 200, with default header values.
GithubCredentials
ForgeCredentials
*/
type CreateCredentialsOK struct {
Payload garm_params.GithubCredentials
Payload garm_params.ForgeCredentials
}
// IsSuccess returns true when this create credentials o k response has a 2xx status code
@ -96,7 +96,7 @@ func (o *CreateCredentialsOK) String() string {
return fmt.Sprintf("[POST /github/credentials][%d] createCredentialsOK %s", 200, payload)
}
func (o *CreateCredentialsOK) GetPayload() garm_params.GithubCredentials {
func (o *CreateCredentialsOK) GetPayload() garm_params.ForgeCredentials {
return o.Payload
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewCreateGiteaCredentialsParams creates a new CreateGiteaCredentialsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewCreateGiteaCredentialsParams() *CreateGiteaCredentialsParams {
return &CreateGiteaCredentialsParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateGiteaCredentialsParamsWithTimeout creates a new CreateGiteaCredentialsParams object
// with the ability to set a timeout on a request.
func NewCreateGiteaCredentialsParamsWithTimeout(timeout time.Duration) *CreateGiteaCredentialsParams {
return &CreateGiteaCredentialsParams{
timeout: timeout,
}
}
// NewCreateGiteaCredentialsParamsWithContext creates a new CreateGiteaCredentialsParams object
// with the ability to set a context for a request.
func NewCreateGiteaCredentialsParamsWithContext(ctx context.Context) *CreateGiteaCredentialsParams {
return &CreateGiteaCredentialsParams{
Context: ctx,
}
}
// NewCreateGiteaCredentialsParamsWithHTTPClient creates a new CreateGiteaCredentialsParams object
// with the ability to set a custom HTTPClient for a request.
func NewCreateGiteaCredentialsParamsWithHTTPClient(client *http.Client) *CreateGiteaCredentialsParams {
return &CreateGiteaCredentialsParams{
HTTPClient: client,
}
}
/*
CreateGiteaCredentialsParams contains all the parameters to send to the API endpoint
for the create gitea credentials operation.
Typically these are written to a http.Request.
*/
type CreateGiteaCredentialsParams struct {
/* Body.
Parameters used when creating a Gitea credential.
*/
Body garm_params.CreateGiteaCredentialsParams
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the create gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateGiteaCredentialsParams) WithDefaults() *CreateGiteaCredentialsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the create gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateGiteaCredentialsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the create gitea credentials params
func (o *CreateGiteaCredentialsParams) WithTimeout(timeout time.Duration) *CreateGiteaCredentialsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create gitea credentials params
func (o *CreateGiteaCredentialsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create gitea credentials params
func (o *CreateGiteaCredentialsParams) WithContext(ctx context.Context) *CreateGiteaCredentialsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create gitea credentials params
func (o *CreateGiteaCredentialsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create gitea credentials params
func (o *CreateGiteaCredentialsParams) WithHTTPClient(client *http.Client) *CreateGiteaCredentialsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create gitea credentials params
func (o *CreateGiteaCredentialsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create gitea credentials params
func (o *CreateGiteaCredentialsParams) WithBody(body garm_params.CreateGiteaCredentialsParams) *CreateGiteaCredentialsParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create gitea credentials params
func (o *CreateGiteaCredentialsParams) SetBody(body garm_params.CreateGiteaCredentialsParams) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *CreateGiteaCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// CreateGiteaCredentialsReader is a Reader for the CreateGiteaCredentials structure.
type CreateGiteaCredentialsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateGiteaCredentialsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateGiteaCredentialsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewCreateGiteaCredentialsBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[POST /gitea/credentials] CreateGiteaCredentials", response, response.Code())
}
}
// NewCreateGiteaCredentialsOK creates a CreateGiteaCredentialsOK with default headers values
func NewCreateGiteaCredentialsOK() *CreateGiteaCredentialsOK {
return &CreateGiteaCredentialsOK{}
}
/*
CreateGiteaCredentialsOK describes a response with status code 200, with default header values.
ForgeCredentials
*/
type CreateGiteaCredentialsOK struct {
Payload garm_params.ForgeCredentials
}
// IsSuccess returns true when this create gitea credentials o k response has a 2xx status code
func (o *CreateGiteaCredentialsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this create gitea credentials o k response has a 3xx status code
func (o *CreateGiteaCredentialsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this create gitea credentials o k response has a 4xx status code
func (o *CreateGiteaCredentialsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this create gitea credentials o k response has a 5xx status code
func (o *CreateGiteaCredentialsOK) IsServerError() bool {
return false
}
// IsCode returns true when this create gitea credentials o k response a status code equal to that given
func (o *CreateGiteaCredentialsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the create gitea credentials o k response
func (o *CreateGiteaCredentialsOK) Code() int {
return 200
}
func (o *CreateGiteaCredentialsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /gitea/credentials][%d] createGiteaCredentialsOK %s", 200, payload)
}
func (o *CreateGiteaCredentialsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /gitea/credentials][%d] createGiteaCredentialsOK %s", 200, payload)
}
func (o *CreateGiteaCredentialsOK) GetPayload() garm_params.ForgeCredentials {
return o.Payload
}
func (o *CreateGiteaCredentialsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateGiteaCredentialsBadRequest creates a CreateGiteaCredentialsBadRequest with default headers values
func NewCreateGiteaCredentialsBadRequest() *CreateGiteaCredentialsBadRequest {
return &CreateGiteaCredentialsBadRequest{}
}
/*
CreateGiteaCredentialsBadRequest describes a response with status code 400, with default header values.
APIErrorResponse
*/
type CreateGiteaCredentialsBadRequest struct {
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this create gitea credentials bad request response has a 2xx status code
func (o *CreateGiteaCredentialsBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this create gitea credentials bad request response has a 3xx status code
func (o *CreateGiteaCredentialsBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this create gitea credentials bad request response has a 4xx status code
func (o *CreateGiteaCredentialsBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this create gitea credentials bad request response has a 5xx status code
func (o *CreateGiteaCredentialsBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this create gitea credentials bad request response a status code equal to that given
func (o *CreateGiteaCredentialsBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the create gitea credentials bad request response
func (o *CreateGiteaCredentialsBadRequest) Code() int {
return 400
}
func (o *CreateGiteaCredentialsBadRequest) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /gitea/credentials][%d] createGiteaCredentialsBadRequest %s", 400, payload)
}
func (o *CreateGiteaCredentialsBadRequest) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /gitea/credentials][%d] createGiteaCredentialsBadRequest %s", 400, payload)
}
func (o *CreateGiteaCredentialsBadRequest) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *CreateGiteaCredentialsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -58,14 +58,24 @@ type ClientOption func(*runtime.ClientOperation)
type ClientService interface {
CreateCredentials(params *CreateCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateCredentialsOK, error)
CreateGiteaCredentials(params *CreateGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGiteaCredentialsOK, error)
DeleteCredentials(params *DeleteCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
DeleteGiteaCredentials(params *DeleteGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
GetCredentials(params *GetCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCredentialsOK, error)
GetGiteaCredentials(params *GetGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGiteaCredentialsOK, error)
ListCredentials(params *ListCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListCredentialsOK, error)
ListGiteaCredentials(params *ListGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListGiteaCredentialsOK, error)
UpdateCredentials(params *UpdateCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateCredentialsOK, error)
UpdateGiteaCredentials(params *UpdateGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGiteaCredentialsOK, error)
SetTransport(transport runtime.ClientTransport)
}
@ -108,6 +118,45 @@ func (a *Client) CreateCredentials(params *CreateCredentialsParams, authInfo run
panic(msg)
}
/*
CreateGiteaCredentials creates a gitea credential
*/
func (a *Client) CreateGiteaCredentials(params *CreateGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGiteaCredentialsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateGiteaCredentialsParams()
}
op := &runtime.ClientOperation{
ID: "CreateGiteaCredentials",
Method: "POST",
PathPattern: "/gitea/credentials",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateGiteaCredentialsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateGiteaCredentialsOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for CreateGiteaCredentials: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
DeleteCredentials deletes a git hub credential
*/
@ -140,6 +189,38 @@ func (a *Client) DeleteCredentials(params *DeleteCredentialsParams, authInfo run
return nil
}
/*
DeleteGiteaCredentials deletes a gitea credential
*/
func (a *Client) DeleteGiteaCredentials(params *DeleteGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteGiteaCredentialsParams()
}
op := &runtime.ClientOperation{
ID: "DeleteGiteaCredentials",
Method: "DELETE",
PathPattern: "/gitea/credentials/{id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &DeleteGiteaCredentialsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
_, err := a.transport.Submit(op)
if err != nil {
return err
}
return nil
}
/*
GetCredentials gets a git hub credential
*/
@ -179,6 +260,45 @@ func (a *Client) GetCredentials(params *GetCredentialsParams, authInfo runtime.C
panic(msg)
}
/*
GetGiteaCredentials gets a gitea credential
*/
func (a *Client) GetGiteaCredentials(params *GetGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGiteaCredentialsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetGiteaCredentialsParams()
}
op := &runtime.ClientOperation{
ID: "GetGiteaCredentials",
Method: "GET",
PathPattern: "/gitea/credentials/{id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetGiteaCredentialsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetGiteaCredentialsOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for GetGiteaCredentials: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
ListCredentials lists all credentials
*/
@ -218,6 +338,45 @@ func (a *Client) ListCredentials(params *ListCredentialsParams, authInfo runtime
panic(msg)
}
/*
ListGiteaCredentials lists all credentials
*/
func (a *Client) ListGiteaCredentials(params *ListGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListGiteaCredentialsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListGiteaCredentialsParams()
}
op := &runtime.ClientOperation{
ID: "ListGiteaCredentials",
Method: "GET",
PathPattern: "/gitea/credentials",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListGiteaCredentialsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListGiteaCredentialsOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for ListGiteaCredentials: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
UpdateCredentials updates a git hub credential
*/
@ -257,6 +416,45 @@ func (a *Client) UpdateCredentials(params *UpdateCredentialsParams, authInfo run
panic(msg)
}
/*
UpdateGiteaCredentials updates a gitea credential
*/
func (a *Client) UpdateGiteaCredentials(params *UpdateGiteaCredentialsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGiteaCredentialsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateGiteaCredentialsParams()
}
op := &runtime.ClientOperation{
ID: "UpdateGiteaCredentials",
Method: "PUT",
PathPattern: "/gitea/credentials/{id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &UpdateGiteaCredentialsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*UpdateGiteaCredentialsOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for UpdateGiteaCredentials: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport

View file

@ -0,0 +1,152 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewDeleteGiteaCredentialsParams creates a new DeleteGiteaCredentialsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewDeleteGiteaCredentialsParams() *DeleteGiteaCredentialsParams {
return &DeleteGiteaCredentialsParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteGiteaCredentialsParamsWithTimeout creates a new DeleteGiteaCredentialsParams object
// with the ability to set a timeout on a request.
func NewDeleteGiteaCredentialsParamsWithTimeout(timeout time.Duration) *DeleteGiteaCredentialsParams {
return &DeleteGiteaCredentialsParams{
timeout: timeout,
}
}
// NewDeleteGiteaCredentialsParamsWithContext creates a new DeleteGiteaCredentialsParams object
// with the ability to set a context for a request.
func NewDeleteGiteaCredentialsParamsWithContext(ctx context.Context) *DeleteGiteaCredentialsParams {
return &DeleteGiteaCredentialsParams{
Context: ctx,
}
}
// NewDeleteGiteaCredentialsParamsWithHTTPClient creates a new DeleteGiteaCredentialsParams object
// with the ability to set a custom HTTPClient for a request.
func NewDeleteGiteaCredentialsParamsWithHTTPClient(client *http.Client) *DeleteGiteaCredentialsParams {
return &DeleteGiteaCredentialsParams{
HTTPClient: client,
}
}
/*
DeleteGiteaCredentialsParams contains all the parameters to send to the API endpoint
for the delete gitea credentials operation.
Typically these are written to a http.Request.
*/
type DeleteGiteaCredentialsParams struct {
/* ID.
ID of the Gitea credential.
*/
ID int64
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the delete gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteGiteaCredentialsParams) WithDefaults() *DeleteGiteaCredentialsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the delete gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteGiteaCredentialsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the delete gitea credentials params
func (o *DeleteGiteaCredentialsParams) WithTimeout(timeout time.Duration) *DeleteGiteaCredentialsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete gitea credentials params
func (o *DeleteGiteaCredentialsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete gitea credentials params
func (o *DeleteGiteaCredentialsParams) WithContext(ctx context.Context) *DeleteGiteaCredentialsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete gitea credentials params
func (o *DeleteGiteaCredentialsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete gitea credentials params
func (o *DeleteGiteaCredentialsParams) WithHTTPClient(client *http.Client) *DeleteGiteaCredentialsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete gitea credentials params
func (o *DeleteGiteaCredentialsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithID adds the id to the delete gitea credentials params
func (o *DeleteGiteaCredentialsParams) WithID(id int64) *DeleteGiteaCredentialsParams {
o.SetID(id)
return o
}
// SetID adds the id to the delete gitea credentials params
func (o *DeleteGiteaCredentialsParams) SetID(id int64) {
o.ID = id
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteGiteaCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param id
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,106 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
)
// DeleteGiteaCredentialsReader is a Reader for the DeleteGiteaCredentials structure.
type DeleteGiteaCredentialsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteGiteaCredentialsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
result := NewDeleteGiteaCredentialsDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
// NewDeleteGiteaCredentialsDefault creates a DeleteGiteaCredentialsDefault with default headers values
func NewDeleteGiteaCredentialsDefault(code int) *DeleteGiteaCredentialsDefault {
return &DeleteGiteaCredentialsDefault{
_statusCode: code,
}
}
/*
DeleteGiteaCredentialsDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type DeleteGiteaCredentialsDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this delete gitea credentials default response has a 2xx status code
func (o *DeleteGiteaCredentialsDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this delete gitea credentials default response has a 3xx status code
func (o *DeleteGiteaCredentialsDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this delete gitea credentials default response has a 4xx status code
func (o *DeleteGiteaCredentialsDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this delete gitea credentials default response has a 5xx status code
func (o *DeleteGiteaCredentialsDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this delete gitea credentials default response a status code equal to that given
func (o *DeleteGiteaCredentialsDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the delete gitea credentials default response
func (o *DeleteGiteaCredentialsDefault) Code() int {
return o._statusCode
}
func (o *DeleteGiteaCredentialsDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[DELETE /gitea/credentials/{id}][%d] DeleteGiteaCredentials default %s", o._statusCode, payload)
}
func (o *DeleteGiteaCredentialsDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[DELETE /gitea/credentials/{id}][%d] DeleteGiteaCredentials default %s", o._statusCode, payload)
}
func (o *DeleteGiteaCredentialsDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *DeleteGiteaCredentialsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -50,10 +50,10 @@ func NewGetCredentialsOK() *GetCredentialsOK {
/*
GetCredentialsOK describes a response with status code 200, with default header values.
GithubCredentials
ForgeCredentials
*/
type GetCredentialsOK struct {
Payload garm_params.GithubCredentials
Payload garm_params.ForgeCredentials
}
// IsSuccess returns true when this get credentials o k response has a 2xx status code
@ -96,7 +96,7 @@ func (o *GetCredentialsOK) String() string {
return fmt.Sprintf("[GET /github/credentials/{id}][%d] getCredentialsOK %s", 200, payload)
}
func (o *GetCredentialsOK) GetPayload() garm_params.GithubCredentials {
func (o *GetCredentialsOK) GetPayload() garm_params.ForgeCredentials {
return o.Payload
}

View file

@ -0,0 +1,152 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewGetGiteaCredentialsParams creates a new GetGiteaCredentialsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewGetGiteaCredentialsParams() *GetGiteaCredentialsParams {
return &GetGiteaCredentialsParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetGiteaCredentialsParamsWithTimeout creates a new GetGiteaCredentialsParams object
// with the ability to set a timeout on a request.
func NewGetGiteaCredentialsParamsWithTimeout(timeout time.Duration) *GetGiteaCredentialsParams {
return &GetGiteaCredentialsParams{
timeout: timeout,
}
}
// NewGetGiteaCredentialsParamsWithContext creates a new GetGiteaCredentialsParams object
// with the ability to set a context for a request.
func NewGetGiteaCredentialsParamsWithContext(ctx context.Context) *GetGiteaCredentialsParams {
return &GetGiteaCredentialsParams{
Context: ctx,
}
}
// NewGetGiteaCredentialsParamsWithHTTPClient creates a new GetGiteaCredentialsParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetGiteaCredentialsParamsWithHTTPClient(client *http.Client) *GetGiteaCredentialsParams {
return &GetGiteaCredentialsParams{
HTTPClient: client,
}
}
/*
GetGiteaCredentialsParams contains all the parameters to send to the API endpoint
for the get gitea credentials operation.
Typically these are written to a http.Request.
*/
type GetGiteaCredentialsParams struct {
/* ID.
ID of the Gitea credential.
*/
ID int64
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetGiteaCredentialsParams) WithDefaults() *GetGiteaCredentialsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetGiteaCredentialsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get gitea credentials params
func (o *GetGiteaCredentialsParams) WithTimeout(timeout time.Duration) *GetGiteaCredentialsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get gitea credentials params
func (o *GetGiteaCredentialsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get gitea credentials params
func (o *GetGiteaCredentialsParams) WithContext(ctx context.Context) *GetGiteaCredentialsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get gitea credentials params
func (o *GetGiteaCredentialsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get gitea credentials params
func (o *GetGiteaCredentialsParams) WithHTTPClient(client *http.Client) *GetGiteaCredentialsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get gitea credentials params
func (o *GetGiteaCredentialsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithID adds the id to the get gitea credentials params
func (o *GetGiteaCredentialsParams) WithID(id int64) *GetGiteaCredentialsParams {
o.SetID(id)
return o
}
// SetID adds the id to the get gitea credentials params
func (o *GetGiteaCredentialsParams) SetID(id int64) {
o.ID = id
}
// WriteToRequest writes these params to a swagger request
func (o *GetGiteaCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param id
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// GetGiteaCredentialsReader is a Reader for the GetGiteaCredentials structure.
type GetGiteaCredentialsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetGiteaCredentialsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetGiteaCredentialsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewGetGiteaCredentialsBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[GET /gitea/credentials/{id}] GetGiteaCredentials", response, response.Code())
}
}
// NewGetGiteaCredentialsOK creates a GetGiteaCredentialsOK with default headers values
func NewGetGiteaCredentialsOK() *GetGiteaCredentialsOK {
return &GetGiteaCredentialsOK{}
}
/*
GetGiteaCredentialsOK describes a response with status code 200, with default header values.
ForgeCredentials
*/
type GetGiteaCredentialsOK struct {
Payload garm_params.ForgeCredentials
}
// IsSuccess returns true when this get gitea credentials o k response has a 2xx status code
func (o *GetGiteaCredentialsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get gitea credentials o k response has a 3xx status code
func (o *GetGiteaCredentialsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get gitea credentials o k response has a 4xx status code
func (o *GetGiteaCredentialsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get gitea credentials o k response has a 5xx status code
func (o *GetGiteaCredentialsOK) IsServerError() bool {
return false
}
// IsCode returns true when this get gitea credentials o k response a status code equal to that given
func (o *GetGiteaCredentialsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get gitea credentials o k response
func (o *GetGiteaCredentialsOK) Code() int {
return 200
}
func (o *GetGiteaCredentialsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/credentials/{id}][%d] getGiteaCredentialsOK %s", 200, payload)
}
func (o *GetGiteaCredentialsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/credentials/{id}][%d] getGiteaCredentialsOK %s", 200, payload)
}
func (o *GetGiteaCredentialsOK) GetPayload() garm_params.ForgeCredentials {
return o.Payload
}
func (o *GetGiteaCredentialsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetGiteaCredentialsBadRequest creates a GetGiteaCredentialsBadRequest with default headers values
func NewGetGiteaCredentialsBadRequest() *GetGiteaCredentialsBadRequest {
return &GetGiteaCredentialsBadRequest{}
}
/*
GetGiteaCredentialsBadRequest describes a response with status code 400, with default header values.
APIErrorResponse
*/
type GetGiteaCredentialsBadRequest struct {
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this get gitea credentials bad request response has a 2xx status code
func (o *GetGiteaCredentialsBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this get gitea credentials bad request response has a 3xx status code
func (o *GetGiteaCredentialsBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this get gitea credentials bad request response has a 4xx status code
func (o *GetGiteaCredentialsBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this get gitea credentials bad request response has a 5xx status code
func (o *GetGiteaCredentialsBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this get gitea credentials bad request response a status code equal to that given
func (o *GetGiteaCredentialsBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the get gitea credentials bad request response
func (o *GetGiteaCredentialsBadRequest) Code() int {
return 400
}
func (o *GetGiteaCredentialsBadRequest) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/credentials/{id}][%d] getGiteaCredentialsBadRequest %s", 400, payload)
}
func (o *GetGiteaCredentialsBadRequest) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/credentials/{id}][%d] getGiteaCredentialsBadRequest %s", 400, payload)
}
func (o *GetGiteaCredentialsBadRequest) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *GetGiteaCredentialsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,128 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListGiteaCredentialsParams creates a new ListGiteaCredentialsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListGiteaCredentialsParams() *ListGiteaCredentialsParams {
return &ListGiteaCredentialsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListGiteaCredentialsParamsWithTimeout creates a new ListGiteaCredentialsParams object
// with the ability to set a timeout on a request.
func NewListGiteaCredentialsParamsWithTimeout(timeout time.Duration) *ListGiteaCredentialsParams {
return &ListGiteaCredentialsParams{
timeout: timeout,
}
}
// NewListGiteaCredentialsParamsWithContext creates a new ListGiteaCredentialsParams object
// with the ability to set a context for a request.
func NewListGiteaCredentialsParamsWithContext(ctx context.Context) *ListGiteaCredentialsParams {
return &ListGiteaCredentialsParams{
Context: ctx,
}
}
// NewListGiteaCredentialsParamsWithHTTPClient creates a new ListGiteaCredentialsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListGiteaCredentialsParamsWithHTTPClient(client *http.Client) *ListGiteaCredentialsParams {
return &ListGiteaCredentialsParams{
HTTPClient: client,
}
}
/*
ListGiteaCredentialsParams contains all the parameters to send to the API endpoint
for the list gitea credentials operation.
Typically these are written to a http.Request.
*/
type ListGiteaCredentialsParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListGiteaCredentialsParams) WithDefaults() *ListGiteaCredentialsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListGiteaCredentialsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list gitea credentials params
func (o *ListGiteaCredentialsParams) WithTimeout(timeout time.Duration) *ListGiteaCredentialsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list gitea credentials params
func (o *ListGiteaCredentialsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list gitea credentials params
func (o *ListGiteaCredentialsParams) WithContext(ctx context.Context) *ListGiteaCredentialsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list gitea credentials params
func (o *ListGiteaCredentialsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list gitea credentials params
func (o *ListGiteaCredentialsParams) WithHTTPClient(client *http.Client) *ListGiteaCredentialsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list gitea credentials params
func (o *ListGiteaCredentialsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ListGiteaCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListGiteaCredentialsReader is a Reader for the ListGiteaCredentials structure.
type ListGiteaCredentialsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListGiteaCredentialsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListGiteaCredentialsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewListGiteaCredentialsBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[GET /gitea/credentials] ListGiteaCredentials", response, response.Code())
}
}
// NewListGiteaCredentialsOK creates a ListGiteaCredentialsOK with default headers values
func NewListGiteaCredentialsOK() *ListGiteaCredentialsOK {
return &ListGiteaCredentialsOK{}
}
/*
ListGiteaCredentialsOK describes a response with status code 200, with default header values.
Credentials
*/
type ListGiteaCredentialsOK struct {
Payload garm_params.Credentials
}
// IsSuccess returns true when this list gitea credentials o k response has a 2xx status code
func (o *ListGiteaCredentialsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list gitea credentials o k response has a 3xx status code
func (o *ListGiteaCredentialsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list gitea credentials o k response has a 4xx status code
func (o *ListGiteaCredentialsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list gitea credentials o k response has a 5xx status code
func (o *ListGiteaCredentialsOK) IsServerError() bool {
return false
}
// IsCode returns true when this list gitea credentials o k response a status code equal to that given
func (o *ListGiteaCredentialsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list gitea credentials o k response
func (o *ListGiteaCredentialsOK) Code() int {
return 200
}
func (o *ListGiteaCredentialsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/credentials][%d] listGiteaCredentialsOK %s", 200, payload)
}
func (o *ListGiteaCredentialsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/credentials][%d] listGiteaCredentialsOK %s", 200, payload)
}
func (o *ListGiteaCredentialsOK) GetPayload() garm_params.Credentials {
return o.Payload
}
func (o *ListGiteaCredentialsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListGiteaCredentialsBadRequest creates a ListGiteaCredentialsBadRequest with default headers values
func NewListGiteaCredentialsBadRequest() *ListGiteaCredentialsBadRequest {
return &ListGiteaCredentialsBadRequest{}
}
/*
ListGiteaCredentialsBadRequest describes a response with status code 400, with default header values.
APIErrorResponse
*/
type ListGiteaCredentialsBadRequest struct {
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list gitea credentials bad request response has a 2xx status code
func (o *ListGiteaCredentialsBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this list gitea credentials bad request response has a 3xx status code
func (o *ListGiteaCredentialsBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this list gitea credentials bad request response has a 4xx status code
func (o *ListGiteaCredentialsBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this list gitea credentials bad request response has a 5xx status code
func (o *ListGiteaCredentialsBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this list gitea credentials bad request response a status code equal to that given
func (o *ListGiteaCredentialsBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the list gitea credentials bad request response
func (o *ListGiteaCredentialsBadRequest) Code() int {
return 400
}
func (o *ListGiteaCredentialsBadRequest) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/credentials][%d] listGiteaCredentialsBadRequest %s", 400, payload)
}
func (o *ListGiteaCredentialsBadRequest) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/credentials][%d] listGiteaCredentialsBadRequest %s", 400, payload)
}
func (o *ListGiteaCredentialsBadRequest) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListGiteaCredentialsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -50,10 +50,10 @@ func NewUpdateCredentialsOK() *UpdateCredentialsOK {
/*
UpdateCredentialsOK describes a response with status code 200, with default header values.
GithubCredentials
ForgeCredentials
*/
type UpdateCredentialsOK struct {
Payload garm_params.GithubCredentials
Payload garm_params.ForgeCredentials
}
// IsSuccess returns true when this update credentials o k response has a 2xx status code
@ -96,7 +96,7 @@ func (o *UpdateCredentialsOK) String() string {
return fmt.Sprintf("[PUT /github/credentials/{id}][%d] updateCredentialsOK %s", 200, payload)
}
func (o *UpdateCredentialsOK) GetPayload() garm_params.GithubCredentials {
func (o *UpdateCredentialsOK) GetPayload() garm_params.ForgeCredentials {
return o.Payload
}

View file

@ -0,0 +1,174 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
garm_params "github.com/cloudbase/garm/params"
)
// NewUpdateGiteaCredentialsParams creates a new UpdateGiteaCredentialsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewUpdateGiteaCredentialsParams() *UpdateGiteaCredentialsParams {
return &UpdateGiteaCredentialsParams{
timeout: cr.DefaultTimeout,
}
}
// NewUpdateGiteaCredentialsParamsWithTimeout creates a new UpdateGiteaCredentialsParams object
// with the ability to set a timeout on a request.
func NewUpdateGiteaCredentialsParamsWithTimeout(timeout time.Duration) *UpdateGiteaCredentialsParams {
return &UpdateGiteaCredentialsParams{
timeout: timeout,
}
}
// NewUpdateGiteaCredentialsParamsWithContext creates a new UpdateGiteaCredentialsParams object
// with the ability to set a context for a request.
func NewUpdateGiteaCredentialsParamsWithContext(ctx context.Context) *UpdateGiteaCredentialsParams {
return &UpdateGiteaCredentialsParams{
Context: ctx,
}
}
// NewUpdateGiteaCredentialsParamsWithHTTPClient creates a new UpdateGiteaCredentialsParams object
// with the ability to set a custom HTTPClient for a request.
func NewUpdateGiteaCredentialsParamsWithHTTPClient(client *http.Client) *UpdateGiteaCredentialsParams {
return &UpdateGiteaCredentialsParams{
HTTPClient: client,
}
}
/*
UpdateGiteaCredentialsParams contains all the parameters to send to the API endpoint
for the update gitea credentials operation.
Typically these are written to a http.Request.
*/
type UpdateGiteaCredentialsParams struct {
/* Body.
Parameters used when updating a Gitea credential.
*/
Body garm_params.UpdateGiteaCredentialsParams
/* ID.
ID of the Gitea credential.
*/
ID int64
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the update gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateGiteaCredentialsParams) WithDefaults() *UpdateGiteaCredentialsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the update gitea credentials params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateGiteaCredentialsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) WithTimeout(timeout time.Duration) *UpdateGiteaCredentialsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) WithContext(ctx context.Context) *UpdateGiteaCredentialsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) WithHTTPClient(client *http.Client) *UpdateGiteaCredentialsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) WithBody(body garm_params.UpdateGiteaCredentialsParams) *UpdateGiteaCredentialsParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) SetBody(body garm_params.UpdateGiteaCredentialsParams) {
o.Body = body
}
// WithID adds the id to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) WithID(id int64) *UpdateGiteaCredentialsParams {
o.SetID(id)
return o
}
// SetID adds the id to the update gitea credentials params
func (o *UpdateGiteaCredentialsParams) SetID(id int64) {
o.ID = id
}
// WriteToRequest writes these params to a swagger request
func (o *UpdateGiteaCredentialsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param id
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package credentials
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// UpdateGiteaCredentialsReader is a Reader for the UpdateGiteaCredentials structure.
type UpdateGiteaCredentialsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UpdateGiteaCredentialsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewUpdateGiteaCredentialsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewUpdateGiteaCredentialsBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[PUT /gitea/credentials/{id}] UpdateGiteaCredentials", response, response.Code())
}
}
// NewUpdateGiteaCredentialsOK creates a UpdateGiteaCredentialsOK with default headers values
func NewUpdateGiteaCredentialsOK() *UpdateGiteaCredentialsOK {
return &UpdateGiteaCredentialsOK{}
}
/*
UpdateGiteaCredentialsOK describes a response with status code 200, with default header values.
ForgeCredentials
*/
type UpdateGiteaCredentialsOK struct {
Payload garm_params.ForgeCredentials
}
// IsSuccess returns true when this update gitea credentials o k response has a 2xx status code
func (o *UpdateGiteaCredentialsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this update gitea credentials o k response has a 3xx status code
func (o *UpdateGiteaCredentialsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this update gitea credentials o k response has a 4xx status code
func (o *UpdateGiteaCredentialsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this update gitea credentials o k response has a 5xx status code
func (o *UpdateGiteaCredentialsOK) IsServerError() bool {
return false
}
// IsCode returns true when this update gitea credentials o k response a status code equal to that given
func (o *UpdateGiteaCredentialsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the update gitea credentials o k response
func (o *UpdateGiteaCredentialsOK) Code() int {
return 200
}
func (o *UpdateGiteaCredentialsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /gitea/credentials/{id}][%d] updateGiteaCredentialsOK %s", 200, payload)
}
func (o *UpdateGiteaCredentialsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /gitea/credentials/{id}][%d] updateGiteaCredentialsOK %s", 200, payload)
}
func (o *UpdateGiteaCredentialsOK) GetPayload() garm_params.ForgeCredentials {
return o.Payload
}
func (o *UpdateGiteaCredentialsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewUpdateGiteaCredentialsBadRequest creates a UpdateGiteaCredentialsBadRequest with default headers values
func NewUpdateGiteaCredentialsBadRequest() *UpdateGiteaCredentialsBadRequest {
return &UpdateGiteaCredentialsBadRequest{}
}
/*
UpdateGiteaCredentialsBadRequest describes a response with status code 400, with default header values.
APIErrorResponse
*/
type UpdateGiteaCredentialsBadRequest struct {
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this update gitea credentials bad request response has a 2xx status code
func (o *UpdateGiteaCredentialsBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this update gitea credentials bad request response has a 3xx status code
func (o *UpdateGiteaCredentialsBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this update gitea credentials bad request response has a 4xx status code
func (o *UpdateGiteaCredentialsBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this update gitea credentials bad request response has a 5xx status code
func (o *UpdateGiteaCredentialsBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this update gitea credentials bad request response a status code equal to that given
func (o *UpdateGiteaCredentialsBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the update gitea credentials bad request response
func (o *UpdateGiteaCredentialsBadRequest) Code() int {
return 400
}
func (o *UpdateGiteaCredentialsBadRequest) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /gitea/credentials/{id}][%d] updateGiteaCredentialsBadRequest %s", 400, payload)
}
func (o *UpdateGiteaCredentialsBadRequest) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /gitea/credentials/{id}][%d] updateGiteaCredentialsBadRequest %s", 400, payload)
}
func (o *UpdateGiteaCredentialsBadRequest) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *UpdateGiteaCredentialsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewCreateGiteaEndpointParams creates a new CreateGiteaEndpointParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewCreateGiteaEndpointParams() *CreateGiteaEndpointParams {
return &CreateGiteaEndpointParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateGiteaEndpointParamsWithTimeout creates a new CreateGiteaEndpointParams object
// with the ability to set a timeout on a request.
func NewCreateGiteaEndpointParamsWithTimeout(timeout time.Duration) *CreateGiteaEndpointParams {
return &CreateGiteaEndpointParams{
timeout: timeout,
}
}
// NewCreateGiteaEndpointParamsWithContext creates a new CreateGiteaEndpointParams object
// with the ability to set a context for a request.
func NewCreateGiteaEndpointParamsWithContext(ctx context.Context) *CreateGiteaEndpointParams {
return &CreateGiteaEndpointParams{
Context: ctx,
}
}
// NewCreateGiteaEndpointParamsWithHTTPClient creates a new CreateGiteaEndpointParams object
// with the ability to set a custom HTTPClient for a request.
func NewCreateGiteaEndpointParamsWithHTTPClient(client *http.Client) *CreateGiteaEndpointParams {
return &CreateGiteaEndpointParams{
HTTPClient: client,
}
}
/*
CreateGiteaEndpointParams contains all the parameters to send to the API endpoint
for the create gitea endpoint operation.
Typically these are written to a http.Request.
*/
type CreateGiteaEndpointParams struct {
/* Body.
Parameters used when creating a Gitea endpoint.
*/
Body garm_params.CreateGiteaEndpointParams
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the create gitea endpoint params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateGiteaEndpointParams) WithDefaults() *CreateGiteaEndpointParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the create gitea endpoint params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateGiteaEndpointParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the create gitea endpoint params
func (o *CreateGiteaEndpointParams) WithTimeout(timeout time.Duration) *CreateGiteaEndpointParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create gitea endpoint params
func (o *CreateGiteaEndpointParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create gitea endpoint params
func (o *CreateGiteaEndpointParams) WithContext(ctx context.Context) *CreateGiteaEndpointParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create gitea endpoint params
func (o *CreateGiteaEndpointParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create gitea endpoint params
func (o *CreateGiteaEndpointParams) WithHTTPClient(client *http.Client) *CreateGiteaEndpointParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create gitea endpoint params
func (o *CreateGiteaEndpointParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create gitea endpoint params
func (o *CreateGiteaEndpointParams) WithBody(body garm_params.CreateGiteaEndpointParams) *CreateGiteaEndpointParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create gitea endpoint params
func (o *CreateGiteaEndpointParams) SetBody(body garm_params.CreateGiteaEndpointParams) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *CreateGiteaEndpointParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// CreateGiteaEndpointReader is a Reader for the CreateGiteaEndpoint structure.
type CreateGiteaEndpointReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateGiteaEndpointReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateGiteaEndpointOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewCreateGiteaEndpointDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewCreateGiteaEndpointOK creates a CreateGiteaEndpointOK with default headers values
func NewCreateGiteaEndpointOK() *CreateGiteaEndpointOK {
return &CreateGiteaEndpointOK{}
}
/*
CreateGiteaEndpointOK describes a response with status code 200, with default header values.
ForgeEndpoint
*/
type CreateGiteaEndpointOK struct {
Payload garm_params.ForgeEndpoint
}
// IsSuccess returns true when this create gitea endpoint o k response has a 2xx status code
func (o *CreateGiteaEndpointOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this create gitea endpoint o k response has a 3xx status code
func (o *CreateGiteaEndpointOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this create gitea endpoint o k response has a 4xx status code
func (o *CreateGiteaEndpointOK) IsClientError() bool {
return false
}
// IsServerError returns true when this create gitea endpoint o k response has a 5xx status code
func (o *CreateGiteaEndpointOK) IsServerError() bool {
return false
}
// IsCode returns true when this create gitea endpoint o k response a status code equal to that given
func (o *CreateGiteaEndpointOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the create gitea endpoint o k response
func (o *CreateGiteaEndpointOK) Code() int {
return 200
}
func (o *CreateGiteaEndpointOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /gitea/endpoints][%d] createGiteaEndpointOK %s", 200, payload)
}
func (o *CreateGiteaEndpointOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /gitea/endpoints][%d] createGiteaEndpointOK %s", 200, payload)
}
func (o *CreateGiteaEndpointOK) GetPayload() garm_params.ForgeEndpoint {
return o.Payload
}
func (o *CreateGiteaEndpointOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateGiteaEndpointDefault creates a CreateGiteaEndpointDefault with default headers values
func NewCreateGiteaEndpointDefault(code int) *CreateGiteaEndpointDefault {
return &CreateGiteaEndpointDefault{
_statusCode: code,
}
}
/*
CreateGiteaEndpointDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type CreateGiteaEndpointDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this create gitea endpoint default response has a 2xx status code
func (o *CreateGiteaEndpointDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this create gitea endpoint default response has a 3xx status code
func (o *CreateGiteaEndpointDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this create gitea endpoint default response has a 4xx status code
func (o *CreateGiteaEndpointDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this create gitea endpoint default response has a 5xx status code
func (o *CreateGiteaEndpointDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this create gitea endpoint default response a status code equal to that given
func (o *CreateGiteaEndpointDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the create gitea endpoint default response
func (o *CreateGiteaEndpointDefault) Code() int {
return o._statusCode
}
func (o *CreateGiteaEndpointDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /gitea/endpoints][%d] CreateGiteaEndpoint default %s", o._statusCode, payload)
}
func (o *CreateGiteaEndpointDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /gitea/endpoints][%d] CreateGiteaEndpoint default %s", o._statusCode, payload)
}
func (o *CreateGiteaEndpointDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *CreateGiteaEndpointDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -51,10 +51,10 @@ func NewCreateGithubEndpointOK() *CreateGithubEndpointOK {
/*
CreateGithubEndpointOK describes a response with status code 200, with default header values.
GithubEndpoint
ForgeEndpoint
*/
type CreateGithubEndpointOK struct {
Payload garm_params.GithubEndpoint
Payload garm_params.ForgeEndpoint
}
// IsSuccess returns true when this create github endpoint o k response has a 2xx status code
@ -97,7 +97,7 @@ func (o *CreateGithubEndpointOK) String() string {
return fmt.Sprintf("[POST /github/endpoints][%d] createGithubEndpointOK %s", 200, payload)
}
func (o *CreateGithubEndpointOK) GetPayload() garm_params.GithubEndpoint {
func (o *CreateGithubEndpointOK) GetPayload() garm_params.ForgeEndpoint {
return o.Payload
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewDeleteGiteaEndpointParams creates a new DeleteGiteaEndpointParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewDeleteGiteaEndpointParams() *DeleteGiteaEndpointParams {
return &DeleteGiteaEndpointParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteGiteaEndpointParamsWithTimeout creates a new DeleteGiteaEndpointParams object
// with the ability to set a timeout on a request.
func NewDeleteGiteaEndpointParamsWithTimeout(timeout time.Duration) *DeleteGiteaEndpointParams {
return &DeleteGiteaEndpointParams{
timeout: timeout,
}
}
// NewDeleteGiteaEndpointParamsWithContext creates a new DeleteGiteaEndpointParams object
// with the ability to set a context for a request.
func NewDeleteGiteaEndpointParamsWithContext(ctx context.Context) *DeleteGiteaEndpointParams {
return &DeleteGiteaEndpointParams{
Context: ctx,
}
}
// NewDeleteGiteaEndpointParamsWithHTTPClient creates a new DeleteGiteaEndpointParams object
// with the ability to set a custom HTTPClient for a request.
func NewDeleteGiteaEndpointParamsWithHTTPClient(client *http.Client) *DeleteGiteaEndpointParams {
return &DeleteGiteaEndpointParams{
HTTPClient: client,
}
}
/*
DeleteGiteaEndpointParams contains all the parameters to send to the API endpoint
for the delete gitea endpoint operation.
Typically these are written to a http.Request.
*/
type DeleteGiteaEndpointParams struct {
/* Name.
The name of the Gitea endpoint.
*/
Name string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the delete gitea endpoint params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteGiteaEndpointParams) WithDefaults() *DeleteGiteaEndpointParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the delete gitea endpoint params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteGiteaEndpointParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the delete gitea endpoint params
func (o *DeleteGiteaEndpointParams) WithTimeout(timeout time.Duration) *DeleteGiteaEndpointParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete gitea endpoint params
func (o *DeleteGiteaEndpointParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete gitea endpoint params
func (o *DeleteGiteaEndpointParams) WithContext(ctx context.Context) *DeleteGiteaEndpointParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete gitea endpoint params
func (o *DeleteGiteaEndpointParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete gitea endpoint params
func (o *DeleteGiteaEndpointParams) WithHTTPClient(client *http.Client) *DeleteGiteaEndpointParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete gitea endpoint params
func (o *DeleteGiteaEndpointParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithName adds the name to the delete gitea endpoint params
func (o *DeleteGiteaEndpointParams) WithName(name string) *DeleteGiteaEndpointParams {
o.SetName(name)
return o
}
// SetName adds the name to the delete gitea endpoint params
func (o *DeleteGiteaEndpointParams) SetName(name string) {
o.Name = name
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteGiteaEndpointParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param name
if err := r.SetPathParam("name", o.Name); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,106 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
)
// DeleteGiteaEndpointReader is a Reader for the DeleteGiteaEndpoint structure.
type DeleteGiteaEndpointReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteGiteaEndpointReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
result := NewDeleteGiteaEndpointDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
// NewDeleteGiteaEndpointDefault creates a DeleteGiteaEndpointDefault with default headers values
func NewDeleteGiteaEndpointDefault(code int) *DeleteGiteaEndpointDefault {
return &DeleteGiteaEndpointDefault{
_statusCode: code,
}
}
/*
DeleteGiteaEndpointDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type DeleteGiteaEndpointDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this delete gitea endpoint default response has a 2xx status code
func (o *DeleteGiteaEndpointDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this delete gitea endpoint default response has a 3xx status code
func (o *DeleteGiteaEndpointDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this delete gitea endpoint default response has a 4xx status code
func (o *DeleteGiteaEndpointDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this delete gitea endpoint default response has a 5xx status code
func (o *DeleteGiteaEndpointDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this delete gitea endpoint default response a status code equal to that given
func (o *DeleteGiteaEndpointDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the delete gitea endpoint default response
func (o *DeleteGiteaEndpointDefault) Code() int {
return o._statusCode
}
func (o *DeleteGiteaEndpointDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[DELETE /gitea/endpoints/{name}][%d] DeleteGiteaEndpoint default %s", o._statusCode, payload)
}
func (o *DeleteGiteaEndpointDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[DELETE /gitea/endpoints/{name}][%d] DeleteGiteaEndpoint default %s", o._statusCode, payload)
}
func (o *DeleteGiteaEndpointDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *DeleteGiteaEndpointDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -54,19 +54,67 @@ type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
CreateGiteaEndpoint(params *CreateGiteaEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGiteaEndpointOK, error)
CreateGithubEndpoint(params *CreateGithubEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGithubEndpointOK, error)
DeleteGiteaEndpoint(params *DeleteGiteaEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
DeleteGithubEndpoint(params *DeleteGithubEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
GetGiteaEndpoint(params *GetGiteaEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGiteaEndpointOK, error)
GetGithubEndpoint(params *GetGithubEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGithubEndpointOK, error)
ListGiteaEndpoints(params *ListGiteaEndpointsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListGiteaEndpointsOK, error)
ListGithubEndpoints(params *ListGithubEndpointsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListGithubEndpointsOK, error)
UpdateGiteaEndpoint(params *UpdateGiteaEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGiteaEndpointOK, error)
UpdateGithubEndpoint(params *UpdateGithubEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGithubEndpointOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
CreateGiteaEndpoint creates a gitea endpoint
*/
func (a *Client) CreateGiteaEndpoint(params *CreateGiteaEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGiteaEndpointOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateGiteaEndpointParams()
}
op := &runtime.ClientOperation{
ID: "CreateGiteaEndpoint",
Method: "POST",
PathPattern: "/gitea/endpoints",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateGiteaEndpointReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateGiteaEndpointOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*CreateGiteaEndpointDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
CreateGithubEndpoint creates a git hub endpoint
*/
@ -105,6 +153,38 @@ func (a *Client) CreateGithubEndpoint(params *CreateGithubEndpointParams, authIn
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
DeleteGiteaEndpoint deletes a gitea endpoint
*/
func (a *Client) DeleteGiteaEndpoint(params *DeleteGiteaEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteGiteaEndpointParams()
}
op := &runtime.ClientOperation{
ID: "DeleteGiteaEndpoint",
Method: "DELETE",
PathPattern: "/gitea/endpoints/{name}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &DeleteGiteaEndpointReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
_, err := a.transport.Submit(op)
if err != nil {
return err
}
return nil
}
/*
DeleteGithubEndpoint deletes a git hub endpoint
*/
@ -137,6 +217,44 @@ func (a *Client) DeleteGithubEndpoint(params *DeleteGithubEndpointParams, authIn
return nil
}
/*
GetGiteaEndpoint gets a gitea endpoint
*/
func (a *Client) GetGiteaEndpoint(params *GetGiteaEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGiteaEndpointOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetGiteaEndpointParams()
}
op := &runtime.ClientOperation{
ID: "GetGiteaEndpoint",
Method: "GET",
PathPattern: "/gitea/endpoints/{name}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetGiteaEndpointReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetGiteaEndpointOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*GetGiteaEndpointDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
GetGithubEndpoint gets a git hub endpoint
*/
@ -175,6 +293,44 @@ func (a *Client) GetGithubEndpoint(params *GetGithubEndpointParams, authInfo run
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListGiteaEndpoints lists all gitea endpoints
*/
func (a *Client) ListGiteaEndpoints(params *ListGiteaEndpointsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListGiteaEndpointsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListGiteaEndpointsParams()
}
op := &runtime.ClientOperation{
ID: "ListGiteaEndpoints",
Method: "GET",
PathPattern: "/gitea/endpoints",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListGiteaEndpointsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListGiteaEndpointsOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListGiteaEndpointsDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListGithubEndpoints lists all git hub endpoints
*/
@ -213,6 +369,44 @@ func (a *Client) ListGithubEndpoints(params *ListGithubEndpointsParams, authInfo
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
UpdateGiteaEndpoint updates a gitea endpoint
*/
func (a *Client) UpdateGiteaEndpoint(params *UpdateGiteaEndpointParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGiteaEndpointOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateGiteaEndpointParams()
}
op := &runtime.ClientOperation{
ID: "UpdateGiteaEndpoint",
Method: "PUT",
PathPattern: "/gitea/endpoints/{name}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &UpdateGiteaEndpointReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*UpdateGiteaEndpointOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*UpdateGiteaEndpointDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
UpdateGithubEndpoint updates a git hub endpoint
*/

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewGetGiteaEndpointParams creates a new GetGiteaEndpointParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewGetGiteaEndpointParams() *GetGiteaEndpointParams {
return &GetGiteaEndpointParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetGiteaEndpointParamsWithTimeout creates a new GetGiteaEndpointParams object
// with the ability to set a timeout on a request.
func NewGetGiteaEndpointParamsWithTimeout(timeout time.Duration) *GetGiteaEndpointParams {
return &GetGiteaEndpointParams{
timeout: timeout,
}
}
// NewGetGiteaEndpointParamsWithContext creates a new GetGiteaEndpointParams object
// with the ability to set a context for a request.
func NewGetGiteaEndpointParamsWithContext(ctx context.Context) *GetGiteaEndpointParams {
return &GetGiteaEndpointParams{
Context: ctx,
}
}
// NewGetGiteaEndpointParamsWithHTTPClient creates a new GetGiteaEndpointParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetGiteaEndpointParamsWithHTTPClient(client *http.Client) *GetGiteaEndpointParams {
return &GetGiteaEndpointParams{
HTTPClient: client,
}
}
/*
GetGiteaEndpointParams contains all the parameters to send to the API endpoint
for the get gitea endpoint operation.
Typically these are written to a http.Request.
*/
type GetGiteaEndpointParams struct {
/* Name.
The name of the Gitea endpoint.
*/
Name string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get gitea endpoint params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetGiteaEndpointParams) WithDefaults() *GetGiteaEndpointParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get gitea endpoint params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetGiteaEndpointParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get gitea endpoint params
func (o *GetGiteaEndpointParams) WithTimeout(timeout time.Duration) *GetGiteaEndpointParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get gitea endpoint params
func (o *GetGiteaEndpointParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get gitea endpoint params
func (o *GetGiteaEndpointParams) WithContext(ctx context.Context) *GetGiteaEndpointParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get gitea endpoint params
func (o *GetGiteaEndpointParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get gitea endpoint params
func (o *GetGiteaEndpointParams) WithHTTPClient(client *http.Client) *GetGiteaEndpointParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get gitea endpoint params
func (o *GetGiteaEndpointParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithName adds the name to the get gitea endpoint params
func (o *GetGiteaEndpointParams) WithName(name string) *GetGiteaEndpointParams {
o.SetName(name)
return o
}
// SetName adds the name to the get gitea endpoint params
func (o *GetGiteaEndpointParams) SetName(name string) {
o.Name = name
}
// WriteToRequest writes these params to a swagger request
func (o *GetGiteaEndpointParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param name
if err := r.SetPathParam("name", o.Name); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// GetGiteaEndpointReader is a Reader for the GetGiteaEndpoint structure.
type GetGiteaEndpointReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetGiteaEndpointReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetGiteaEndpointOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewGetGiteaEndpointDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewGetGiteaEndpointOK creates a GetGiteaEndpointOK with default headers values
func NewGetGiteaEndpointOK() *GetGiteaEndpointOK {
return &GetGiteaEndpointOK{}
}
/*
GetGiteaEndpointOK describes a response with status code 200, with default header values.
ForgeEndpoint
*/
type GetGiteaEndpointOK struct {
Payload garm_params.ForgeEndpoint
}
// IsSuccess returns true when this get gitea endpoint o k response has a 2xx status code
func (o *GetGiteaEndpointOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get gitea endpoint o k response has a 3xx status code
func (o *GetGiteaEndpointOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get gitea endpoint o k response has a 4xx status code
func (o *GetGiteaEndpointOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get gitea endpoint o k response has a 5xx status code
func (o *GetGiteaEndpointOK) IsServerError() bool {
return false
}
// IsCode returns true when this get gitea endpoint o k response a status code equal to that given
func (o *GetGiteaEndpointOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get gitea endpoint o k response
func (o *GetGiteaEndpointOK) Code() int {
return 200
}
func (o *GetGiteaEndpointOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/endpoints/{name}][%d] getGiteaEndpointOK %s", 200, payload)
}
func (o *GetGiteaEndpointOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/endpoints/{name}][%d] getGiteaEndpointOK %s", 200, payload)
}
func (o *GetGiteaEndpointOK) GetPayload() garm_params.ForgeEndpoint {
return o.Payload
}
func (o *GetGiteaEndpointOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetGiteaEndpointDefault creates a GetGiteaEndpointDefault with default headers values
func NewGetGiteaEndpointDefault(code int) *GetGiteaEndpointDefault {
return &GetGiteaEndpointDefault{
_statusCode: code,
}
}
/*
GetGiteaEndpointDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type GetGiteaEndpointDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this get gitea endpoint default response has a 2xx status code
func (o *GetGiteaEndpointDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this get gitea endpoint default response has a 3xx status code
func (o *GetGiteaEndpointDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this get gitea endpoint default response has a 4xx status code
func (o *GetGiteaEndpointDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this get gitea endpoint default response has a 5xx status code
func (o *GetGiteaEndpointDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this get gitea endpoint default response a status code equal to that given
func (o *GetGiteaEndpointDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the get gitea endpoint default response
func (o *GetGiteaEndpointDefault) Code() int {
return o._statusCode
}
func (o *GetGiteaEndpointDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/endpoints/{name}][%d] GetGiteaEndpoint default %s", o._statusCode, payload)
}
func (o *GetGiteaEndpointDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/endpoints/{name}][%d] GetGiteaEndpoint default %s", o._statusCode, payload)
}
func (o *GetGiteaEndpointDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *GetGiteaEndpointDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -51,10 +51,10 @@ func NewGetGithubEndpointOK() *GetGithubEndpointOK {
/*
GetGithubEndpointOK describes a response with status code 200, with default header values.
GithubEndpoint
ForgeEndpoint
*/
type GetGithubEndpointOK struct {
Payload garm_params.GithubEndpoint
Payload garm_params.ForgeEndpoint
}
// IsSuccess returns true when this get github endpoint o k response has a 2xx status code
@ -97,7 +97,7 @@ func (o *GetGithubEndpointOK) String() string {
return fmt.Sprintf("[GET /github/endpoints/{name}][%d] getGithubEndpointOK %s", 200, payload)
}
func (o *GetGithubEndpointOK) GetPayload() garm_params.GithubEndpoint {
func (o *GetGithubEndpointOK) GetPayload() garm_params.ForgeEndpoint {
return o.Payload
}

View file

@ -0,0 +1,128 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListGiteaEndpointsParams creates a new ListGiteaEndpointsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListGiteaEndpointsParams() *ListGiteaEndpointsParams {
return &ListGiteaEndpointsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListGiteaEndpointsParamsWithTimeout creates a new ListGiteaEndpointsParams object
// with the ability to set a timeout on a request.
func NewListGiteaEndpointsParamsWithTimeout(timeout time.Duration) *ListGiteaEndpointsParams {
return &ListGiteaEndpointsParams{
timeout: timeout,
}
}
// NewListGiteaEndpointsParamsWithContext creates a new ListGiteaEndpointsParams object
// with the ability to set a context for a request.
func NewListGiteaEndpointsParamsWithContext(ctx context.Context) *ListGiteaEndpointsParams {
return &ListGiteaEndpointsParams{
Context: ctx,
}
}
// NewListGiteaEndpointsParamsWithHTTPClient creates a new ListGiteaEndpointsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListGiteaEndpointsParamsWithHTTPClient(client *http.Client) *ListGiteaEndpointsParams {
return &ListGiteaEndpointsParams{
HTTPClient: client,
}
}
/*
ListGiteaEndpointsParams contains all the parameters to send to the API endpoint
for the list gitea endpoints operation.
Typically these are written to a http.Request.
*/
type ListGiteaEndpointsParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list gitea endpoints params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListGiteaEndpointsParams) WithDefaults() *ListGiteaEndpointsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list gitea endpoints params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListGiteaEndpointsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list gitea endpoints params
func (o *ListGiteaEndpointsParams) WithTimeout(timeout time.Duration) *ListGiteaEndpointsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list gitea endpoints params
func (o *ListGiteaEndpointsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list gitea endpoints params
func (o *ListGiteaEndpointsParams) WithContext(ctx context.Context) *ListGiteaEndpointsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list gitea endpoints params
func (o *ListGiteaEndpointsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list gitea endpoints params
func (o *ListGiteaEndpointsParams) WithHTTPClient(client *http.Client) *ListGiteaEndpointsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list gitea endpoints params
func (o *ListGiteaEndpointsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ListGiteaEndpointsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListGiteaEndpointsReader is a Reader for the ListGiteaEndpoints structure.
type ListGiteaEndpointsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListGiteaEndpointsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListGiteaEndpointsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListGiteaEndpointsDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListGiteaEndpointsOK creates a ListGiteaEndpointsOK with default headers values
func NewListGiteaEndpointsOK() *ListGiteaEndpointsOK {
return &ListGiteaEndpointsOK{}
}
/*
ListGiteaEndpointsOK describes a response with status code 200, with default header values.
ForgeEndpoints
*/
type ListGiteaEndpointsOK struct {
Payload garm_params.ForgeEndpoints
}
// IsSuccess returns true when this list gitea endpoints o k response has a 2xx status code
func (o *ListGiteaEndpointsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list gitea endpoints o k response has a 3xx status code
func (o *ListGiteaEndpointsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list gitea endpoints o k response has a 4xx status code
func (o *ListGiteaEndpointsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list gitea endpoints o k response has a 5xx status code
func (o *ListGiteaEndpointsOK) IsServerError() bool {
return false
}
// IsCode returns true when this list gitea endpoints o k response a status code equal to that given
func (o *ListGiteaEndpointsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list gitea endpoints o k response
func (o *ListGiteaEndpointsOK) Code() int {
return 200
}
func (o *ListGiteaEndpointsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/endpoints][%d] listGiteaEndpointsOK %s", 200, payload)
}
func (o *ListGiteaEndpointsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/endpoints][%d] listGiteaEndpointsOK %s", 200, payload)
}
func (o *ListGiteaEndpointsOK) GetPayload() garm_params.ForgeEndpoints {
return o.Payload
}
func (o *ListGiteaEndpointsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListGiteaEndpointsDefault creates a ListGiteaEndpointsDefault with default headers values
func NewListGiteaEndpointsDefault(code int) *ListGiteaEndpointsDefault {
return &ListGiteaEndpointsDefault{
_statusCode: code,
}
}
/*
ListGiteaEndpointsDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListGiteaEndpointsDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list gitea endpoints default response has a 2xx status code
func (o *ListGiteaEndpointsDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list gitea endpoints default response has a 3xx status code
func (o *ListGiteaEndpointsDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list gitea endpoints default response has a 4xx status code
func (o *ListGiteaEndpointsDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list gitea endpoints default response has a 5xx status code
func (o *ListGiteaEndpointsDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list gitea endpoints default response a status code equal to that given
func (o *ListGiteaEndpointsDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list gitea endpoints default response
func (o *ListGiteaEndpointsDefault) Code() int {
return o._statusCode
}
func (o *ListGiteaEndpointsDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/endpoints][%d] ListGiteaEndpoints default %s", o._statusCode, payload)
}
func (o *ListGiteaEndpointsDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /gitea/endpoints][%d] ListGiteaEndpoints default %s", o._statusCode, payload)
}
func (o *ListGiteaEndpointsDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListGiteaEndpointsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -51,10 +51,10 @@ func NewListGithubEndpointsOK() *ListGithubEndpointsOK {
/*
ListGithubEndpointsOK describes a response with status code 200, with default header values.
GithubEndpoints
ForgeEndpoints
*/
type ListGithubEndpointsOK struct {
Payload garm_params.GithubEndpoints
Payload garm_params.ForgeEndpoints
}
// IsSuccess returns true when this list github endpoints o k response has a 2xx status code
@ -97,7 +97,7 @@ func (o *ListGithubEndpointsOK) String() string {
return fmt.Sprintf("[GET /github/endpoints][%d] listGithubEndpointsOK %s", 200, payload)
}
func (o *ListGithubEndpointsOK) GetPayload() garm_params.GithubEndpoints {
func (o *ListGithubEndpointsOK) GetPayload() garm_params.ForgeEndpoints {
return o.Payload
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewUpdateGiteaEndpointParams creates a new UpdateGiteaEndpointParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewUpdateGiteaEndpointParams() *UpdateGiteaEndpointParams {
return &UpdateGiteaEndpointParams{
timeout: cr.DefaultTimeout,
}
}
// NewUpdateGiteaEndpointParamsWithTimeout creates a new UpdateGiteaEndpointParams object
// with the ability to set a timeout on a request.
func NewUpdateGiteaEndpointParamsWithTimeout(timeout time.Duration) *UpdateGiteaEndpointParams {
return &UpdateGiteaEndpointParams{
timeout: timeout,
}
}
// NewUpdateGiteaEndpointParamsWithContext creates a new UpdateGiteaEndpointParams object
// with the ability to set a context for a request.
func NewUpdateGiteaEndpointParamsWithContext(ctx context.Context) *UpdateGiteaEndpointParams {
return &UpdateGiteaEndpointParams{
Context: ctx,
}
}
// NewUpdateGiteaEndpointParamsWithHTTPClient creates a new UpdateGiteaEndpointParams object
// with the ability to set a custom HTTPClient for a request.
func NewUpdateGiteaEndpointParamsWithHTTPClient(client *http.Client) *UpdateGiteaEndpointParams {
return &UpdateGiteaEndpointParams{
HTTPClient: client,
}
}
/*
UpdateGiteaEndpointParams contains all the parameters to send to the API endpoint
for the update gitea endpoint operation.
Typically these are written to a http.Request.
*/
type UpdateGiteaEndpointParams struct {
/* Body.
Parameters used when updating a Gitea endpoint.
*/
Body garm_params.UpdateGiteaEndpointParams
/* Name.
The name of the Gitea endpoint.
*/
Name string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the update gitea endpoint params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateGiteaEndpointParams) WithDefaults() *UpdateGiteaEndpointParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the update gitea endpoint params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateGiteaEndpointParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) WithTimeout(timeout time.Duration) *UpdateGiteaEndpointParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) WithContext(ctx context.Context) *UpdateGiteaEndpointParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) WithHTTPClient(client *http.Client) *UpdateGiteaEndpointParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) WithBody(body garm_params.UpdateGiteaEndpointParams) *UpdateGiteaEndpointParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) SetBody(body garm_params.UpdateGiteaEndpointParams) {
o.Body = body
}
// WithName adds the name to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) WithName(name string) *UpdateGiteaEndpointParams {
o.SetName(name)
return o
}
// SetName adds the name to the update gitea endpoint params
func (o *UpdateGiteaEndpointParams) SetName(name string) {
o.Name = name
}
// WriteToRequest writes these params to a swagger request
func (o *UpdateGiteaEndpointParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param name
if err := r.SetPathParam("name", o.Name); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package endpoints
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// UpdateGiteaEndpointReader is a Reader for the UpdateGiteaEndpoint structure.
type UpdateGiteaEndpointReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UpdateGiteaEndpointReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewUpdateGiteaEndpointOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewUpdateGiteaEndpointDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewUpdateGiteaEndpointOK creates a UpdateGiteaEndpointOK with default headers values
func NewUpdateGiteaEndpointOK() *UpdateGiteaEndpointOK {
return &UpdateGiteaEndpointOK{}
}
/*
UpdateGiteaEndpointOK describes a response with status code 200, with default header values.
ForgeEndpoint
*/
type UpdateGiteaEndpointOK struct {
Payload garm_params.ForgeEndpoint
}
// IsSuccess returns true when this update gitea endpoint o k response has a 2xx status code
func (o *UpdateGiteaEndpointOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this update gitea endpoint o k response has a 3xx status code
func (o *UpdateGiteaEndpointOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this update gitea endpoint o k response has a 4xx status code
func (o *UpdateGiteaEndpointOK) IsClientError() bool {
return false
}
// IsServerError returns true when this update gitea endpoint o k response has a 5xx status code
func (o *UpdateGiteaEndpointOK) IsServerError() bool {
return false
}
// IsCode returns true when this update gitea endpoint o k response a status code equal to that given
func (o *UpdateGiteaEndpointOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the update gitea endpoint o k response
func (o *UpdateGiteaEndpointOK) Code() int {
return 200
}
func (o *UpdateGiteaEndpointOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /gitea/endpoints/{name}][%d] updateGiteaEndpointOK %s", 200, payload)
}
func (o *UpdateGiteaEndpointOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /gitea/endpoints/{name}][%d] updateGiteaEndpointOK %s", 200, payload)
}
func (o *UpdateGiteaEndpointOK) GetPayload() garm_params.ForgeEndpoint {
return o.Payload
}
func (o *UpdateGiteaEndpointOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewUpdateGiteaEndpointDefault creates a UpdateGiteaEndpointDefault with default headers values
func NewUpdateGiteaEndpointDefault(code int) *UpdateGiteaEndpointDefault {
return &UpdateGiteaEndpointDefault{
_statusCode: code,
}
}
/*
UpdateGiteaEndpointDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type UpdateGiteaEndpointDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this update gitea endpoint default response has a 2xx status code
func (o *UpdateGiteaEndpointDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this update gitea endpoint default response has a 3xx status code
func (o *UpdateGiteaEndpointDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this update gitea endpoint default response has a 4xx status code
func (o *UpdateGiteaEndpointDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this update gitea endpoint default response has a 5xx status code
func (o *UpdateGiteaEndpointDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this update gitea endpoint default response a status code equal to that given
func (o *UpdateGiteaEndpointDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the update gitea endpoint default response
func (o *UpdateGiteaEndpointDefault) Code() int {
return o._statusCode
}
func (o *UpdateGiteaEndpointDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /gitea/endpoints/{name}][%d] UpdateGiteaEndpoint default %s", o._statusCode, payload)
}
func (o *UpdateGiteaEndpointDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /gitea/endpoints/{name}][%d] UpdateGiteaEndpoint default %s", o._statusCode, payload)
}
func (o *UpdateGiteaEndpointDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *UpdateGiteaEndpointDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -51,10 +51,10 @@ func NewUpdateGithubEndpointOK() *UpdateGithubEndpointOK {
/*
UpdateGithubEndpointOK describes a response with status code 200, with default header values.
GithubEndpoint
ForgeEndpoint
*/
type UpdateGithubEndpointOK struct {
Payload garm_params.GithubEndpoint
Payload garm_params.ForgeEndpoint
}
// IsSuccess returns true when this update github endpoint o k response has a 2xx status code
@ -97,7 +97,7 @@ func (o *UpdateGithubEndpointOK) String() string {
return fmt.Sprintf("[PUT /github/endpoints/{name}][%d] updateGithubEndpointOK %s", 200, payload)
}
func (o *UpdateGithubEndpointOK) GetPayload() garm_params.GithubEndpoint {
func (o *UpdateGithubEndpointOK) GetPayload() garm_params.ForgeEndpoint {
return o.Payload
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package enterprises
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewCreateEnterpriseScaleSetParams creates a new CreateEnterpriseScaleSetParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewCreateEnterpriseScaleSetParams() *CreateEnterpriseScaleSetParams {
return &CreateEnterpriseScaleSetParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateEnterpriseScaleSetParamsWithTimeout creates a new CreateEnterpriseScaleSetParams object
// with the ability to set a timeout on a request.
func NewCreateEnterpriseScaleSetParamsWithTimeout(timeout time.Duration) *CreateEnterpriseScaleSetParams {
return &CreateEnterpriseScaleSetParams{
timeout: timeout,
}
}
// NewCreateEnterpriseScaleSetParamsWithContext creates a new CreateEnterpriseScaleSetParams object
// with the ability to set a context for a request.
func NewCreateEnterpriseScaleSetParamsWithContext(ctx context.Context) *CreateEnterpriseScaleSetParams {
return &CreateEnterpriseScaleSetParams{
Context: ctx,
}
}
// NewCreateEnterpriseScaleSetParamsWithHTTPClient creates a new CreateEnterpriseScaleSetParams object
// with the ability to set a custom HTTPClient for a request.
func NewCreateEnterpriseScaleSetParamsWithHTTPClient(client *http.Client) *CreateEnterpriseScaleSetParams {
return &CreateEnterpriseScaleSetParams{
HTTPClient: client,
}
}
/*
CreateEnterpriseScaleSetParams contains all the parameters to send to the API endpoint
for the create enterprise scale set operation.
Typically these are written to a http.Request.
*/
type CreateEnterpriseScaleSetParams struct {
/* Body.
Parameters used when creating the enterprise scale set.
*/
Body garm_params.CreateScaleSetParams
/* EnterpriseID.
Enterprise ID.
*/
EnterpriseID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the create enterprise scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateEnterpriseScaleSetParams) WithDefaults() *CreateEnterpriseScaleSetParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the create enterprise scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateEnterpriseScaleSetParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) WithTimeout(timeout time.Duration) *CreateEnterpriseScaleSetParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) WithContext(ctx context.Context) *CreateEnterpriseScaleSetParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) WithHTTPClient(client *http.Client) *CreateEnterpriseScaleSetParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) WithBody(body garm_params.CreateScaleSetParams) *CreateEnterpriseScaleSetParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) SetBody(body garm_params.CreateScaleSetParams) {
o.Body = body
}
// WithEnterpriseID adds the enterpriseID to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) WithEnterpriseID(enterpriseID string) *CreateEnterpriseScaleSetParams {
o.SetEnterpriseID(enterpriseID)
return o
}
// SetEnterpriseID adds the enterpriseId to the create enterprise scale set params
func (o *CreateEnterpriseScaleSetParams) SetEnterpriseID(enterpriseID string) {
o.EnterpriseID = enterpriseID
}
// WriteToRequest writes these params to a swagger request
func (o *CreateEnterpriseScaleSetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param enterpriseID
if err := r.SetPathParam("enterpriseID", o.EnterpriseID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package enterprises
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// CreateEnterpriseScaleSetReader is a Reader for the CreateEnterpriseScaleSet structure.
type CreateEnterpriseScaleSetReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateEnterpriseScaleSetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateEnterpriseScaleSetOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewCreateEnterpriseScaleSetDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewCreateEnterpriseScaleSetOK creates a CreateEnterpriseScaleSetOK with default headers values
func NewCreateEnterpriseScaleSetOK() *CreateEnterpriseScaleSetOK {
return &CreateEnterpriseScaleSetOK{}
}
/*
CreateEnterpriseScaleSetOK describes a response with status code 200, with default header values.
ScaleSet
*/
type CreateEnterpriseScaleSetOK struct {
Payload garm_params.ScaleSet
}
// IsSuccess returns true when this create enterprise scale set o k response has a 2xx status code
func (o *CreateEnterpriseScaleSetOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this create enterprise scale set o k response has a 3xx status code
func (o *CreateEnterpriseScaleSetOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this create enterprise scale set o k response has a 4xx status code
func (o *CreateEnterpriseScaleSetOK) IsClientError() bool {
return false
}
// IsServerError returns true when this create enterprise scale set o k response has a 5xx status code
func (o *CreateEnterpriseScaleSetOK) IsServerError() bool {
return false
}
// IsCode returns true when this create enterprise scale set o k response a status code equal to that given
func (o *CreateEnterpriseScaleSetOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the create enterprise scale set o k response
func (o *CreateEnterpriseScaleSetOK) Code() int {
return 200
}
func (o *CreateEnterpriseScaleSetOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /enterprises/{enterpriseID}/scalesets][%d] createEnterpriseScaleSetOK %s", 200, payload)
}
func (o *CreateEnterpriseScaleSetOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /enterprises/{enterpriseID}/scalesets][%d] createEnterpriseScaleSetOK %s", 200, payload)
}
func (o *CreateEnterpriseScaleSetOK) GetPayload() garm_params.ScaleSet {
return o.Payload
}
func (o *CreateEnterpriseScaleSetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateEnterpriseScaleSetDefault creates a CreateEnterpriseScaleSetDefault with default headers values
func NewCreateEnterpriseScaleSetDefault(code int) *CreateEnterpriseScaleSetDefault {
return &CreateEnterpriseScaleSetDefault{
_statusCode: code,
}
}
/*
CreateEnterpriseScaleSetDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type CreateEnterpriseScaleSetDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this create enterprise scale set default response has a 2xx status code
func (o *CreateEnterpriseScaleSetDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this create enterprise scale set default response has a 3xx status code
func (o *CreateEnterpriseScaleSetDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this create enterprise scale set default response has a 4xx status code
func (o *CreateEnterpriseScaleSetDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this create enterprise scale set default response has a 5xx status code
func (o *CreateEnterpriseScaleSetDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this create enterprise scale set default response a status code equal to that given
func (o *CreateEnterpriseScaleSetDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the create enterprise scale set default response
func (o *CreateEnterpriseScaleSetDefault) Code() int {
return o._statusCode
}
func (o *CreateEnterpriseScaleSetDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /enterprises/{enterpriseID}/scalesets][%d] CreateEnterpriseScaleSet default %s", o._statusCode, payload)
}
func (o *CreateEnterpriseScaleSetDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /enterprises/{enterpriseID}/scalesets][%d] CreateEnterpriseScaleSet default %s", o._statusCode, payload)
}
func (o *CreateEnterpriseScaleSetDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *CreateEnterpriseScaleSetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -58,6 +58,8 @@ type ClientService interface {
CreateEnterprisePool(params *CreateEnterprisePoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateEnterprisePoolOK, error)
CreateEnterpriseScaleSet(params *CreateEnterpriseScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateEnterpriseScaleSetOK, error)
DeleteEnterprise(params *DeleteEnterpriseParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
DeleteEnterprisePool(params *DeleteEnterprisePoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
@ -70,6 +72,8 @@ type ClientService interface {
ListEnterprisePools(params *ListEnterprisePoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListEnterprisePoolsOK, error)
ListEnterpriseScaleSets(params *ListEnterpriseScaleSetsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListEnterpriseScaleSetsOK, error)
ListEnterprises(params *ListEnterprisesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListEnterprisesOK, error)
UpdateEnterprise(params *UpdateEnterpriseParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateEnterpriseOK, error)
@ -155,6 +159,44 @@ func (a *Client) CreateEnterprisePool(params *CreateEnterprisePoolParams, authIn
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
CreateEnterpriseScaleSet creates enterprise pool with the parameters given
*/
func (a *Client) CreateEnterpriseScaleSet(params *CreateEnterpriseScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateEnterpriseScaleSetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateEnterpriseScaleSetParams()
}
op := &runtime.ClientOperation{
ID: "CreateEnterpriseScaleSet",
Method: "POST",
PathPattern: "/enterprises/{enterpriseID}/scalesets",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateEnterpriseScaleSetReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateEnterpriseScaleSetOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*CreateEnterpriseScaleSetDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
DeleteEnterprise deletes enterprise by ID
*/
@ -371,6 +413,44 @@ func (a *Client) ListEnterprisePools(params *ListEnterprisePoolsParams, authInfo
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListEnterpriseScaleSets lists enterprise scale sets
*/
func (a *Client) ListEnterpriseScaleSets(params *ListEnterpriseScaleSetsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListEnterpriseScaleSetsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListEnterpriseScaleSetsParams()
}
op := &runtime.ClientOperation{
ID: "ListEnterpriseScaleSets",
Method: "GET",
PathPattern: "/enterprises/{enterpriseID}/scalesets",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListEnterpriseScaleSetsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListEnterpriseScaleSetsOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListEnterpriseScaleSetsDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListEnterprises lists all enterprises
*/

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package enterprises
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListEnterpriseScaleSetsParams creates a new ListEnterpriseScaleSetsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListEnterpriseScaleSetsParams() *ListEnterpriseScaleSetsParams {
return &ListEnterpriseScaleSetsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListEnterpriseScaleSetsParamsWithTimeout creates a new ListEnterpriseScaleSetsParams object
// with the ability to set a timeout on a request.
func NewListEnterpriseScaleSetsParamsWithTimeout(timeout time.Duration) *ListEnterpriseScaleSetsParams {
return &ListEnterpriseScaleSetsParams{
timeout: timeout,
}
}
// NewListEnterpriseScaleSetsParamsWithContext creates a new ListEnterpriseScaleSetsParams object
// with the ability to set a context for a request.
func NewListEnterpriseScaleSetsParamsWithContext(ctx context.Context) *ListEnterpriseScaleSetsParams {
return &ListEnterpriseScaleSetsParams{
Context: ctx,
}
}
// NewListEnterpriseScaleSetsParamsWithHTTPClient creates a new ListEnterpriseScaleSetsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListEnterpriseScaleSetsParamsWithHTTPClient(client *http.Client) *ListEnterpriseScaleSetsParams {
return &ListEnterpriseScaleSetsParams{
HTTPClient: client,
}
}
/*
ListEnterpriseScaleSetsParams contains all the parameters to send to the API endpoint
for the list enterprise scale sets operation.
Typically these are written to a http.Request.
*/
type ListEnterpriseScaleSetsParams struct {
/* EnterpriseID.
Enterprise ID.
*/
EnterpriseID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list enterprise scale sets params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListEnterpriseScaleSetsParams) WithDefaults() *ListEnterpriseScaleSetsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list enterprise scale sets params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListEnterpriseScaleSetsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list enterprise scale sets params
func (o *ListEnterpriseScaleSetsParams) WithTimeout(timeout time.Duration) *ListEnterpriseScaleSetsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list enterprise scale sets params
func (o *ListEnterpriseScaleSetsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list enterprise scale sets params
func (o *ListEnterpriseScaleSetsParams) WithContext(ctx context.Context) *ListEnterpriseScaleSetsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list enterprise scale sets params
func (o *ListEnterpriseScaleSetsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list enterprise scale sets params
func (o *ListEnterpriseScaleSetsParams) WithHTTPClient(client *http.Client) *ListEnterpriseScaleSetsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list enterprise scale sets params
func (o *ListEnterpriseScaleSetsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithEnterpriseID adds the enterpriseID to the list enterprise scale sets params
func (o *ListEnterpriseScaleSetsParams) WithEnterpriseID(enterpriseID string) *ListEnterpriseScaleSetsParams {
o.SetEnterpriseID(enterpriseID)
return o
}
// SetEnterpriseID adds the enterpriseId to the list enterprise scale sets params
func (o *ListEnterpriseScaleSetsParams) SetEnterpriseID(enterpriseID string) {
o.EnterpriseID = enterpriseID
}
// WriteToRequest writes these params to a swagger request
func (o *ListEnterpriseScaleSetsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param enterpriseID
if err := r.SetPathParam("enterpriseID", o.EnterpriseID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package enterprises
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListEnterpriseScaleSetsReader is a Reader for the ListEnterpriseScaleSets structure.
type ListEnterpriseScaleSetsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListEnterpriseScaleSetsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListEnterpriseScaleSetsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListEnterpriseScaleSetsDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListEnterpriseScaleSetsOK creates a ListEnterpriseScaleSetsOK with default headers values
func NewListEnterpriseScaleSetsOK() *ListEnterpriseScaleSetsOK {
return &ListEnterpriseScaleSetsOK{}
}
/*
ListEnterpriseScaleSetsOK describes a response with status code 200, with default header values.
ScaleSets
*/
type ListEnterpriseScaleSetsOK struct {
Payload garm_params.ScaleSets
}
// IsSuccess returns true when this list enterprise scale sets o k response has a 2xx status code
func (o *ListEnterpriseScaleSetsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list enterprise scale sets o k response has a 3xx status code
func (o *ListEnterpriseScaleSetsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list enterprise scale sets o k response has a 4xx status code
func (o *ListEnterpriseScaleSetsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list enterprise scale sets o k response has a 5xx status code
func (o *ListEnterpriseScaleSetsOK) IsServerError() bool {
return false
}
// IsCode returns true when this list enterprise scale sets o k response a status code equal to that given
func (o *ListEnterpriseScaleSetsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list enterprise scale sets o k response
func (o *ListEnterpriseScaleSetsOK) Code() int {
return 200
}
func (o *ListEnterpriseScaleSetsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /enterprises/{enterpriseID}/scalesets][%d] listEnterpriseScaleSetsOK %s", 200, payload)
}
func (o *ListEnterpriseScaleSetsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /enterprises/{enterpriseID}/scalesets][%d] listEnterpriseScaleSetsOK %s", 200, payload)
}
func (o *ListEnterpriseScaleSetsOK) GetPayload() garm_params.ScaleSets {
return o.Payload
}
func (o *ListEnterpriseScaleSetsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListEnterpriseScaleSetsDefault creates a ListEnterpriseScaleSetsDefault with default headers values
func NewListEnterpriseScaleSetsDefault(code int) *ListEnterpriseScaleSetsDefault {
return &ListEnterpriseScaleSetsDefault{
_statusCode: code,
}
}
/*
ListEnterpriseScaleSetsDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListEnterpriseScaleSetsDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list enterprise scale sets default response has a 2xx status code
func (o *ListEnterpriseScaleSetsDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list enterprise scale sets default response has a 3xx status code
func (o *ListEnterpriseScaleSetsDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list enterprise scale sets default response has a 4xx status code
func (o *ListEnterpriseScaleSetsDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list enterprise scale sets default response has a 5xx status code
func (o *ListEnterpriseScaleSetsDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list enterprise scale sets default response a status code equal to that given
func (o *ListEnterpriseScaleSetsDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list enterprise scale sets default response
func (o *ListEnterpriseScaleSetsDefault) Code() int {
return o._statusCode
}
func (o *ListEnterpriseScaleSetsDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /enterprises/{enterpriseID}/scalesets][%d] ListEnterpriseScaleSets default %s", o._statusCode, payload)
}
func (o *ListEnterpriseScaleSetsDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /enterprises/{enterpriseID}/scalesets][%d] ListEnterpriseScaleSets default %s", o._statusCode, payload)
}
func (o *ListEnterpriseScaleSetsDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListEnterpriseScaleSetsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -60,6 +60,19 @@ ListEnterprisesParams contains all the parameters to send to the API endpoint
Typically these are written to a http.Request.
*/
type ListEnterprisesParams struct {
/* Endpoint.
Exact endpoint name to filter by
*/
Endpoint *string
/* Name.
Exact enterprise name to filter by
*/
Name *string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
@ -113,6 +126,28 @@ func (o *ListEnterprisesParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithEndpoint adds the endpoint to the list enterprises params
func (o *ListEnterprisesParams) WithEndpoint(endpoint *string) *ListEnterprisesParams {
o.SetEndpoint(endpoint)
return o
}
// SetEndpoint adds the endpoint to the list enterprises params
func (o *ListEnterprisesParams) SetEndpoint(endpoint *string) {
o.Endpoint = endpoint
}
// WithName adds the name to the list enterprises params
func (o *ListEnterprisesParams) WithName(name *string) *ListEnterprisesParams {
o.SetName(name)
return o
}
// SetName adds the name to the list enterprises params
func (o *ListEnterprisesParams) SetName(name *string) {
o.Name = name
}
// WriteToRequest writes these params to a swagger request
func (o *ListEnterprisesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
@ -121,6 +156,40 @@ func (o *ListEnterprisesParams) WriteToRequest(r runtime.ClientRequest, reg strf
}
var res []error
if o.Endpoint != nil {
// query param endpoint
var qrEndpoint string
if o.Endpoint != nil {
qrEndpoint = *o.Endpoint
}
qEndpoint := qrEndpoint
if qEndpoint != "" {
if err := r.SetQueryParam("endpoint", qEndpoint); err != nil {
return err
}
}
}
if o.Name != nil {
// query param name
var qrName string
if o.Name != nil {
qrName = *o.Name
}
qName := qrName
if qName != "" {
if err := r.SetQueryParam("name", qName); err != nil {
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}

View file

@ -24,6 +24,7 @@ import (
"github.com/cloudbase/garm/client/pools"
"github.com/cloudbase/garm/client/providers"
"github.com/cloudbase/garm/client/repositories"
"github.com/cloudbase/garm/client/scalesets"
)
// Default garm API HTTP client.
@ -82,6 +83,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *GarmAPI {
cli.Pools = pools.New(transport, formats)
cli.Providers = providers.New(transport, formats)
cli.Repositories = repositories.New(transport, formats)
cli.Scalesets = scalesets.New(transport, formats)
return cli
}
@ -154,6 +156,8 @@ type GarmAPI struct {
Repositories repositories.ClientService
Scalesets scalesets.ClientService
Transport runtime.ClientTransport
}
@ -174,4 +178,5 @@ func (c *GarmAPI) SetTransport(transport runtime.ClientTransport) {
c.Pools.SetTransport(transport)
c.Providers.SetTransport(transport)
c.Repositories.SetTransport(transport)
c.Scalesets.SetTransport(transport)
}

View file

@ -62,6 +62,8 @@ type ClientService interface {
ListPoolInstances(params *ListPoolInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListPoolInstancesOK, error)
ListScaleSetInstances(params *ListScaleSetInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListScaleSetInstancesOK, error)
SetTransport(transport runtime.ClientTransport)
}
@ -211,6 +213,44 @@ func (a *Client) ListPoolInstances(params *ListPoolInstancesParams, authInfo run
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListScaleSetInstances lists runner instances in a scale set
*/
func (a *Client) ListScaleSetInstances(params *ListScaleSetInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListScaleSetInstancesOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListScaleSetInstancesParams()
}
op := &runtime.ClientOperation{
ID: "ListScaleSetInstances",
Method: "GET",
PathPattern: "/scalesets/{scalesetID}/instances",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListScaleSetInstancesReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListScaleSetInstancesOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListScaleSetInstancesDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListScaleSetInstancesParams creates a new ListScaleSetInstancesParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListScaleSetInstancesParams() *ListScaleSetInstancesParams {
return &ListScaleSetInstancesParams{
timeout: cr.DefaultTimeout,
}
}
// NewListScaleSetInstancesParamsWithTimeout creates a new ListScaleSetInstancesParams object
// with the ability to set a timeout on a request.
func NewListScaleSetInstancesParamsWithTimeout(timeout time.Duration) *ListScaleSetInstancesParams {
return &ListScaleSetInstancesParams{
timeout: timeout,
}
}
// NewListScaleSetInstancesParamsWithContext creates a new ListScaleSetInstancesParams object
// with the ability to set a context for a request.
func NewListScaleSetInstancesParamsWithContext(ctx context.Context) *ListScaleSetInstancesParams {
return &ListScaleSetInstancesParams{
Context: ctx,
}
}
// NewListScaleSetInstancesParamsWithHTTPClient creates a new ListScaleSetInstancesParams object
// with the ability to set a custom HTTPClient for a request.
func NewListScaleSetInstancesParamsWithHTTPClient(client *http.Client) *ListScaleSetInstancesParams {
return &ListScaleSetInstancesParams{
HTTPClient: client,
}
}
/*
ListScaleSetInstancesParams contains all the parameters to send to the API endpoint
for the list scale set instances operation.
Typically these are written to a http.Request.
*/
type ListScaleSetInstancesParams struct {
/* ScalesetID.
Runner scale set ID.
*/
ScalesetID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list scale set instances params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListScaleSetInstancesParams) WithDefaults() *ListScaleSetInstancesParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list scale set instances params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListScaleSetInstancesParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list scale set instances params
func (o *ListScaleSetInstancesParams) WithTimeout(timeout time.Duration) *ListScaleSetInstancesParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list scale set instances params
func (o *ListScaleSetInstancesParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list scale set instances params
func (o *ListScaleSetInstancesParams) WithContext(ctx context.Context) *ListScaleSetInstancesParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list scale set instances params
func (o *ListScaleSetInstancesParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list scale set instances params
func (o *ListScaleSetInstancesParams) WithHTTPClient(client *http.Client) *ListScaleSetInstancesParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list scale set instances params
func (o *ListScaleSetInstancesParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithScalesetID adds the scalesetID to the list scale set instances params
func (o *ListScaleSetInstancesParams) WithScalesetID(scalesetID string) *ListScaleSetInstancesParams {
o.SetScalesetID(scalesetID)
return o
}
// SetScalesetID adds the scalesetId to the list scale set instances params
func (o *ListScaleSetInstancesParams) SetScalesetID(scalesetID string) {
o.ScalesetID = scalesetID
}
// WriteToRequest writes these params to a swagger request
func (o *ListScaleSetInstancesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param scalesetID
if err := r.SetPathParam("scalesetID", o.ScalesetID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListScaleSetInstancesReader is a Reader for the ListScaleSetInstances structure.
type ListScaleSetInstancesReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListScaleSetInstancesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListScaleSetInstancesOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListScaleSetInstancesDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListScaleSetInstancesOK creates a ListScaleSetInstancesOK with default headers values
func NewListScaleSetInstancesOK() *ListScaleSetInstancesOK {
return &ListScaleSetInstancesOK{}
}
/*
ListScaleSetInstancesOK describes a response with status code 200, with default header values.
Instances
*/
type ListScaleSetInstancesOK struct {
Payload garm_params.Instances
}
// IsSuccess returns true when this list scale set instances o k response has a 2xx status code
func (o *ListScaleSetInstancesOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list scale set instances o k response has a 3xx status code
func (o *ListScaleSetInstancesOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list scale set instances o k response has a 4xx status code
func (o *ListScaleSetInstancesOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list scale set instances o k response has a 5xx status code
func (o *ListScaleSetInstancesOK) IsServerError() bool {
return false
}
// IsCode returns true when this list scale set instances o k response a status code equal to that given
func (o *ListScaleSetInstancesOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list scale set instances o k response
func (o *ListScaleSetInstancesOK) Code() int {
return 200
}
func (o *ListScaleSetInstancesOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets/{scalesetID}/instances][%d] listScaleSetInstancesOK %s", 200, payload)
}
func (o *ListScaleSetInstancesOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets/{scalesetID}/instances][%d] listScaleSetInstancesOK %s", 200, payload)
}
func (o *ListScaleSetInstancesOK) GetPayload() garm_params.Instances {
return o.Payload
}
func (o *ListScaleSetInstancesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListScaleSetInstancesDefault creates a ListScaleSetInstancesDefault with default headers values
func NewListScaleSetInstancesDefault(code int) *ListScaleSetInstancesDefault {
return &ListScaleSetInstancesDefault{
_statusCode: code,
}
}
/*
ListScaleSetInstancesDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListScaleSetInstancesDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list scale set instances default response has a 2xx status code
func (o *ListScaleSetInstancesDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list scale set instances default response has a 3xx status code
func (o *ListScaleSetInstancesDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list scale set instances default response has a 4xx status code
func (o *ListScaleSetInstancesDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list scale set instances default response has a 5xx status code
func (o *ListScaleSetInstancesDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list scale set instances default response a status code equal to that given
func (o *ListScaleSetInstancesDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list scale set instances default response
func (o *ListScaleSetInstancesDefault) Code() int {
return o._statusCode
}
func (o *ListScaleSetInstancesDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets/{scalesetID}/instances][%d] ListScaleSetInstances default %s", o._statusCode, payload)
}
func (o *ListScaleSetInstancesDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets/{scalesetID}/instances][%d] ListScaleSetInstances default %s", o._statusCode, payload)
}
func (o *ListScaleSetInstancesDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListScaleSetInstancesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package organizations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewCreateOrgScaleSetParams creates a new CreateOrgScaleSetParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewCreateOrgScaleSetParams() *CreateOrgScaleSetParams {
return &CreateOrgScaleSetParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateOrgScaleSetParamsWithTimeout creates a new CreateOrgScaleSetParams object
// with the ability to set a timeout on a request.
func NewCreateOrgScaleSetParamsWithTimeout(timeout time.Duration) *CreateOrgScaleSetParams {
return &CreateOrgScaleSetParams{
timeout: timeout,
}
}
// NewCreateOrgScaleSetParamsWithContext creates a new CreateOrgScaleSetParams object
// with the ability to set a context for a request.
func NewCreateOrgScaleSetParamsWithContext(ctx context.Context) *CreateOrgScaleSetParams {
return &CreateOrgScaleSetParams{
Context: ctx,
}
}
// NewCreateOrgScaleSetParamsWithHTTPClient creates a new CreateOrgScaleSetParams object
// with the ability to set a custom HTTPClient for a request.
func NewCreateOrgScaleSetParamsWithHTTPClient(client *http.Client) *CreateOrgScaleSetParams {
return &CreateOrgScaleSetParams{
HTTPClient: client,
}
}
/*
CreateOrgScaleSetParams contains all the parameters to send to the API endpoint
for the create org scale set operation.
Typically these are written to a http.Request.
*/
type CreateOrgScaleSetParams struct {
/* Body.
Parameters used when creating the organization scale set.
*/
Body garm_params.CreateScaleSetParams
/* OrgID.
Organization ID.
*/
OrgID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the create org scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateOrgScaleSetParams) WithDefaults() *CreateOrgScaleSetParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the create org scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateOrgScaleSetParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the create org scale set params
func (o *CreateOrgScaleSetParams) WithTimeout(timeout time.Duration) *CreateOrgScaleSetParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create org scale set params
func (o *CreateOrgScaleSetParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create org scale set params
func (o *CreateOrgScaleSetParams) WithContext(ctx context.Context) *CreateOrgScaleSetParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create org scale set params
func (o *CreateOrgScaleSetParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create org scale set params
func (o *CreateOrgScaleSetParams) WithHTTPClient(client *http.Client) *CreateOrgScaleSetParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create org scale set params
func (o *CreateOrgScaleSetParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create org scale set params
func (o *CreateOrgScaleSetParams) WithBody(body garm_params.CreateScaleSetParams) *CreateOrgScaleSetParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create org scale set params
func (o *CreateOrgScaleSetParams) SetBody(body garm_params.CreateScaleSetParams) {
o.Body = body
}
// WithOrgID adds the orgID to the create org scale set params
func (o *CreateOrgScaleSetParams) WithOrgID(orgID string) *CreateOrgScaleSetParams {
o.SetOrgID(orgID)
return o
}
// SetOrgID adds the orgId to the create org scale set params
func (o *CreateOrgScaleSetParams) SetOrgID(orgID string) {
o.OrgID = orgID
}
// WriteToRequest writes these params to a swagger request
func (o *CreateOrgScaleSetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param orgID
if err := r.SetPathParam("orgID", o.OrgID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package organizations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// CreateOrgScaleSetReader is a Reader for the CreateOrgScaleSet structure.
type CreateOrgScaleSetReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateOrgScaleSetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateOrgScaleSetOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewCreateOrgScaleSetDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewCreateOrgScaleSetOK creates a CreateOrgScaleSetOK with default headers values
func NewCreateOrgScaleSetOK() *CreateOrgScaleSetOK {
return &CreateOrgScaleSetOK{}
}
/*
CreateOrgScaleSetOK describes a response with status code 200, with default header values.
ScaleSet
*/
type CreateOrgScaleSetOK struct {
Payload garm_params.ScaleSet
}
// IsSuccess returns true when this create org scale set o k response has a 2xx status code
func (o *CreateOrgScaleSetOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this create org scale set o k response has a 3xx status code
func (o *CreateOrgScaleSetOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this create org scale set o k response has a 4xx status code
func (o *CreateOrgScaleSetOK) IsClientError() bool {
return false
}
// IsServerError returns true when this create org scale set o k response has a 5xx status code
func (o *CreateOrgScaleSetOK) IsServerError() bool {
return false
}
// IsCode returns true when this create org scale set o k response a status code equal to that given
func (o *CreateOrgScaleSetOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the create org scale set o k response
func (o *CreateOrgScaleSetOK) Code() int {
return 200
}
func (o *CreateOrgScaleSetOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /organizations/{orgID}/scalesets][%d] createOrgScaleSetOK %s", 200, payload)
}
func (o *CreateOrgScaleSetOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /organizations/{orgID}/scalesets][%d] createOrgScaleSetOK %s", 200, payload)
}
func (o *CreateOrgScaleSetOK) GetPayload() garm_params.ScaleSet {
return o.Payload
}
func (o *CreateOrgScaleSetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateOrgScaleSetDefault creates a CreateOrgScaleSetDefault with default headers values
func NewCreateOrgScaleSetDefault(code int) *CreateOrgScaleSetDefault {
return &CreateOrgScaleSetDefault{
_statusCode: code,
}
}
/*
CreateOrgScaleSetDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type CreateOrgScaleSetDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this create org scale set default response has a 2xx status code
func (o *CreateOrgScaleSetDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this create org scale set default response has a 3xx status code
func (o *CreateOrgScaleSetDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this create org scale set default response has a 4xx status code
func (o *CreateOrgScaleSetDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this create org scale set default response has a 5xx status code
func (o *CreateOrgScaleSetDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this create org scale set default response a status code equal to that given
func (o *CreateOrgScaleSetDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the create org scale set default response
func (o *CreateOrgScaleSetDefault) Code() int {
return o._statusCode
}
func (o *CreateOrgScaleSetDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /organizations/{orgID}/scalesets][%d] CreateOrgScaleSet default %s", o._statusCode, payload)
}
func (o *CreateOrgScaleSetDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /organizations/{orgID}/scalesets][%d] CreateOrgScaleSet default %s", o._statusCode, payload)
}
func (o *CreateOrgScaleSetDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *CreateOrgScaleSetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package organizations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListOrgScaleSetsParams creates a new ListOrgScaleSetsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListOrgScaleSetsParams() *ListOrgScaleSetsParams {
return &ListOrgScaleSetsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListOrgScaleSetsParamsWithTimeout creates a new ListOrgScaleSetsParams object
// with the ability to set a timeout on a request.
func NewListOrgScaleSetsParamsWithTimeout(timeout time.Duration) *ListOrgScaleSetsParams {
return &ListOrgScaleSetsParams{
timeout: timeout,
}
}
// NewListOrgScaleSetsParamsWithContext creates a new ListOrgScaleSetsParams object
// with the ability to set a context for a request.
func NewListOrgScaleSetsParamsWithContext(ctx context.Context) *ListOrgScaleSetsParams {
return &ListOrgScaleSetsParams{
Context: ctx,
}
}
// NewListOrgScaleSetsParamsWithHTTPClient creates a new ListOrgScaleSetsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListOrgScaleSetsParamsWithHTTPClient(client *http.Client) *ListOrgScaleSetsParams {
return &ListOrgScaleSetsParams{
HTTPClient: client,
}
}
/*
ListOrgScaleSetsParams contains all the parameters to send to the API endpoint
for the list org scale sets operation.
Typically these are written to a http.Request.
*/
type ListOrgScaleSetsParams struct {
/* OrgID.
Organization ID.
*/
OrgID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list org scale sets params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListOrgScaleSetsParams) WithDefaults() *ListOrgScaleSetsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list org scale sets params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListOrgScaleSetsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list org scale sets params
func (o *ListOrgScaleSetsParams) WithTimeout(timeout time.Duration) *ListOrgScaleSetsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list org scale sets params
func (o *ListOrgScaleSetsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list org scale sets params
func (o *ListOrgScaleSetsParams) WithContext(ctx context.Context) *ListOrgScaleSetsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list org scale sets params
func (o *ListOrgScaleSetsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list org scale sets params
func (o *ListOrgScaleSetsParams) WithHTTPClient(client *http.Client) *ListOrgScaleSetsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list org scale sets params
func (o *ListOrgScaleSetsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithOrgID adds the orgID to the list org scale sets params
func (o *ListOrgScaleSetsParams) WithOrgID(orgID string) *ListOrgScaleSetsParams {
o.SetOrgID(orgID)
return o
}
// SetOrgID adds the orgId to the list org scale sets params
func (o *ListOrgScaleSetsParams) SetOrgID(orgID string) {
o.OrgID = orgID
}
// WriteToRequest writes these params to a swagger request
func (o *ListOrgScaleSetsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param orgID
if err := r.SetPathParam("orgID", o.OrgID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package organizations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListOrgScaleSetsReader is a Reader for the ListOrgScaleSets structure.
type ListOrgScaleSetsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListOrgScaleSetsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListOrgScaleSetsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListOrgScaleSetsDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListOrgScaleSetsOK creates a ListOrgScaleSetsOK with default headers values
func NewListOrgScaleSetsOK() *ListOrgScaleSetsOK {
return &ListOrgScaleSetsOK{}
}
/*
ListOrgScaleSetsOK describes a response with status code 200, with default header values.
ScaleSets
*/
type ListOrgScaleSetsOK struct {
Payload garm_params.ScaleSets
}
// IsSuccess returns true when this list org scale sets o k response has a 2xx status code
func (o *ListOrgScaleSetsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list org scale sets o k response has a 3xx status code
func (o *ListOrgScaleSetsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list org scale sets o k response has a 4xx status code
func (o *ListOrgScaleSetsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list org scale sets o k response has a 5xx status code
func (o *ListOrgScaleSetsOK) IsServerError() bool {
return false
}
// IsCode returns true when this list org scale sets o k response a status code equal to that given
func (o *ListOrgScaleSetsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list org scale sets o k response
func (o *ListOrgScaleSetsOK) Code() int {
return 200
}
func (o *ListOrgScaleSetsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /organizations/{orgID}/scalesets][%d] listOrgScaleSetsOK %s", 200, payload)
}
func (o *ListOrgScaleSetsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /organizations/{orgID}/scalesets][%d] listOrgScaleSetsOK %s", 200, payload)
}
func (o *ListOrgScaleSetsOK) GetPayload() garm_params.ScaleSets {
return o.Payload
}
func (o *ListOrgScaleSetsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListOrgScaleSetsDefault creates a ListOrgScaleSetsDefault with default headers values
func NewListOrgScaleSetsDefault(code int) *ListOrgScaleSetsDefault {
return &ListOrgScaleSetsDefault{
_statusCode: code,
}
}
/*
ListOrgScaleSetsDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListOrgScaleSetsDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list org scale sets default response has a 2xx status code
func (o *ListOrgScaleSetsDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list org scale sets default response has a 3xx status code
func (o *ListOrgScaleSetsDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list org scale sets default response has a 4xx status code
func (o *ListOrgScaleSetsDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list org scale sets default response has a 5xx status code
func (o *ListOrgScaleSetsDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list org scale sets default response a status code equal to that given
func (o *ListOrgScaleSetsDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list org scale sets default response
func (o *ListOrgScaleSetsDefault) Code() int {
return o._statusCode
}
func (o *ListOrgScaleSetsDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /organizations/{orgID}/scalesets][%d] ListOrgScaleSets default %s", o._statusCode, payload)
}
func (o *ListOrgScaleSetsDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /organizations/{orgID}/scalesets][%d] ListOrgScaleSets default %s", o._statusCode, payload)
}
func (o *ListOrgScaleSetsDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListOrgScaleSetsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -60,6 +60,19 @@ ListOrgsParams contains all the parameters to send to the API endpoint
Typically these are written to a http.Request.
*/
type ListOrgsParams struct {
/* Endpoint.
Exact endpoint name to filter by
*/
Endpoint *string
/* Name.
Exact organization name to filter by
*/
Name *string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
@ -113,6 +126,28 @@ func (o *ListOrgsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithEndpoint adds the endpoint to the list orgs params
func (o *ListOrgsParams) WithEndpoint(endpoint *string) *ListOrgsParams {
o.SetEndpoint(endpoint)
return o
}
// SetEndpoint adds the endpoint to the list orgs params
func (o *ListOrgsParams) SetEndpoint(endpoint *string) {
o.Endpoint = endpoint
}
// WithName adds the name to the list orgs params
func (o *ListOrgsParams) WithName(name *string) *ListOrgsParams {
o.SetName(name)
return o
}
// SetName adds the name to the list orgs params
func (o *ListOrgsParams) SetName(name *string) {
o.Name = name
}
// WriteToRequest writes these params to a swagger request
func (o *ListOrgsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
@ -121,6 +156,40 @@ func (o *ListOrgsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regi
}
var res []error
if o.Endpoint != nil {
// query param endpoint
var qrEndpoint string
if o.Endpoint != nil {
qrEndpoint = *o.Endpoint
}
qEndpoint := qrEndpoint
if qEndpoint != "" {
if err := r.SetQueryParam("endpoint", qEndpoint); err != nil {
return err
}
}
}
if o.Name != nil {
// query param name
var qrName string
if o.Name != nil {
qrName = *o.Name
}
qName := qrName
if qName != "" {
if err := r.SetQueryParam("name", qName); err != nil {
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}

View file

@ -58,6 +58,8 @@ type ClientService interface {
CreateOrgPool(params *CreateOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgPoolOK, error)
CreateOrgScaleSet(params *CreateOrgScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgScaleSetOK, error)
DeleteOrg(params *DeleteOrgParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
DeleteOrgPool(params *DeleteOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
@ -74,6 +76,8 @@ type ClientService interface {
ListOrgPools(params *ListOrgPoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgPoolsOK, error)
ListOrgScaleSets(params *ListOrgScaleSetsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgScaleSetsOK, error)
ListOrgs(params *ListOrgsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgsOK, error)
UninstallOrgWebhook(params *UninstallOrgWebhookParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
@ -161,6 +165,44 @@ func (a *Client) CreateOrgPool(params *CreateOrgPoolParams, authInfo runtime.Cli
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
CreateOrgScaleSet creates organization scale set with the parameters given
*/
func (a *Client) CreateOrgScaleSet(params *CreateOrgScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOrgScaleSetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateOrgScaleSetParams()
}
op := &runtime.ClientOperation{
ID: "CreateOrgScaleSet",
Method: "POST",
PathPattern: "/organizations/{orgID}/scalesets",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateOrgScaleSetReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateOrgScaleSetOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*CreateOrgScaleSetDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
DeleteOrg deletes organization by ID
*/
@ -455,6 +497,44 @@ func (a *Client) ListOrgPools(params *ListOrgPoolsParams, authInfo runtime.Clien
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListOrgScaleSets lists organization scale sets
*/
func (a *Client) ListOrgScaleSets(params *ListOrgScaleSetsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgScaleSetsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListOrgScaleSetsParams()
}
op := &runtime.ClientOperation{
ID: "ListOrgScaleSets",
Method: "GET",
PathPattern: "/organizations/{orgID}/scalesets",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListOrgScaleSetsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListOrgScaleSetsOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListOrgScaleSetsDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListOrgs lists organizations
*/

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewCreateRepoScaleSetParams creates a new CreateRepoScaleSetParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewCreateRepoScaleSetParams() *CreateRepoScaleSetParams {
return &CreateRepoScaleSetParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateRepoScaleSetParamsWithTimeout creates a new CreateRepoScaleSetParams object
// with the ability to set a timeout on a request.
func NewCreateRepoScaleSetParamsWithTimeout(timeout time.Duration) *CreateRepoScaleSetParams {
return &CreateRepoScaleSetParams{
timeout: timeout,
}
}
// NewCreateRepoScaleSetParamsWithContext creates a new CreateRepoScaleSetParams object
// with the ability to set a context for a request.
func NewCreateRepoScaleSetParamsWithContext(ctx context.Context) *CreateRepoScaleSetParams {
return &CreateRepoScaleSetParams{
Context: ctx,
}
}
// NewCreateRepoScaleSetParamsWithHTTPClient creates a new CreateRepoScaleSetParams object
// with the ability to set a custom HTTPClient for a request.
func NewCreateRepoScaleSetParamsWithHTTPClient(client *http.Client) *CreateRepoScaleSetParams {
return &CreateRepoScaleSetParams{
HTTPClient: client,
}
}
/*
CreateRepoScaleSetParams contains all the parameters to send to the API endpoint
for the create repo scale set operation.
Typically these are written to a http.Request.
*/
type CreateRepoScaleSetParams struct {
/* Body.
Parameters used when creating the repository scale set.
*/
Body garm_params.CreateScaleSetParams
/* RepoID.
Repository ID.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the create repo scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateRepoScaleSetParams) WithDefaults() *CreateRepoScaleSetParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the create repo scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateRepoScaleSetParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the create repo scale set params
func (o *CreateRepoScaleSetParams) WithTimeout(timeout time.Duration) *CreateRepoScaleSetParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create repo scale set params
func (o *CreateRepoScaleSetParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create repo scale set params
func (o *CreateRepoScaleSetParams) WithContext(ctx context.Context) *CreateRepoScaleSetParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create repo scale set params
func (o *CreateRepoScaleSetParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create repo scale set params
func (o *CreateRepoScaleSetParams) WithHTTPClient(client *http.Client) *CreateRepoScaleSetParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create repo scale set params
func (o *CreateRepoScaleSetParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create repo scale set params
func (o *CreateRepoScaleSetParams) WithBody(body garm_params.CreateScaleSetParams) *CreateRepoScaleSetParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create repo scale set params
func (o *CreateRepoScaleSetParams) SetBody(body garm_params.CreateScaleSetParams) {
o.Body = body
}
// WithRepoID adds the repoID to the create repo scale set params
func (o *CreateRepoScaleSetParams) WithRepoID(repoID string) *CreateRepoScaleSetParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the create repo scale set params
func (o *CreateRepoScaleSetParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *CreateRepoScaleSetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// CreateRepoScaleSetReader is a Reader for the CreateRepoScaleSet structure.
type CreateRepoScaleSetReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateRepoScaleSetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateRepoScaleSetOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewCreateRepoScaleSetDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewCreateRepoScaleSetOK creates a CreateRepoScaleSetOK with default headers values
func NewCreateRepoScaleSetOK() *CreateRepoScaleSetOK {
return &CreateRepoScaleSetOK{}
}
/*
CreateRepoScaleSetOK describes a response with status code 200, with default header values.
ScaleSet
*/
type CreateRepoScaleSetOK struct {
Payload garm_params.ScaleSet
}
// IsSuccess returns true when this create repo scale set o k response has a 2xx status code
func (o *CreateRepoScaleSetOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this create repo scale set o k response has a 3xx status code
func (o *CreateRepoScaleSetOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this create repo scale set o k response has a 4xx status code
func (o *CreateRepoScaleSetOK) IsClientError() bool {
return false
}
// IsServerError returns true when this create repo scale set o k response has a 5xx status code
func (o *CreateRepoScaleSetOK) IsServerError() bool {
return false
}
// IsCode returns true when this create repo scale set o k response a status code equal to that given
func (o *CreateRepoScaleSetOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the create repo scale set o k response
func (o *CreateRepoScaleSetOK) Code() int {
return 200
}
func (o *CreateRepoScaleSetOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /repositories/{repoID}/scalesets][%d] createRepoScaleSetOK %s", 200, payload)
}
func (o *CreateRepoScaleSetOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /repositories/{repoID}/scalesets][%d] createRepoScaleSetOK %s", 200, payload)
}
func (o *CreateRepoScaleSetOK) GetPayload() garm_params.ScaleSet {
return o.Payload
}
func (o *CreateRepoScaleSetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateRepoScaleSetDefault creates a CreateRepoScaleSetDefault with default headers values
func NewCreateRepoScaleSetDefault(code int) *CreateRepoScaleSetDefault {
return &CreateRepoScaleSetDefault{
_statusCode: code,
}
}
/*
CreateRepoScaleSetDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type CreateRepoScaleSetDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this create repo scale set default response has a 2xx status code
func (o *CreateRepoScaleSetDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this create repo scale set default response has a 3xx status code
func (o *CreateRepoScaleSetDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this create repo scale set default response has a 4xx status code
func (o *CreateRepoScaleSetDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this create repo scale set default response has a 5xx status code
func (o *CreateRepoScaleSetDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this create repo scale set default response a status code equal to that given
func (o *CreateRepoScaleSetDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the create repo scale set default response
func (o *CreateRepoScaleSetDefault) Code() int {
return o._statusCode
}
func (o *CreateRepoScaleSetDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /repositories/{repoID}/scalesets][%d] CreateRepoScaleSet default %s", o._statusCode, payload)
}
func (o *CreateRepoScaleSetDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[POST /repositories/{repoID}/scalesets][%d] CreateRepoScaleSet default %s", o._statusCode, payload)
}
func (o *CreateRepoScaleSetDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *CreateRepoScaleSetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListRepoScaleSetsParams creates a new ListRepoScaleSetsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListRepoScaleSetsParams() *ListRepoScaleSetsParams {
return &ListRepoScaleSetsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListRepoScaleSetsParamsWithTimeout creates a new ListRepoScaleSetsParams object
// with the ability to set a timeout on a request.
func NewListRepoScaleSetsParamsWithTimeout(timeout time.Duration) *ListRepoScaleSetsParams {
return &ListRepoScaleSetsParams{
timeout: timeout,
}
}
// NewListRepoScaleSetsParamsWithContext creates a new ListRepoScaleSetsParams object
// with the ability to set a context for a request.
func NewListRepoScaleSetsParamsWithContext(ctx context.Context) *ListRepoScaleSetsParams {
return &ListRepoScaleSetsParams{
Context: ctx,
}
}
// NewListRepoScaleSetsParamsWithHTTPClient creates a new ListRepoScaleSetsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListRepoScaleSetsParamsWithHTTPClient(client *http.Client) *ListRepoScaleSetsParams {
return &ListRepoScaleSetsParams{
HTTPClient: client,
}
}
/*
ListRepoScaleSetsParams contains all the parameters to send to the API endpoint
for the list repo scale sets operation.
Typically these are written to a http.Request.
*/
type ListRepoScaleSetsParams struct {
/* RepoID.
Repository ID.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list repo scale sets params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListRepoScaleSetsParams) WithDefaults() *ListRepoScaleSetsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list repo scale sets params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListRepoScaleSetsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list repo scale sets params
func (o *ListRepoScaleSetsParams) WithTimeout(timeout time.Duration) *ListRepoScaleSetsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list repo scale sets params
func (o *ListRepoScaleSetsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list repo scale sets params
func (o *ListRepoScaleSetsParams) WithContext(ctx context.Context) *ListRepoScaleSetsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list repo scale sets params
func (o *ListRepoScaleSetsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list repo scale sets params
func (o *ListRepoScaleSetsParams) WithHTTPClient(client *http.Client) *ListRepoScaleSetsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list repo scale sets params
func (o *ListRepoScaleSetsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRepoID adds the repoID to the list repo scale sets params
func (o *ListRepoScaleSetsParams) WithRepoID(repoID string) *ListRepoScaleSetsParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the list repo scale sets params
func (o *ListRepoScaleSetsParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *ListRepoScaleSetsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListRepoScaleSetsReader is a Reader for the ListRepoScaleSets structure.
type ListRepoScaleSetsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListRepoScaleSetsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListRepoScaleSetsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListRepoScaleSetsDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListRepoScaleSetsOK creates a ListRepoScaleSetsOK with default headers values
func NewListRepoScaleSetsOK() *ListRepoScaleSetsOK {
return &ListRepoScaleSetsOK{}
}
/*
ListRepoScaleSetsOK describes a response with status code 200, with default header values.
ScaleSets
*/
type ListRepoScaleSetsOK struct {
Payload garm_params.ScaleSets
}
// IsSuccess returns true when this list repo scale sets o k response has a 2xx status code
func (o *ListRepoScaleSetsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list repo scale sets o k response has a 3xx status code
func (o *ListRepoScaleSetsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list repo scale sets o k response has a 4xx status code
func (o *ListRepoScaleSetsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list repo scale sets o k response has a 5xx status code
func (o *ListRepoScaleSetsOK) IsServerError() bool {
return false
}
// IsCode returns true when this list repo scale sets o k response a status code equal to that given
func (o *ListRepoScaleSetsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list repo scale sets o k response
func (o *ListRepoScaleSetsOK) Code() int {
return 200
}
func (o *ListRepoScaleSetsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /repositories/{repoID}/scalesets][%d] listRepoScaleSetsOK %s", 200, payload)
}
func (o *ListRepoScaleSetsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /repositories/{repoID}/scalesets][%d] listRepoScaleSetsOK %s", 200, payload)
}
func (o *ListRepoScaleSetsOK) GetPayload() garm_params.ScaleSets {
return o.Payload
}
func (o *ListRepoScaleSetsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListRepoScaleSetsDefault creates a ListRepoScaleSetsDefault with default headers values
func NewListRepoScaleSetsDefault(code int) *ListRepoScaleSetsDefault {
return &ListRepoScaleSetsDefault{
_statusCode: code,
}
}
/*
ListRepoScaleSetsDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListRepoScaleSetsDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list repo scale sets default response has a 2xx status code
func (o *ListRepoScaleSetsDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list repo scale sets default response has a 3xx status code
func (o *ListRepoScaleSetsDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list repo scale sets default response has a 4xx status code
func (o *ListRepoScaleSetsDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list repo scale sets default response has a 5xx status code
func (o *ListRepoScaleSetsDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list repo scale sets default response a status code equal to that given
func (o *ListRepoScaleSetsDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list repo scale sets default response
func (o *ListRepoScaleSetsDefault) Code() int {
return o._statusCode
}
func (o *ListRepoScaleSetsDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /repositories/{repoID}/scalesets][%d] ListRepoScaleSets default %s", o._statusCode, payload)
}
func (o *ListRepoScaleSetsDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /repositories/{repoID}/scalesets][%d] ListRepoScaleSets default %s", o._statusCode, payload)
}
func (o *ListRepoScaleSetsDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListRepoScaleSetsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -60,6 +60,25 @@ ListReposParams contains all the parameters to send to the API endpoint
Typically these are written to a http.Request.
*/
type ListReposParams struct {
/* Endpoint.
Exact endpoint name to filter by
*/
Endpoint *string
/* Name.
Exact repository name to filter by
*/
Name *string
/* Owner.
Exact owner name to filter by
*/
Owner *string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
@ -113,6 +132,39 @@ func (o *ListReposParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithEndpoint adds the endpoint to the list repos params
func (o *ListReposParams) WithEndpoint(endpoint *string) *ListReposParams {
o.SetEndpoint(endpoint)
return o
}
// SetEndpoint adds the endpoint to the list repos params
func (o *ListReposParams) SetEndpoint(endpoint *string) {
o.Endpoint = endpoint
}
// WithName adds the name to the list repos params
func (o *ListReposParams) WithName(name *string) *ListReposParams {
o.SetName(name)
return o
}
// SetName adds the name to the list repos params
func (o *ListReposParams) SetName(name *string) {
o.Name = name
}
// WithOwner adds the owner to the list repos params
func (o *ListReposParams) WithOwner(owner *string) *ListReposParams {
o.SetOwner(owner)
return o
}
// SetOwner adds the owner to the list repos params
func (o *ListReposParams) SetOwner(owner *string) {
o.Owner = owner
}
// WriteToRequest writes these params to a swagger request
func (o *ListReposParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
@ -121,6 +173,57 @@ func (o *ListReposParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg
}
var res []error
if o.Endpoint != nil {
// query param endpoint
var qrEndpoint string
if o.Endpoint != nil {
qrEndpoint = *o.Endpoint
}
qEndpoint := qrEndpoint
if qEndpoint != "" {
if err := r.SetQueryParam("endpoint", qEndpoint); err != nil {
return err
}
}
}
if o.Name != nil {
// query param name
var qrName string
if o.Name != nil {
qrName = *o.Name
}
qName := qrName
if qName != "" {
if err := r.SetQueryParam("name", qName); err != nil {
return err
}
}
}
if o.Owner != nil {
// query param owner
var qrOwner string
if o.Owner != nil {
qrOwner = *o.Owner
}
qOwner := qrOwner
if qOwner != "" {
if err := r.SetQueryParam("owner", qOwner); err != nil {
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}

View file

@ -58,6 +58,8 @@ type ClientService interface {
CreateRepoPool(params *CreateRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRepoPoolOK, error)
CreateRepoScaleSet(params *CreateRepoScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRepoScaleSetOK, error)
DeleteRepo(params *DeleteRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
DeleteRepoPool(params *DeleteRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
@ -74,6 +76,8 @@ type ClientService interface {
ListRepoPools(params *ListRepoPoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListRepoPoolsOK, error)
ListRepoScaleSets(params *ListRepoScaleSetsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListRepoScaleSetsOK, error)
ListRepos(params *ListReposParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListReposOK, error)
UninstallRepoWebhook(params *UninstallRepoWebhookParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
@ -161,6 +165,44 @@ func (a *Client) CreateRepoPool(params *CreateRepoPoolParams, authInfo runtime.C
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
CreateRepoScaleSet creates repository scale set with the parameters given
*/
func (a *Client) CreateRepoScaleSet(params *CreateRepoScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRepoScaleSetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateRepoScaleSetParams()
}
op := &runtime.ClientOperation{
ID: "CreateRepoScaleSet",
Method: "POST",
PathPattern: "/repositories/{repoID}/scalesets",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateRepoScaleSetReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateRepoScaleSetOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*CreateRepoScaleSetDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
DeleteRepo deletes repository by ID
*/
@ -455,6 +497,44 @@ func (a *Client) ListRepoPools(params *ListRepoPoolsParams, authInfo runtime.Cli
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListRepoScaleSets lists repository scale sets
*/
func (a *Client) ListRepoScaleSets(params *ListRepoScaleSetsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListRepoScaleSetsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListRepoScaleSetsParams()
}
op := &runtime.ClientOperation{
ID: "ListRepoScaleSets",
Method: "GET",
PathPattern: "/repositories/{repoID}/scalesets",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListRepoScaleSetsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListRepoScaleSetsOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListRepoScaleSetsDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListRepos lists repositories
*/

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewDeleteScaleSetParams creates a new DeleteScaleSetParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewDeleteScaleSetParams() *DeleteScaleSetParams {
return &DeleteScaleSetParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteScaleSetParamsWithTimeout creates a new DeleteScaleSetParams object
// with the ability to set a timeout on a request.
func NewDeleteScaleSetParamsWithTimeout(timeout time.Duration) *DeleteScaleSetParams {
return &DeleteScaleSetParams{
timeout: timeout,
}
}
// NewDeleteScaleSetParamsWithContext creates a new DeleteScaleSetParams object
// with the ability to set a context for a request.
func NewDeleteScaleSetParamsWithContext(ctx context.Context) *DeleteScaleSetParams {
return &DeleteScaleSetParams{
Context: ctx,
}
}
// NewDeleteScaleSetParamsWithHTTPClient creates a new DeleteScaleSetParams object
// with the ability to set a custom HTTPClient for a request.
func NewDeleteScaleSetParamsWithHTTPClient(client *http.Client) *DeleteScaleSetParams {
return &DeleteScaleSetParams{
HTTPClient: client,
}
}
/*
DeleteScaleSetParams contains all the parameters to send to the API endpoint
for the delete scale set operation.
Typically these are written to a http.Request.
*/
type DeleteScaleSetParams struct {
/* ScalesetID.
ID of the scale set to delete.
*/
ScalesetID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the delete scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteScaleSetParams) WithDefaults() *DeleteScaleSetParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the delete scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteScaleSetParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the delete scale set params
func (o *DeleteScaleSetParams) WithTimeout(timeout time.Duration) *DeleteScaleSetParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete scale set params
func (o *DeleteScaleSetParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete scale set params
func (o *DeleteScaleSetParams) WithContext(ctx context.Context) *DeleteScaleSetParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete scale set params
func (o *DeleteScaleSetParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete scale set params
func (o *DeleteScaleSetParams) WithHTTPClient(client *http.Client) *DeleteScaleSetParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete scale set params
func (o *DeleteScaleSetParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithScalesetID adds the scalesetID to the delete scale set params
func (o *DeleteScaleSetParams) WithScalesetID(scalesetID string) *DeleteScaleSetParams {
o.SetScalesetID(scalesetID)
return o
}
// SetScalesetID adds the scalesetId to the delete scale set params
func (o *DeleteScaleSetParams) SetScalesetID(scalesetID string) {
o.ScalesetID = scalesetID
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteScaleSetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param scalesetID
if err := r.SetPathParam("scalesetID", o.ScalesetID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,106 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
)
// DeleteScaleSetReader is a Reader for the DeleteScaleSet structure.
type DeleteScaleSetReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteScaleSetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
result := NewDeleteScaleSetDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
// NewDeleteScaleSetDefault creates a DeleteScaleSetDefault with default headers values
func NewDeleteScaleSetDefault(code int) *DeleteScaleSetDefault {
return &DeleteScaleSetDefault{
_statusCode: code,
}
}
/*
DeleteScaleSetDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type DeleteScaleSetDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this delete scale set default response has a 2xx status code
func (o *DeleteScaleSetDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this delete scale set default response has a 3xx status code
func (o *DeleteScaleSetDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this delete scale set default response has a 4xx status code
func (o *DeleteScaleSetDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this delete scale set default response has a 5xx status code
func (o *DeleteScaleSetDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this delete scale set default response a status code equal to that given
func (o *DeleteScaleSetDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the delete scale set default response
func (o *DeleteScaleSetDefault) Code() int {
return o._statusCode
}
func (o *DeleteScaleSetDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[DELETE /scalesets/{scalesetID}][%d] DeleteScaleSet default %s", o._statusCode, payload)
}
func (o *DeleteScaleSetDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[DELETE /scalesets/{scalesetID}][%d] DeleteScaleSet default %s", o._statusCode, payload)
}
func (o *DeleteScaleSetDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *DeleteScaleSetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewGetScaleSetParams creates a new GetScaleSetParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewGetScaleSetParams() *GetScaleSetParams {
return &GetScaleSetParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetScaleSetParamsWithTimeout creates a new GetScaleSetParams object
// with the ability to set a timeout on a request.
func NewGetScaleSetParamsWithTimeout(timeout time.Duration) *GetScaleSetParams {
return &GetScaleSetParams{
timeout: timeout,
}
}
// NewGetScaleSetParamsWithContext creates a new GetScaleSetParams object
// with the ability to set a context for a request.
func NewGetScaleSetParamsWithContext(ctx context.Context) *GetScaleSetParams {
return &GetScaleSetParams{
Context: ctx,
}
}
// NewGetScaleSetParamsWithHTTPClient creates a new GetScaleSetParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetScaleSetParamsWithHTTPClient(client *http.Client) *GetScaleSetParams {
return &GetScaleSetParams{
HTTPClient: client,
}
}
/*
GetScaleSetParams contains all the parameters to send to the API endpoint
for the get scale set operation.
Typically these are written to a http.Request.
*/
type GetScaleSetParams struct {
/* ScalesetID.
ID of the scale set to fetch.
*/
ScalesetID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetScaleSetParams) WithDefaults() *GetScaleSetParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetScaleSetParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get scale set params
func (o *GetScaleSetParams) WithTimeout(timeout time.Duration) *GetScaleSetParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get scale set params
func (o *GetScaleSetParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get scale set params
func (o *GetScaleSetParams) WithContext(ctx context.Context) *GetScaleSetParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get scale set params
func (o *GetScaleSetParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get scale set params
func (o *GetScaleSetParams) WithHTTPClient(client *http.Client) *GetScaleSetParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get scale set params
func (o *GetScaleSetParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithScalesetID adds the scalesetID to the get scale set params
func (o *GetScaleSetParams) WithScalesetID(scalesetID string) *GetScaleSetParams {
o.SetScalesetID(scalesetID)
return o
}
// SetScalesetID adds the scalesetId to the get scale set params
func (o *GetScaleSetParams) SetScalesetID(scalesetID string) {
o.ScalesetID = scalesetID
}
// WriteToRequest writes these params to a swagger request
func (o *GetScaleSetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param scalesetID
if err := r.SetPathParam("scalesetID", o.ScalesetID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// GetScaleSetReader is a Reader for the GetScaleSet structure.
type GetScaleSetReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetScaleSetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetScaleSetOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewGetScaleSetDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewGetScaleSetOK creates a GetScaleSetOK with default headers values
func NewGetScaleSetOK() *GetScaleSetOK {
return &GetScaleSetOK{}
}
/*
GetScaleSetOK describes a response with status code 200, with default header values.
ScaleSet
*/
type GetScaleSetOK struct {
Payload garm_params.ScaleSet
}
// IsSuccess returns true when this get scale set o k response has a 2xx status code
func (o *GetScaleSetOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get scale set o k response has a 3xx status code
func (o *GetScaleSetOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get scale set o k response has a 4xx status code
func (o *GetScaleSetOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get scale set o k response has a 5xx status code
func (o *GetScaleSetOK) IsServerError() bool {
return false
}
// IsCode returns true when this get scale set o k response a status code equal to that given
func (o *GetScaleSetOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get scale set o k response
func (o *GetScaleSetOK) Code() int {
return 200
}
func (o *GetScaleSetOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets/{scalesetID}][%d] getScaleSetOK %s", 200, payload)
}
func (o *GetScaleSetOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets/{scalesetID}][%d] getScaleSetOK %s", 200, payload)
}
func (o *GetScaleSetOK) GetPayload() garm_params.ScaleSet {
return o.Payload
}
func (o *GetScaleSetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetScaleSetDefault creates a GetScaleSetDefault with default headers values
func NewGetScaleSetDefault(code int) *GetScaleSetDefault {
return &GetScaleSetDefault{
_statusCode: code,
}
}
/*
GetScaleSetDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type GetScaleSetDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this get scale set default response has a 2xx status code
func (o *GetScaleSetDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this get scale set default response has a 3xx status code
func (o *GetScaleSetDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this get scale set default response has a 4xx status code
func (o *GetScaleSetDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this get scale set default response has a 5xx status code
func (o *GetScaleSetDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this get scale set default response a status code equal to that given
func (o *GetScaleSetDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the get scale set default response
func (o *GetScaleSetDefault) Code() int {
return o._statusCode
}
func (o *GetScaleSetDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets/{scalesetID}][%d] GetScaleSet default %s", o._statusCode, payload)
}
func (o *GetScaleSetDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets/{scalesetID}][%d] GetScaleSet default %s", o._statusCode, payload)
}
func (o *GetScaleSetDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *GetScaleSetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,128 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListScalesetsParams creates a new ListScalesetsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListScalesetsParams() *ListScalesetsParams {
return &ListScalesetsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListScalesetsParamsWithTimeout creates a new ListScalesetsParams object
// with the ability to set a timeout on a request.
func NewListScalesetsParamsWithTimeout(timeout time.Duration) *ListScalesetsParams {
return &ListScalesetsParams{
timeout: timeout,
}
}
// NewListScalesetsParamsWithContext creates a new ListScalesetsParams object
// with the ability to set a context for a request.
func NewListScalesetsParamsWithContext(ctx context.Context) *ListScalesetsParams {
return &ListScalesetsParams{
Context: ctx,
}
}
// NewListScalesetsParamsWithHTTPClient creates a new ListScalesetsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListScalesetsParamsWithHTTPClient(client *http.Client) *ListScalesetsParams {
return &ListScalesetsParams{
HTTPClient: client,
}
}
/*
ListScalesetsParams contains all the parameters to send to the API endpoint
for the list scalesets operation.
Typically these are written to a http.Request.
*/
type ListScalesetsParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list scalesets params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListScalesetsParams) WithDefaults() *ListScalesetsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list scalesets params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListScalesetsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list scalesets params
func (o *ListScalesetsParams) WithTimeout(timeout time.Duration) *ListScalesetsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list scalesets params
func (o *ListScalesetsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list scalesets params
func (o *ListScalesetsParams) WithContext(ctx context.Context) *ListScalesetsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list scalesets params
func (o *ListScalesetsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list scalesets params
func (o *ListScalesetsParams) WithHTTPClient(client *http.Client) *ListScalesetsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list scalesets params
func (o *ListScalesetsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ListScalesetsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListScalesetsReader is a Reader for the ListScalesets structure.
type ListScalesetsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListScalesetsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListScalesetsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListScalesetsDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListScalesetsOK creates a ListScalesetsOK with default headers values
func NewListScalesetsOK() *ListScalesetsOK {
return &ListScalesetsOK{}
}
/*
ListScalesetsOK describes a response with status code 200, with default header values.
ScaleSets
*/
type ListScalesetsOK struct {
Payload garm_params.ScaleSets
}
// IsSuccess returns true when this list scalesets o k response has a 2xx status code
func (o *ListScalesetsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list scalesets o k response has a 3xx status code
func (o *ListScalesetsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list scalesets o k response has a 4xx status code
func (o *ListScalesetsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list scalesets o k response has a 5xx status code
func (o *ListScalesetsOK) IsServerError() bool {
return false
}
// IsCode returns true when this list scalesets o k response a status code equal to that given
func (o *ListScalesetsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list scalesets o k response
func (o *ListScalesetsOK) Code() int {
return 200
}
func (o *ListScalesetsOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets][%d] listScalesetsOK %s", 200, payload)
}
func (o *ListScalesetsOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets][%d] listScalesetsOK %s", 200, payload)
}
func (o *ListScalesetsOK) GetPayload() garm_params.ScaleSets {
return o.Payload
}
func (o *ListScalesetsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListScalesetsDefault creates a ListScalesetsDefault with default headers values
func NewListScalesetsDefault(code int) *ListScalesetsDefault {
return &ListScalesetsDefault{
_statusCode: code,
}
}
/*
ListScalesetsDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListScalesetsDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list scalesets default response has a 2xx status code
func (o *ListScalesetsDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list scalesets default response has a 3xx status code
func (o *ListScalesetsDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list scalesets default response has a 4xx status code
func (o *ListScalesetsDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list scalesets default response has a 5xx status code
func (o *ListScalesetsDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list scalesets default response a status code equal to that given
func (o *ListScalesetsDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list scalesets default response
func (o *ListScalesetsDefault) Code() int {
return o._statusCode
}
func (o *ListScalesetsDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets][%d] ListScalesets default %s", o._statusCode, payload)
}
func (o *ListScalesetsDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[GET /scalesets][%d] ListScalesets default %s", o._statusCode, payload)
}
func (o *ListScalesetsDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListScalesetsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,217 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// New creates a new scalesets API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
// New creates a new scalesets API client with basic auth credentials.
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - user: user for basic authentication header.
// - password: password for basic authentication header.
func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService {
transport := httptransport.New(host, basePath, []string{scheme})
transport.DefaultAuthentication = httptransport.BasicAuth(user, password)
return &Client{transport: transport, formats: strfmt.Default}
}
// New creates a new scalesets API client with a bearer token for authentication.
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - bearerToken: bearer token for Bearer authentication header.
func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService {
transport := httptransport.New(host, basePath, []string{scheme})
transport.DefaultAuthentication = httptransport.BearerToken(bearerToken)
return &Client{transport: transport, formats: strfmt.Default}
}
/*
Client for scalesets API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption may be used to customize the behavior of Client methods.
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
DeleteScaleSet(params *DeleteScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
GetScaleSet(params *GetScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetScaleSetOK, error)
ListScalesets(params *ListScalesetsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListScalesetsOK, error)
UpdateScaleSet(params *UpdateScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateScaleSetOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
DeleteScaleSet deletes scale set by ID
*/
func (a *Client) DeleteScaleSet(params *DeleteScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteScaleSetParams()
}
op := &runtime.ClientOperation{
ID: "DeleteScaleSet",
Method: "DELETE",
PathPattern: "/scalesets/{scalesetID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &DeleteScaleSetReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
_, err := a.transport.Submit(op)
if err != nil {
return err
}
return nil
}
/*
GetScaleSet gets scale set by ID
*/
func (a *Client) GetScaleSet(params *GetScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetScaleSetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetScaleSetParams()
}
op := &runtime.ClientOperation{
ID: "GetScaleSet",
Method: "GET",
PathPattern: "/scalesets/{scalesetID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetScaleSetReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetScaleSetOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*GetScaleSetDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListScalesets lists all scalesets
*/
func (a *Client) ListScalesets(params *ListScalesetsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListScalesetsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListScalesetsParams()
}
op := &runtime.ClientOperation{
ID: "ListScalesets",
Method: "GET",
PathPattern: "/scalesets",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListScalesetsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListScalesetsOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListScalesetsDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
UpdateScaleSet updates scale set by ID
*/
func (a *Client) UpdateScaleSet(params *UpdateScaleSetParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateScaleSetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateScaleSetParams()
}
op := &runtime.ClientOperation{
ID: "UpdateScaleSet",
Method: "PUT",
PathPattern: "/scalesets/{scalesetID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &UpdateScaleSetReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*UpdateScaleSetOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*UpdateScaleSetDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewUpdateScaleSetParams creates a new UpdateScaleSetParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewUpdateScaleSetParams() *UpdateScaleSetParams {
return &UpdateScaleSetParams{
timeout: cr.DefaultTimeout,
}
}
// NewUpdateScaleSetParamsWithTimeout creates a new UpdateScaleSetParams object
// with the ability to set a timeout on a request.
func NewUpdateScaleSetParamsWithTimeout(timeout time.Duration) *UpdateScaleSetParams {
return &UpdateScaleSetParams{
timeout: timeout,
}
}
// NewUpdateScaleSetParamsWithContext creates a new UpdateScaleSetParams object
// with the ability to set a context for a request.
func NewUpdateScaleSetParamsWithContext(ctx context.Context) *UpdateScaleSetParams {
return &UpdateScaleSetParams{
Context: ctx,
}
}
// NewUpdateScaleSetParamsWithHTTPClient creates a new UpdateScaleSetParams object
// with the ability to set a custom HTTPClient for a request.
func NewUpdateScaleSetParamsWithHTTPClient(client *http.Client) *UpdateScaleSetParams {
return &UpdateScaleSetParams{
HTTPClient: client,
}
}
/*
UpdateScaleSetParams contains all the parameters to send to the API endpoint
for the update scale set operation.
Typically these are written to a http.Request.
*/
type UpdateScaleSetParams struct {
/* Body.
Parameters to update the scale set with.
*/
Body garm_params.UpdateScaleSetParams
/* ScalesetID.
ID of the scale set to update.
*/
ScalesetID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the update scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateScaleSetParams) WithDefaults() *UpdateScaleSetParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the update scale set params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateScaleSetParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the update scale set params
func (o *UpdateScaleSetParams) WithTimeout(timeout time.Duration) *UpdateScaleSetParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the update scale set params
func (o *UpdateScaleSetParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the update scale set params
func (o *UpdateScaleSetParams) WithContext(ctx context.Context) *UpdateScaleSetParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the update scale set params
func (o *UpdateScaleSetParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the update scale set params
func (o *UpdateScaleSetParams) WithHTTPClient(client *http.Client) *UpdateScaleSetParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the update scale set params
func (o *UpdateScaleSetParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the update scale set params
func (o *UpdateScaleSetParams) WithBody(body garm_params.UpdateScaleSetParams) *UpdateScaleSetParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the update scale set params
func (o *UpdateScaleSetParams) SetBody(body garm_params.UpdateScaleSetParams) {
o.Body = body
}
// WithScalesetID adds the scalesetID to the update scale set params
func (o *UpdateScaleSetParams) WithScalesetID(scalesetID string) *UpdateScaleSetParams {
o.SetScalesetID(scalesetID)
return o
}
// SetScalesetID adds the scalesetId to the update scale set params
func (o *UpdateScaleSetParams) SetScalesetID(scalesetID string) {
o.ScalesetID = scalesetID
}
// WriteToRequest writes these params to a swagger request
func (o *UpdateScaleSetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param scalesetID
if err := r.SetPathParam("scalesetID", o.ScalesetID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,184 @@
// Code generated by go-swagger; DO NOT EDIT.
package scalesets
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// UpdateScaleSetReader is a Reader for the UpdateScaleSet structure.
type UpdateScaleSetReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UpdateScaleSetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewUpdateScaleSetOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewUpdateScaleSetDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewUpdateScaleSetOK creates a UpdateScaleSetOK with default headers values
func NewUpdateScaleSetOK() *UpdateScaleSetOK {
return &UpdateScaleSetOK{}
}
/*
UpdateScaleSetOK describes a response with status code 200, with default header values.
ScaleSet
*/
type UpdateScaleSetOK struct {
Payload garm_params.ScaleSet
}
// IsSuccess returns true when this update scale set o k response has a 2xx status code
func (o *UpdateScaleSetOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this update scale set o k response has a 3xx status code
func (o *UpdateScaleSetOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this update scale set o k response has a 4xx status code
func (o *UpdateScaleSetOK) IsClientError() bool {
return false
}
// IsServerError returns true when this update scale set o k response has a 5xx status code
func (o *UpdateScaleSetOK) IsServerError() bool {
return false
}
// IsCode returns true when this update scale set o k response a status code equal to that given
func (o *UpdateScaleSetOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the update scale set o k response
func (o *UpdateScaleSetOK) Code() int {
return 200
}
func (o *UpdateScaleSetOK) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /scalesets/{scalesetID}][%d] updateScaleSetOK %s", 200, payload)
}
func (o *UpdateScaleSetOK) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /scalesets/{scalesetID}][%d] updateScaleSetOK %s", 200, payload)
}
func (o *UpdateScaleSetOK) GetPayload() garm_params.ScaleSet {
return o.Payload
}
func (o *UpdateScaleSetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewUpdateScaleSetDefault creates a UpdateScaleSetDefault with default headers values
func NewUpdateScaleSetDefault(code int) *UpdateScaleSetDefault {
return &UpdateScaleSetDefault{
_statusCode: code,
}
}
/*
UpdateScaleSetDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type UpdateScaleSetDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this update scale set default response has a 2xx status code
func (o *UpdateScaleSetDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this update scale set default response has a 3xx status code
func (o *UpdateScaleSetDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this update scale set default response has a 4xx status code
func (o *UpdateScaleSetDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this update scale set default response has a 5xx status code
func (o *UpdateScaleSetDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this update scale set default response a status code equal to that given
func (o *UpdateScaleSetDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the update scale set default response
func (o *UpdateScaleSetDefault) Code() int {
return o._statusCode
}
func (o *UpdateScaleSetDefault) Error() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /scalesets/{scalesetID}][%d] UpdateScaleSet default %s", o._statusCode, payload)
}
func (o *UpdateScaleSetDefault) String() string {
payload, _ := json.Marshal(o.Payload)
return fmt.Sprintf("[PUT /scalesets/{scalesetID}][%d] UpdateScaleSet default %s", o._statusCode, payload)
}
func (o *UpdateScaleSetDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *UpdateScaleSetDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

Some files were not shown because too many files have changed in this diff Show more