2022-05-05 13:25:50 +00:00
|
|
|
// 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.
|
|
|
|
|
|
2022-04-15 15:22:47 +00:00
|
|
|
package params
|
|
|
|
|
|
2022-04-28 16:13:20 +00:00
|
|
|
import (
|
2024-04-15 08:32:19 +00:00
|
|
|
"crypto/x509"
|
2023-01-30 00:40:01 +00:00
|
|
|
"encoding/json"
|
2024-04-15 08:32:19 +00:00
|
|
|
"encoding/pem"
|
2022-04-29 16:08:31 +00:00
|
|
|
"fmt"
|
2023-01-24 08:56:57 +01:00
|
|
|
|
2023-07-22 22:26:47 +00:00
|
|
|
"github.com/cloudbase/garm-provider-common/errors"
|
2024-02-22 07:31:51 +01:00
|
|
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
2022-04-28 16:13:20 +00:00
|
|
|
)
|
2022-04-19 20:22:50 +00:00
|
|
|
|
2022-12-19 20:56:16 +01:00
|
|
|
const DefaultRunnerPrefix = "garm"
|
|
|
|
|
|
2022-04-15 15:22:47 +00:00
|
|
|
type InstanceRequest struct {
|
2023-07-21 15:30:22 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
|
OSType commonParams.OSType `json:"os_type"`
|
|
|
|
|
OSVersion string `json:"os_version"`
|
2022-04-15 15:22:47 +00:00
|
|
|
}
|
2022-04-28 16:13:20 +00:00
|
|
|
|
|
|
|
|
type CreateRepoParams struct {
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
Owner string `json:"owner"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
CredentialsName string `json:"credentials_name"`
|
|
|
|
|
WebhookSecret string `json:"webhook_secret"`
|
|
|
|
|
PoolBalancerType PoolBalancerType `json:"pool_balancer_type"`
|
2022-04-28 16:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-29 14:18:22 +00:00
|
|
|
func (c *CreateRepoParams) Validate() error {
|
|
|
|
|
if c.Owner == "" {
|
|
|
|
|
return errors.NewBadRequestError("missing owner")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.Name == "" {
|
|
|
|
|
return errors.NewBadRequestError("missing repo name")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.CredentialsName == "" {
|
|
|
|
|
return errors.NewBadRequestError("missing credentials name")
|
|
|
|
|
}
|
2023-01-24 08:56:57 +01:00
|
|
|
if c.WebhookSecret == "" {
|
|
|
|
|
return errors.NewMissingSecretError("missing secret")
|
|
|
|
|
}
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
|
|
|
|
|
switch c.PoolBalancerType {
|
2024-03-15 14:35:05 +00:00
|
|
|
case PoolBalancerTypeRoundRobin, PoolBalancerTypePack, PoolBalancerTypeNone:
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
default:
|
|
|
|
|
return errors.NewBadRequestError("invalid pool balancer type")
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-29 14:18:22 +00:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-04 16:27:24 +00:00
|
|
|
type CreateOrgParams struct {
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
|
CredentialsName string `json:"credentials_name"`
|
|
|
|
|
WebhookSecret string `json:"webhook_secret"`
|
|
|
|
|
PoolBalancerType PoolBalancerType `json:"pool_balancer_type"`
|
2022-05-04 16:27:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *CreateOrgParams) Validate() error {
|
|
|
|
|
if c.Name == "" {
|
2022-08-10 12:15:12 +03:00
|
|
|
return errors.NewBadRequestError("missing org name")
|
2022-10-13 16:09:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.CredentialsName == "" {
|
|
|
|
|
return errors.NewBadRequestError("missing credentials name")
|
|
|
|
|
}
|
2023-01-24 08:56:57 +01:00
|
|
|
if c.WebhookSecret == "" {
|
|
|
|
|
return errors.NewMissingSecretError("missing secret")
|
|
|
|
|
}
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
|
|
|
|
|
switch c.PoolBalancerType {
|
2024-03-15 14:35:05 +00:00
|
|
|
case PoolBalancerTypeRoundRobin, PoolBalancerTypePack, PoolBalancerTypeNone:
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
default:
|
|
|
|
|
return errors.NewBadRequestError("invalid pool balancer type")
|
|
|
|
|
}
|
2022-10-13 16:09:28 +00:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CreateEnterpriseParams struct {
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
|
CredentialsName string `json:"credentials_name"`
|
|
|
|
|
WebhookSecret string `json:"webhook_secret"`
|
|
|
|
|
PoolBalancerType PoolBalancerType `json:"pool_balancer_type"`
|
2022-10-13 16:09:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *CreateEnterpriseParams) Validate() error {
|
|
|
|
|
if c.Name == "" {
|
2022-12-04 17:30:27 +00:00
|
|
|
return errors.NewBadRequestError("missing enterprise name")
|
2022-05-04 16:27:24 +00:00
|
|
|
}
|
|
|
|
|
if c.CredentialsName == "" {
|
|
|
|
|
return errors.NewBadRequestError("missing credentials name")
|
|
|
|
|
}
|
2023-01-24 08:56:57 +01:00
|
|
|
if c.WebhookSecret == "" {
|
|
|
|
|
return errors.NewMissingSecretError("missing secret")
|
|
|
|
|
}
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
|
|
|
|
|
switch c.PoolBalancerType {
|
2024-03-15 14:35:05 +00:00
|
|
|
case PoolBalancerTypeRoundRobin, PoolBalancerTypePack, PoolBalancerTypeNone:
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
default:
|
|
|
|
|
return errors.NewBadRequestError("invalid pool balancer type")
|
|
|
|
|
}
|
2022-05-04 16:27:24 +00:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-28 16:13:20 +00:00
|
|
|
// NewUserParams holds the needed information to create
|
|
|
|
|
// a new user
|
|
|
|
|
type NewUserParams struct {
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
FullName string `json:"full_name"`
|
|
|
|
|
Password string `json:"password"`
|
|
|
|
|
IsAdmin bool `json:"-"`
|
|
|
|
|
Enabled bool `json:"-"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UpdatePoolParams struct {
|
2023-01-20 12:05:32 +02:00
|
|
|
RunnerPrefix
|
|
|
|
|
|
2023-07-21 15:30:22 +00:00
|
|
|
Tags []string `json:"tags,omitempty"`
|
|
|
|
|
Enabled *bool `json:"enabled,omitempty"`
|
|
|
|
|
MaxRunners *uint `json:"max_runners,omitempty"`
|
|
|
|
|
MinIdleRunners *uint `json:"min_idle_runners,omitempty"`
|
|
|
|
|
RunnerBootstrapTimeout *uint `json:"runner_bootstrap_timeout,omitempty"`
|
|
|
|
|
Image string `json:"image"`
|
|
|
|
|
Flavor string `json:"flavor"`
|
|
|
|
|
OSType commonParams.OSType `json:"os_type"`
|
|
|
|
|
OSArch commonParams.OSArch `json:"os_arch"`
|
|
|
|
|
ExtraSpecs json.RawMessage `json:"extra_specs,omitempty"`
|
2023-03-27 08:40:22 +00:00
|
|
|
// GithubRunnerGroup is the github runner group in which the runners of this
|
|
|
|
|
// pool will be added to.
|
|
|
|
|
// The runner group must be created by someone with access to the enterprise.
|
|
|
|
|
GitHubRunnerGroup *string `json:"github-runner-group,omitempty"`
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
Priority *uint `json:"priority,omitempty"`
|
2022-04-28 16:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CreateInstanceParams struct {
|
2023-03-27 08:40:22 +00:00
|
|
|
Name string
|
2023-07-21 15:30:22 +00:00
|
|
|
OSType commonParams.OSType
|
|
|
|
|
OSArch commonParams.OSArch
|
|
|
|
|
Status commonParams.InstanceStatus
|
|
|
|
|
RunnerStatus RunnerStatus
|
2023-03-27 08:40:22 +00:00
|
|
|
CallbackURL string
|
|
|
|
|
MetadataURL string
|
|
|
|
|
// GithubRunnerGroup is the github runner group to which the runner belongs.
|
|
|
|
|
// The runner group must be created by someone with access to the enterprise.
|
|
|
|
|
GitHubRunnerGroup string
|
2023-08-26 19:40:01 +00:00
|
|
|
CreateAttempt int `json:"-"`
|
|
|
|
|
AgentID int64 `json:"-"`
|
2023-06-24 00:22:51 +00:00
|
|
|
AditionalLabels []string
|
2023-08-18 06:09:44 +00:00
|
|
|
JitConfiguration map[string]string
|
2022-04-28 16:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CreatePoolParams struct {
|
2023-01-20 12:05:32 +02:00
|
|
|
RunnerPrefix
|
|
|
|
|
|
2023-07-21 15:30:22 +00:00
|
|
|
ProviderName string `json:"provider_name"`
|
|
|
|
|
MaxRunners uint `json:"max_runners"`
|
|
|
|
|
MinIdleRunners uint `json:"min_idle_runners"`
|
|
|
|
|
Image string `json:"image"`
|
|
|
|
|
Flavor string `json:"flavor"`
|
|
|
|
|
OSType commonParams.OSType `json:"os_type"`
|
|
|
|
|
OSArch commonParams.OSArch `json:"os_arch"`
|
|
|
|
|
Tags []string `json:"tags"`
|
|
|
|
|
Enabled bool `json:"enabled"`
|
|
|
|
|
RunnerBootstrapTimeout uint `json:"runner_bootstrap_timeout"`
|
|
|
|
|
ExtraSpecs json.RawMessage `json:"extra_specs,omitempty"`
|
2023-03-27 08:40:22 +00:00
|
|
|
// GithubRunnerGroup is the github runner group in which the runners of this
|
|
|
|
|
// pool will be added to.
|
|
|
|
|
// The runner group must be created by someone with access to the enterprise.
|
|
|
|
|
GitHubRunnerGroup string `json:"github-runner-group"`
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
Priority uint `json:"priority"`
|
2022-04-28 16:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-29 16:08:31 +00:00
|
|
|
func (p *CreatePoolParams) Validate() error {
|
|
|
|
|
if p.ProviderName == "" {
|
|
|
|
|
return fmt.Errorf("missing provider")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.MinIdleRunners > p.MaxRunners {
|
|
|
|
|
return fmt.Errorf("min_idle_runners cannot be larger than max_runners")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.MaxRunners == 0 {
|
|
|
|
|
return fmt.Errorf("max_runners cannot be 0")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(p.Tags) == 0 {
|
|
|
|
|
return fmt.Errorf("missing tags")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.Flavor == "" {
|
|
|
|
|
return fmt.Errorf("missing flavor")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.Image == "" {
|
|
|
|
|
return fmt.Errorf("missing image")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-28 16:13:20 +00:00
|
|
|
type UpdateInstanceParams struct {
|
|
|
|
|
ProviderID string `json:"provider_id,omitempty"`
|
|
|
|
|
// OSName is the name of the OS. Eg: ubuntu, centos, etc.
|
|
|
|
|
OSName string `json:"os_name,omitempty"`
|
|
|
|
|
// OSVersion is the version of the operating system.
|
|
|
|
|
OSVersion string `json:"os_version,omitempty"`
|
|
|
|
|
// Addresses is a list of IP addresses the provider reports
|
|
|
|
|
// for this instance.
|
2023-07-21 15:30:22 +00:00
|
|
|
Addresses []commonParams.Address `json:"addresses,omitempty"`
|
2022-04-28 16:13:20 +00:00
|
|
|
// Status is the status of the instance inside the provider (eg: running, stopped, etc)
|
2023-08-19 16:31:02 +00:00
|
|
|
Status commonParams.InstanceStatus `json:"status,omitempty"`
|
|
|
|
|
RunnerStatus RunnerStatus `json:"runner_status,omitempty"`
|
|
|
|
|
ProviderFault []byte `json:"provider_fault,omitempty"`
|
|
|
|
|
AgentID int64 `json:"-"`
|
|
|
|
|
CreateAttempt int `json:"-"`
|
|
|
|
|
TokenFetched *bool `json:"-"`
|
|
|
|
|
JitConfiguration map[string]string `json:"-"`
|
2022-04-28 16:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UpdateUserParams struct {
|
|
|
|
|
FullName string `json:"full_name"`
|
|
|
|
|
Password string `json:"password"`
|
|
|
|
|
Enabled *bool `json:"enabled"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PasswordLoginParams holds information used during
|
|
|
|
|
// password authentication, that will be passed to a
|
|
|
|
|
// password login function
|
|
|
|
|
type PasswordLoginParams struct {
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
Password string `json:"password"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate checks if the username and password are set
|
|
|
|
|
func (p PasswordLoginParams) Validate() error {
|
|
|
|
|
if p.Username == "" || p.Password == "" {
|
|
|
|
|
return errors.ErrUnauthorized
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2022-04-29 14:18:22 +00:00
|
|
|
|
2023-07-04 23:47:55 +00:00
|
|
|
type UpdateEntityParams struct {
|
Add pool balancing strategy
This change adds the ability to specify the pool balancing strategy to
use when processing queued jobs. Before this change, GARM would round-robin
through all pools that matched the set of tags requested by queued jobs.
When round-robin (default) is used for an entity (repo, org or enterprise)
and you have 2 pools defined for that entity with a common set of tags that
match 10 jobs (for example), then those jobs would trigger the creation of
a new runner in each of the two pools in turn. Job 1 would go to pool 1,
job 2 would go to pool 2, job 3 to pool 1, job 4 to pool 2 and so on.
When "stack" is used, those same 10 jobs would trigger the creation of a
new runner in the pool with the highest priority, every time.
In both cases, if a pool is full, the next one would be tried automatically.
For the stack case, this would mean that if pool 2 had a priority of 10 and
pool 1 would have a priority of 5, pool 2 would be saturated first, then
pool 1.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-14 20:04:34 +00:00
|
|
|
CredentialsName string `json:"credentials_name"`
|
|
|
|
|
WebhookSecret string `json:"webhook_secret"`
|
|
|
|
|
PoolBalancerType PoolBalancerType `json:"pool_balancer_type"`
|
2022-04-29 14:18:22 +00:00
|
|
|
}
|
2022-05-03 19:49:14 +00:00
|
|
|
|
|
|
|
|
type InstanceUpdateMessage struct {
|
2023-07-21 15:30:22 +00:00
|
|
|
Status RunnerStatus `json:"status"`
|
|
|
|
|
Message string `json:"message"`
|
2024-01-04 15:23:43 +00:00
|
|
|
AgentID *int64 `json:"agent_id,omitempty"`
|
2022-05-03 19:49:14 +00:00
|
|
|
}
|
2024-04-15 08:32:19 +00:00
|
|
|
|
|
|
|
|
type CreateGithubEndpointParams struct {
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
APIBaseURL string `json:"api_base_url"`
|
|
|
|
|
UploadBaseURL string `json:"upload_base_url"`
|
|
|
|
|
BaseURL string `json:"base_url"`
|
|
|
|
|
CACertBundle []byte `json:"ca_cert_bundle"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UpdateGithubEndpointParams struct {
|
|
|
|
|
Description *string `json:"description"`
|
|
|
|
|
APIBaseURL *string `json:"api_base_url"`
|
|
|
|
|
UploadBaseURL *string `json:"upload_base_url"`
|
|
|
|
|
BaseURL *string `json:"base_url"`
|
|
|
|
|
CACertBundle []byte `json:"ca_cert_bundle"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GithubPAT struct {
|
|
|
|
|
OAuth2Token string `json:"oauth2_token"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GithubApp struct {
|
|
|
|
|
AppID int64 `json:"app_id"`
|
|
|
|
|
InstallationID int64 `json:"installation_id"`
|
|
|
|
|
PrivateKeyBytes []byte `json:"private_key_bytes"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g GithubApp) Validate() error {
|
|
|
|
|
if g.AppID == 0 {
|
|
|
|
|
return errors.NewBadRequestError("missing app_id")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if g.InstallationID == 0 {
|
|
|
|
|
return errors.NewBadRequestError("missing installation_id")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(g.PrivateKeyBytes) == 0 {
|
|
|
|
|
return errors.NewBadRequestError("missing private_key_bytes")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
block, _ := pem.Decode(g.PrivateKeyBytes)
|
|
|
|
|
// Parse the private key as PCKS1
|
|
|
|
|
_, err := x509.ParsePKCS1PrivateKey(block.Bytes)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("parsing private_key_path: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CreateGithubCredentialsParams struct {
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
AuthType GithubAuthType `json:"auth_type"`
|
|
|
|
|
PAT GithubPAT `json:"pat,omitempty"`
|
|
|
|
|
App GithubApp `json:"app,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UpdateGithubCredentialsParams struct {
|
|
|
|
|
Name *string `json:"name,omitempty"`
|
|
|
|
|
Description *string `json:"description,omitempty"`
|
|
|
|
|
PAT *GithubPAT `json:"pat,omitempty"`
|
|
|
|
|
App *GithubApp `json:"app,omitempty"`
|
|
|
|
|
}
|