Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type Client interface {
GetRunnerGroup(ctx context.Context, id string) (*RunnerGroup, error)
GetRunnerServiceAccount(ctx context.Context, runnerID string) (*RunnerServiceAccount, error)
GetRunnerServiceAccountToken(ctx context.Context, runnerID string, dur time.Duration, invalidate bool) (string, error)

CreateRunnerInGroup(ctx context.Context, runnerGroupID string, platform string) (*CreateRunnerInGroupResponse, error)
TaintRunner(ctx context.Context, runnerID string) error
UntaintRunner(ctx context.Context, runnerID string) error
}

var _ Client = (*client)(nil)
Expand Down
46 changes: 46 additions & 0 deletions pkg/api/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type Runner struct {
RunnerGroupID string `json:"runner_group_id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Platform string `json:"platform"`
Tainted bool `json:"tainted"`
}

func (c *client) ListRunners(ctx context.Context, typ string) ([]Runner, error) {
Expand Down Expand Up @@ -122,6 +124,50 @@ func (c *client) GetRunnerGroup(ctx context.Context, id string) (*RunnerGroup, e
return &resp, nil
}

type CreateRunnerInGroupRequest struct {
Platform string `json:"platform"`
}

type CreateRunnerInGroupResponse struct {
Runner Runner `json:"runner"`
Token string `json:"token"`
}

func (c *client) CreateRunnerInGroup(ctx context.Context, runnerGroupID string, platform string) (*CreateRunnerInGroupResponse, error) {
endpoint := fmt.Sprintf("/v1/runner-groups/%s/runners", runnerGroupID)
byts, err := c.execPostRequest(ctx, endpoint, CreateRunnerInGroupRequest{
Platform: platform,
})
if err != nil {
return nil, fmt.Errorf("unable to create runner in group: %w", err)
}

var resp CreateRunnerInGroupResponse
if err := json.Unmarshal(byts, &resp); err != nil {
return nil, fmt.Errorf("unable to parse response: %w", err)
}

return &resp, nil
}

func (c *client) TaintRunner(ctx context.Context, runnerID string) error {
endpoint := fmt.Sprintf("/v1/runners/%s/taint", runnerID)
_, err := c.execPostRequest(ctx, endpoint, map[string]interface{}{})
if err != nil {
return fmt.Errorf("unable to taint runner: %w", err)
}
return nil
}

func (c *client) UntaintRunner(ctx context.Context, runnerID string) error {
endpoint := fmt.Sprintf("/v1/runners/%s/untaint", runnerID)
_, err := c.execPostRequest(ctx, endpoint, map[string]interface{}{})
if err != nil {
return fmt.Errorf("unable to untaint runner: %w", err)
}
return nil
}

func (c *client) RestartRunner(ctx context.Context, runnerID string) error {
endpoint := fmt.Sprintf("/v1/runners/%s/restart", runnerID)
byts, err := c.execPostRequest(ctx, endpoint, map[string]interface{}{})
Expand Down
7 changes: 7 additions & 0 deletions sdks/nuon-go/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ type Client interface {
// runner job plan
GetRunnerJobPlan(ctx context.Context, runnerJobID string) (string, error)

// install runner groups
GetInstallRunnerGroup(ctx context.Context, installID string) (*models.AppRunnerGroup, error)
GetRunnerGroupLeader(ctx context.Context, runnerGroupID string) (*models.AppRunner, error)
UpdateRunnerGroupLeader(ctx context.Context, runnerGroupID string, runnerID string) error
TaintRunner(ctx context.Context, runnerID string) (*models.AppRunner, error)
UntaintRunner(ctx context.Context, runnerID string) (*models.AppRunner, error)

// install stacks
GetInstallStack(ctx context.Context, installID string) (*models.AppInstallStack, error)

Expand Down
151 changes: 151 additions & 0 deletions sdks/nuon-go/client/operations/get_runner_group_leader_parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading