Documentation
¶
Overview ¶
Package webhook is the base webhook server for a github app's events specific to queued workflow jobs.
Index ¶
- type CloudBuild
- type CloudBuildClient
- type Config
- type CreateSignerRes
- type FileReader
- type KeyManagement
- type KeyManagementClient
- type MockCloudBuildClient
- type MockFileReader
- type MockKMSClient
- type OSFileReader
- type ReadFileResErr
- type Server
- func (s *Server) Close() error
- func (s *Server) GenerateOrgJITConfig(ctx context.Context, installationID int64, org, runnerName string) (*github.JITRunnerConfig, *apiResponse)
- func (s *Server) GenerateRepoJITConfig(ctx context.Context, installationID int64, org, repo, runnerName string) (*github.JITRunnerConfig, *apiResponse)
- func (s *Server) Routes(ctx context.Context) http.Handler
- type WebhookClientOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudBuild ¶
type CloudBuild struct {
// contains filtered or unexported fields
}
CloudBuild provides a client and dataset identifiers.
func NewCloudBuild ¶
func NewCloudBuild(ctx context.Context, opts ...option.ClientOption) (*CloudBuild, error)
NewCloudBuild creates a new instance of a CloudBuild client.
func (*CloudBuild) Close ¶
func (cb *CloudBuild) Close() error
Close releases any resources held by the CloudBuild client.
func (*CloudBuild) CreateBuild ¶
func (cb *CloudBuild) CreateBuild(ctx context.Context, req *cloudbuildpb.CreateBuildRequest, opts ...gax.CallOption) error
type CloudBuildClient ¶
type CloudBuildClient interface { Close() error CreateBuild(ctx context.Context, req *cloudbuildpb.CreateBuildRequest, opts ...gax.CallOption) error }
CloudBuildClient adheres to the interaction the webhook service has with a subset of Cloud Build APIs.
type Config ¶
type Config struct { Environment string `env:"ENVIRONMENT,default=production"` GitHubAPIBaseURL string `env:"GITHUB_API_BASE_URL,default=https://api.github.com"` GitHubAppID string `env:"GITHUB_APP_ID,required"` GitHubWebhookKeyMountPath string `env:"WEBHOOK_KEY_MOUNT_PATH,required"` GitHubWebhookKeyName string `env:"WEBHOOK_KEY_NAME,required"` KMSAppPrivateKeyID string `env:"KMS_APP_PRIVATE_KEY_ID,required"` Port string `env:"PORT,default=8080"` RunnerImageName string `env:"RUNNER_IMAGE_NAME,default=default-runner"` RunnerImageTag string `env:"RUNNER_IMAGE_TAG,default=latest"` RunnerLocation string `env:"RUNNER_LOCATION,required"` RunnerProjectID string `env:"RUNNER_PROJECT_ID,required"` RunnerRepositoryID string `env:"RUNNER_REPOSITORY_ID,required"` RunnerServiceAccount string `env:"RUNNER_SERVICE_ACCOUNT,required"` RunnerWorkerPoolID string `env:"RUNNER_WORKER_POOL_ID"` }
Config defines the set of environment variables required for running the webhook service.
func (*Config) ToFlags ¶
ToFlags binds the config to the cli.FlagSet and returns it.
type CreateSignerRes ¶
type FileReader ¶
FileReader can read a file and return the content.
type KeyManagement ¶
type KeyManagement struct {
// contains filtered or unexported fields
}
KeyManagement provides a client and dataset identifiers.
func NewKeyManagement ¶
func NewKeyManagement(ctx context.Context, opts ...option.ClientOption) (*KeyManagement, error)
NewKeyManagementClient creates a new instance of a KMS client.
func (*KeyManagement) Close ¶
func (km *KeyManagement) Close() error
Close releases any resources held by the KeyManagement client.
func (*KeyManagement) CreateSigner ¶
func (km *KeyManagement) CreateSigner(ctx context.Context, kmsAppPrivateKeyID string) (*gcpkms.Signer, error)
CreateSigner leverages the gcpkms package to create a signer.
type KeyManagementClient ¶
type KeyManagementClient interface { Close() error CreateSigner(ctx context.Context, kmsAppPrivateKeyID string) (*gcpkms.Signer, error) }
KeyManagementClient adheres to the interaction the webhook service has with a subset of Key Management APIs.
type MockCloudBuildClient ¶
type MockCloudBuildClient struct {
// contains filtered or unexported fields
}
func (*MockCloudBuildClient) Close ¶
func (m *MockCloudBuildClient) Close() error
func (*MockCloudBuildClient) CreateBuild ¶
func (m *MockCloudBuildClient) CreateBuild(ctx context.Context, req *cloudbuildpb.CreateBuildRequest, opts ...gax.CallOption) error
type MockFileReader ¶
type MockFileReader struct {
ReadFileMock *ReadFileResErr
}
type MockKMSClient ¶
type MockKMSClient struct {
CreateSignerMock *CreateSignerRes
}
func (*MockKMSClient) Close ¶
func (m *MockKMSClient) Close() error
func (*MockKMSClient) CreateSigner ¶
type OSFileReader ¶
type OSFileReader struct{}
OSFileReader implements FileReader using the os package.
type ReadFileResErr ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides the server implementation.
func NewServer ¶
func NewServer(ctx context.Context, h *renderer.Renderer, cfg *Config, wco *WebhookClientOptions) (*Server, error)
NewServer creates a new HTTP server implementation that will handle receiving webhook payloads.
func (*Server) GenerateOrgJITConfig ¶
func (*Server) GenerateRepoJITConfig ¶
type WebhookClientOptions ¶
type WebhookClientOptions struct { CloudBuildClientOpts []option.ClientOption KeyManagementClientOpts []option.ClientOption OSFileReaderOverride FileReader CloudBuildClientOverride CloudBuildClient KeyManagementClientOverride KeyManagementClient }
WebhookClientOptions encapsulate client config options as well as dependency implementation overrides.