nuonrunner

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 15 Imported by: 0

README

nuon-runner-go

The SDK that powers the Nuon runner.

Overview

The Nuon runner is deployed in each install, and powers everything from updates, releases and rollouts to day 2 monitoring.

Full documentation is available at https://runner.nuon.co/docs/index.html.

All endpoints in the API follow REST conventions and standard HTTP methods. You can find the OpenAPI Spec here

Installation

In your project, you can install the package directly using go get:

go get github.com/nuonco/nuon-runner-go

In your code, add the following import:

import nuonrunner "github.com/nuonco/nuon-runner-go"

Create a client

Create a new api client, using an API key set in the environment.

apiURL := "https://runner.nuon.co"
apiToken := os.Getenv("NUON_API_TOKEN")
runnerID := os.Getenv("NUON_RUNNER_ID")

apiClient, err := client.New(s.v,
  client.WithAuthToken(apiToken),
  client.WithURL(apiURL),
  client.WithRunnerID(orgID),
)
if err != nil {
  return fmt.Errorf("unable to get api client: %w", err)
}

Example usage

List current available jobs
jobs, err := apiClient.AvailableJobs(ctx)

Contributing

Please submit a PR, and if you would like help, contact us on our community slack.

You can generate mock code using:

$ go generate ./...

You can also change the open api spec to generate against, by setting the API_URL field to a different value:

$ NUON_API_URL=http://localhost:8081 go generate ./...

Documentation

Overview

Package nuonrunner is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBadRequest

func IsBadRequest(err error) bool

func IsForbidden

func IsForbidden(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsServerError

func IsServerError(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

func New

func New(opts ...clientOption) (*client, error)

func ToUserError

func ToUserError(inputErr error) (*models.StderrErrResponse, bool)

ToUserError returns the error as a user error if possible

func WithAuthToken

func WithAuthToken(token string) clientOption

WithAuthToken specifies the auth token to use

func WithRunnerID

func WithRunnerID(runnerID string) clientOption

WithRunnerID specifies the runner id to use

func WithURL

func WithURL(url string) clientOption

WithURL specifies the url to use

func WithValidator

func WithValidator(v *validator.Validate) clientOption

WithValidator specifies a validator to use

Types

type Client

type Client interface {
	SetRunnerID(runnerID string)

	GetSettings(ctx context.Context) (*models.AppRunnerGroupSettings, error)

	// heartbeat and health checks
	CreateHeartBeat(ctx context.Context, req *models.ServiceCreateRunnerHeartBeatRequest) (*models.AppRunnerHeartBeat, error)
	CreateHealthCheck(ctx context.Context, req *models.ServiceCreateRunnerHealthCheckRequest) (*models.AppRunnerHealthCheck, error)

	// jobs
	GetJobs(ctx context.Context, grp models.AppRunnerJobGroup, status models.AppRunnerJobStatus, limit *int64) ([]*models.AppRunnerJob, error)
	GetJob(ctx context.Context, jobID string) (*models.AppRunnerJob, error)
	GetJobPlanJSON(ctx context.Context, jobID string) (string, error)

	// job executions
	GetJobExecutions(ctx context.Context, jobID string) ([]*models.AppRunnerJobExecution, error)
	CreateJobExecution(ctx context.Context, jobID string, req *models.ServiceCreateRunnerJobExecutionRequest) (*models.AppRunnerJobExecution, error)
	UpdateJobExecution(ctx context.Context, jobID, jobExecutionID string, req *models.ServiceUpdateRunnerJobExecutionRequest) (*models.AppRunnerJobExecution, error)
	CreateJobExecutionResult(ctx context.Context, jobID, jobExecutionID string, req *models.ServiceCreateRunnerJobExecutionResultRequest) (*models.AppRunnerJobExecutionResult, error)

	// otel operations
	WriteOTELLogs(ctx context.Context, req interface{}) error
	WriteOTELTraces(ctx context.Context, req interface{}) error
	WriteOTELMetrics(ctx context.Context, req interface{}) error
}

type MockClient

type MockClient struct {
	// contains filtered or unexported fields
}

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) CreateHealthCheck

CreateHealthCheck mocks base method.

func (*MockClient) CreateHeartBeat

CreateHeartBeat mocks base method.

func (*MockClient) CreateJobExecution

CreateJobExecution mocks base method.

func (*MockClient) CreateJobExecutionResult

func (m *MockClient) CreateJobExecutionResult(ctx context.Context, jobID, jobExecutionID string, req *models.ServiceCreateRunnerJobExecutionResultRequest) (*models.AppRunnerJobExecutionResult, error)

CreateJobExecutionResult mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) GetJob

func (m *MockClient) GetJob(ctx context.Context, jobID string) (*models.AppRunnerJob, error)

GetJob mocks base method.

func (*MockClient) GetJobExecutions

func (m *MockClient) GetJobExecutions(ctx context.Context, jobID string) ([]*models.AppRunnerJobExecution, error)

GetJobExecutions mocks base method.

func (*MockClient) GetJobPlanJSON added in v0.0.1

func (m *MockClient) GetJobPlanJSON(ctx context.Context, jobID string) (string, error)

GetJobPlanJSON mocks base method.

func (*MockClient) GetJobs

GetJobs mocks base method.

func (*MockClient) GetSettings

func (m *MockClient) GetSettings(ctx context.Context) (*models.AppRunnerGroupSettings, error)

GetSettings mocks base method.

func (*MockClient) SetRunnerID

func (m *MockClient) SetRunnerID(runnerID string)

SetRunnerID mocks base method.

func (*MockClient) UpdateJobExecution

func (m *MockClient) UpdateJobExecution(ctx context.Context, jobID, jobExecutionID string, req *models.ServiceUpdateRunnerJobExecutionRequest) (*models.AppRunnerJobExecution, error)

UpdateJobExecution mocks base method.

func (*MockClient) WriteOTELLogs

func (m *MockClient) WriteOTELLogs(ctx context.Context, req interface{}) error

WriteOTELLogs mocks base method.

func (*MockClient) WriteOTELMetrics

func (m *MockClient) WriteOTELMetrics(ctx context.Context, req interface{}) error

WriteOTELMetrics mocks base method.

func (*MockClient) WriteOTELTraces

func (m *MockClient) WriteOTELTraces(ctx context.Context, req interface{}) error

WriteOTELTraces mocks base method.

type MockClientMockRecorder

type MockClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) CreateHealthCheck

func (mr *MockClientMockRecorder) CreateHealthCheck(ctx, req interface{}) *gomock.Call

CreateHealthCheck indicates an expected call of CreateHealthCheck.

func (*MockClientMockRecorder) CreateHeartBeat

func (mr *MockClientMockRecorder) CreateHeartBeat(ctx, req interface{}) *gomock.Call

CreateHeartBeat indicates an expected call of CreateHeartBeat.

func (*MockClientMockRecorder) CreateJobExecution

func (mr *MockClientMockRecorder) CreateJobExecution(ctx, jobID, req interface{}) *gomock.Call

CreateJobExecution indicates an expected call of CreateJobExecution.

func (*MockClientMockRecorder) CreateJobExecutionResult

func (mr *MockClientMockRecorder) CreateJobExecutionResult(ctx, jobID, jobExecutionID, req interface{}) *gomock.Call

CreateJobExecutionResult indicates an expected call of CreateJobExecutionResult.

func (*MockClientMockRecorder) GetJob

func (mr *MockClientMockRecorder) GetJob(ctx, jobID interface{}) *gomock.Call

GetJob indicates an expected call of GetJob.

func (*MockClientMockRecorder) GetJobExecutions

func (mr *MockClientMockRecorder) GetJobExecutions(ctx, jobID interface{}) *gomock.Call

GetJobExecutions indicates an expected call of GetJobExecutions.

func (*MockClientMockRecorder) GetJobPlanJSON added in v0.0.1

func (mr *MockClientMockRecorder) GetJobPlanJSON(ctx, jobID interface{}) *gomock.Call

GetJobPlanJSON indicates an expected call of GetJobPlanJSON.

func (*MockClientMockRecorder) GetJobs

func (mr *MockClientMockRecorder) GetJobs(ctx, grp, status, limit interface{}) *gomock.Call

GetJobs indicates an expected call of GetJobs.

func (*MockClientMockRecorder) GetSettings

func (mr *MockClientMockRecorder) GetSettings(ctx interface{}) *gomock.Call

GetSettings indicates an expected call of GetSettings.

func (*MockClientMockRecorder) SetRunnerID

func (mr *MockClientMockRecorder) SetRunnerID(runnerID interface{}) *gomock.Call

SetRunnerID indicates an expected call of SetRunnerID.

func (*MockClientMockRecorder) UpdateJobExecution

func (mr *MockClientMockRecorder) UpdateJobExecution(ctx, jobID, jobExecutionID, req interface{}) *gomock.Call

UpdateJobExecution indicates an expected call of UpdateJobExecution.

func (*MockClientMockRecorder) WriteOTELLogs

func (mr *MockClientMockRecorder) WriteOTELLogs(ctx, req interface{}) *gomock.Call

WriteOTELLogs indicates an expected call of WriteOTELLogs.

func (*MockClientMockRecorder) WriteOTELMetrics

func (mr *MockClientMockRecorder) WriteOTELMetrics(ctx, req interface{}) *gomock.Call

WriteOTELMetrics indicates an expected call of WriteOTELMetrics.

func (*MockClientMockRecorder) WriteOTELTraces

func (mr *MockClientMockRecorder) WriteOTELTraces(ctx, req interface{}) *gomock.Call

WriteOTELTraces indicates an expected call of WriteOTELTraces.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL