client

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: BSD-3-Clause Imports: 9 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CreateRepositoryRetryAttempts is the number of times to retry creating a repository
	CreateRepositoryRetryAttempts uint = 3

	// CreateRepositoryRetryDelay is the delay between retry attempts
	CreateRepositoryRetryDelay = 300 * time.Millisecond
)

Functions

func ErrorBatchRequest

func ErrorBatchRequest(request string, ids []string, projectId string, err error) error

func ErrorProviderNotSupported

func ErrorProviderNotSupported(provider string) error

Types

type CanBeCreated

type CanBeCreated interface {
	Create(c *Client) error
}

type Client

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

func New

func New(ctx context.Context, options ...http.Option) (*Client, error)

New returns a new Client based on the options provided and an error

func (*Client) Create

func (c *Client) Create(object CanBeCreated) error

Create creates the given CanBeCreated object with the current client

func (*Client) CreateRepository

func (c *Client) CreateRepository(name string, description string, private bool) (id string, err error)

CreateRepository creates a new repository on the git provider. Returns the repository id and an error

func (*Client) GetProjectById

func (c *Client) GetProjectById(projectId string) (*Project, error)

GetProjectById returns the project with the given id and an error Note: The repository field is not populated

func (*Client) GetProjectByIdWithCors

func (c *Client) GetProjectByIdWithCors(projectId string) (*ProjectReturnWithCors, error)

GetProjectByIdWithCors returns the project with cors information with the given id and an error

func (*Client) GetRepositoryById

func (c *Client) GetRepositoryById(repoId string) (common.Repository, error)

GetRepositoryById returns a common Repository based on the id and an error

func (*Client) GetRepositoryByName

func (c *Client) GetRepositoryByName(fullName string) (common.Repository, error)

GetRepositoryByName returns a common Repository based on the name and an error

func (*Client) Git

func (c *Client) Git() common.Client

Git returns a git client based on the current git provider Currently only github is supported

func (*Client) ListRepositories

func (c *Client) ListRepositories() ([]common.Repository, error)

ListRepositories returns a list of common Repositories and an error

func (*Client) Projects

func (c *Client) Projects() ([]*Project, error)

Projects returns a list of projects and an error

func (*Client) RegisterDomain

func (c *Client) RegisterDomain(fqdn, projectId string) (response DomainResponse, err error)

RegisterDomain returns information for creating a CNAME record

func (*Client) RegisterRepository

func (c *Client) RegisterRepository(repoId string) error

RegisterRepository registers a git repository with the auth server

func (*Client) UnregisterRepository

func (c *Client) UnregisterRepository(repoId string) error

UnregisterRepository un-registers a git repository from the auth server

func (*Client) User

func (c *Client) User() *User

type Cors

type Cors struct {
	Url   string `json:"url"`
	Token string `json:"token"`
}

type CreateProjectData

type CreateProjectData struct {
	Config Repository `json:"config"`
	Code   Repository `json:"code"`
}

CreateProjectData is the data that is sent to the server to create a new project The repositories only need an id that is registered with the server

type Device

type Device struct {
	Project     *Project
	Id          string            `json:"id"`
	Description string            `json:"description"`
	Enabled     bool              `json:"enabled"`
	Name        string            `json:"name"`
	PrivateKey  string            `json:"privateKey"`
	PublicKey   string            `json:"publicKey"`
	Tags        []string          `json:"tags"`
	Type        string            `json:"type"`
	Env         map[string]string `json:"env"`
}

Device is the data that is sent to/from the server when getting or updating a device Note: the client and id of the Project are used in calls to the server

func (*Device) Create

func (d *Device) Create(c *Client) error

Create creates a new device for the project

type DomainResponse

type DomainResponse struct {
	Token string `json:"token"`
	Entry string `json:"entry"`
	Type  string `json:"type"`
}

type Project

type Project struct {
	Id       string            `json:"id"`
	Name     string            `json:"name"`
	RepoList *RawRepoDataOuter `json:"Repositories"`
	// contains filtered or unexported fields
}

Project is data which is returned from the server when getting a project Note: filling the RepoList field is a separate call

func (Project) Client

func (o Project) Client() *Client

func (*Project) Config

func (p *Project) Config() (*common.ProjectConfig, error)

Config returns the project configuration and an error The configuration is a "config.yaml" file in the root of the repository

func (*Project) Create

func (p *Project) Create(c *Client, configRepoId string, codeRepoId string) error

Create creates a new project with the registered config and code repository ids

func (*Project) Delete

func (p *Project) Delete() (response deleteResponse, err error)

Delete deletes the project and returns an error

func (*Project) Repositories

func (p *Project) Repositories() (*RawRepoDataOuter, error)

Repositories will populate then return the repositories field and an error

type ProjectReturn

type ProjectReturn struct {
	Project *Project `json:"project"`
}

ProjectReturn is the data that is returned from the server when creating or getting a project

type ProjectReturnWithCors

type ProjectReturnWithCors struct {
	Project *ProjectWithCors `json:"project"`
}

ProjectWithCors is the same as ProjectReturn but includes Cors

type ProjectWithCors

type ProjectWithCors struct {
	Id       string            `json:"id"`
	Name     string            `json:"name"`
	RepoList *RawRepoDataOuter `json:"Repositories"`
	Cors     Cors              `json:"cors"`
	// contains filtered or unexported fields
}

func (ProjectWithCors) Client

func (o ProjectWithCors) Client() *Client

type ProjectsReturn

type ProjectsReturn struct {
	Projects []*Project `json:"projects"`
}

ProjectsReturn is the data that is returned from the server when listing projects

type RawRepoData

type RawRepoData struct {
	Id       string `json:"id"` // Not exported by auth.taubyte, must use GetID()
	Name     string `json:"name"`
	Fullname string `json:"fullname"`
	Url      string `json:"url"`
}

RawRepoData is the data that is returned from the server when getting repositories of a project

type RawRepoDataOuter

type RawRepoDataOuter struct {
	Code          RawRepoData `json:"code"`
	Configuration RawRepoData `json:"configuration"`
	Provider      string      `json:"provider"`
	URL           string      `json:"url"`
}

RawRepoDataOuter is the data that is returned from the server when fetching repositories of a project

type Repository

type Repository struct {
	Provider string `json:"provider"`
	Id       string `json:"id"`
}

Repository is the data that is sent to the server to register a repository or for creating a project

type User

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

func (*User) Get

func (u *User) Get() (*UserData, error)

Get will fetch the user data from the server and return UserData and an error

type UserData

type UserData struct {
	Company string `json:"company"`
	Email   string `json:"email"`
	Login   string `json:"login"`
	Name    string `json:"name"`
}

UserData is the data that is returned from the server when getting user data

Directories

Path Synopsis
git

Jump to

Keyboard shortcuts

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