harness

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package harness provides a Harness http client.

Index

Constants

View Source
const (
	// DefaultSecretType defines the default secret type.
	DefaultSecretType = "SecretText"

	// DefaultSecretType defines the default secret value type.
	DefaultSecretValueType = "Inline"

	// DefaultSecretManager defines the default secret manager.
	DefaultSecretManager = "harnessSecretManager"
)
View Source
const (
	ConnectorTypeGithub = "Github"
	ConnectorTypeGitlab = "Gitlab"
)

Variables

This section is empty.

Functions

func WaitHarnessSecretManager

func WaitHarnessSecretManager(client Client, org, project string) error

WaitHarnessSecretManager blocks until the harness secret manager is created for the project.

func WaitHarnessSecretManagerOrg

func WaitHarnessSecretManagerOrg(client Client, org string) error

WaitHarnessSecretManagerOrg blocks until the harness secret manager is created for the organization.

Types

type Client

type Client interface {
	// FindOrg returns an organization by identifier.
	FindOrg(id string) (*Org, error)

	// FindProject returns a project by organization and
	// identifier.
	FindProject(org, id string) (*Project, error)

	// FindPipeline returns a pipeline by organization,
	// project and identifer.
	FindPipeline(org, project, id string) (*Pipeline, error)

	// FindSecret returns a secret by organization, project
	// and identifer.
	FindSecret(org, project, id string) (*Secret, error)

	// FindSecretOrg returns a secret by organization and
	// identifer.
	FindSecretOrg(org, id string) (*Secret, error)

	// FindConnector returns a connector by organization,
	// project and identifer.
	FindConnector(org, project, id string) (*Connector, error)

	// FindConnectorOrg returns a connector by organization
	// and identifer.
	FindConnectorOrg(org, id string) (*Connector, error)

	// CreateOrg creates an organization.
	CreateOrg(org *Org) error

	// CreateProject creates a project.
	CreateProject(project *Project) error

	// CreateSecret creates a secret.
	CreateSecret(secret *Secret) error

	// CreateSecret creates an organization secret.
	CreateSecretOrg(secret *Secret) error

	// CreateConnector creates a connector.
	CreateConnector(connector *Connector) error

	// CreateConnector creates an organization connector.
	CreateConnectorOrg(connector *Connector) error

	// CreatePipeline creates a pipeline for the
	// organization and pipeline identifier, with the
	// given identifier and name.
	CreatePipeline(org, project string, pipeline []byte) error

	// CreateRepository creates a repository.
	CreateRepository(org, project string, repo *RepositoryCreateRequest) (*Repository, error)
}

Client is used to communicate with the Harness server.

func New

func New(account, token string, opts ...Option) Client

New returns a new Client.

type Connector

type Connector struct {
	Name              string `json:"name"`
	Identifier        string `json:"identifier"`
	Orgidentifier     string `json:"orgIdentifier,omitempty"`
	Projectidentifier string `json:"projectIdentifier,omitempty"`
	Version           int    `json:"version,omitempty"`
	Numofstages       int    `json:"numOfStages,omitempty"`
	Createdat         int64  `json:"createdAt,omitempty"`
	Lastupdatedat     int64  `json:"lastUpdatedAt,omitempty"`

	Type string      `json:"type"` // Gitlab, Github
	Spec interface{} `json:"spec"`
}

Connector defines a connector.

type ConnectorDocker

type ConnectorDocker struct {
	ExecuteOnDelegate bool      `json:"executeOnDelegate"`
	DockerRegistryURL string    `json:"dockerRegistryUrl"`
	ProviderType      string    `json:"providerType"`
	Authentication    *Resource `json:"auth"`
}

type ConnectorGithub

type ConnectorGithub struct {
	Executeondelegate bool      `json:"executeOnDelegate"`
	Type              string    `json:"type"` // Account
	URL               string    `json:"url"`
	Validationrepo    string    `json:"validationRepo,omitempty"`
	Authentication    *Resource `json:"authentication"`
	Apiaccess         *Resource `json:"apiAccess"`
}

ConnectorGithub defines a Github connector.

type ConnectorGitlab

type ConnectorGitlab struct {
	Executeondelegate bool      `json:"executeOnDelegate"`
	Type              string    `json:"type"` // Account
	URL               string    `json:"url"`
	Validationrepo    string    `json:"validationRepo,omitempty"`
	Authentication    *Resource `json:"authentication"`
	Apiaccess         *Resource `json:"apiAccess"`
}

ConnectorGitlab defines a Gitlab connector.

type ConnectorToken

type ConnectorToken struct {
	Username string `json:"username,omitempty"`
	Tokenref string `json:"tokenRef,omitempty"`
}

ConnectorToken defines connector credentials.

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

Error represents an API error response.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message.

type Option

type Option func(*client)

Option configures a Digital Ocean provider option.

func WithAddress

func WithAddress(address string) Option

WithAddress returns an option to set the base address.

func WithTracing

func WithTracing(tracing bool) Option

WithTracing returns an option to enable tracing.

type Org

type Org struct {
	ID   string `json:"identifier"`
	Name string `json:"name"`
	Desc string `json:"description"`
}

Org defines an organization.

type Pipeline

type Pipeline struct {
	Name          string `json:"name"`
	Identifier    string `json:"identifier"`
	Version       int    `json:"version"`
	Numofstages   int    `json:"numOfStages"`
	Createdat     int64  `json:"createdAt"`
	Lastupdatedat int64  `json:"lastUpdatedAt"`
}

Pipeline defines a pipeline.

type Project

type Project struct {
	Orgidentifier string   `json:"orgIdentifier"`
	Identifier    string   `json:"identifier"`
	Name          string   `json:"name"`
	Color         string   `json:"color,omitempty"`
	Modules       []string `json:"modules,omitempty"`
	Description   string   `json:"description,omitempty"`
}

Project defines a project.

type Repository

type Repository struct {
	UID           string `json:"uid"`
	ParentID      int64  `json:"parent_id"`
	Description   string `json:"description"`
	IsPublic      bool   `json:"is_public"`
	DefaultBranch string `json:"default_branch"`
	GitURL        string `json:"git_url"`
}

Repository defines a resository.

type RepositoryCreateRequest

type RepositoryCreateRequest struct {
	UID           string `json:"uid"`
	DefaultBranch string `json:"default_branch"`
	Description   string `json:"description"`
	IsPublic      bool   `json:"is_public"`
}

RepositoryCreateRequest defines a repo creation request.

type Resource

type Resource struct {
	Type string      `json:"type"`
	Spec interface{} `json:"spec"`
}

Resource defines a base resource.

type Secret

type Secret struct {
	Name              string      `json:"name"`
	Identifier        string      `json:"identifier"`
	Orgidentifier     string      `json:"orgIdentifier,omitempty"`
	Projectidentifier string      `json:"projectIdentifier,omitempty"`
	Description       string      `json:"description,omitempty"`
	Type              string      `json:"type"` // SecretText
	Spec              *SecretText `json:"spec"`
}

type SecretText

type SecretText struct {
	Value   *string `json:"value"`
	Type    string  `json:"valueType"`               // Inline
	Manager string  `json:"secretManagerIdentifier"` // harnessSecretManager
}

Jump to

Keyboard shortcuts

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