rest

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	KubernetesRunnerType = "kubernetes"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Name string `json:"name"`
	ID   string `json:"_id"`
}

type AgentState

type AgentState struct {
	Kind  string `json:"type"`
	Items any    `json:"items"`
}

type Annotation

type Annotation struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type ApplicationResources

type ApplicationResources struct {
	Name      string  `json:"name,omitempty"`
	HistoryId int64   `json:"historyId"`
	Revision  string  `json:"revision,omitempty"`
	Resources any     `json:"resources"`
	Context   *string `json:"context"`
}

type ArgoAPI

type ArgoAPI interface {
	CreateIntegration(integration IntegrationPayloadData) error
	DeleteIntegrationByName(name string) error
	GetIntegrationByName(name string) (*IntegrationPayload, error)
	GetIntegrations() ([]IntegrationPayload, error)
	HeartBeat(error string, version string, integration string) error
	SendResources(kind string, items any, amount int, integration string) error
	UpdateIntegration(name string, integration IntegrationPayloadData) error
}

type CFEnvironment

type CFEnvironment struct {
	Metadata struct {
		Name string `json:"name"`
	} `json:"metadata"`
	Spec struct {
		Type        string `json:"type"`
		Application string `json:"application"`
	} `json:"spec"`
}

type Cluster

type Cluster struct {
	Auth struct {
		Bearer string
	} `json:"auth"`
	Ca  string `json:"ca"`
	Url string `json:"url"`
}

type ClusterAPI

type ClusterAPI interface {
	GetAccountClusters() ([]ClusterMinified, error)
	GetClusterCredentialsByAccountId(selector string) (*Cluster, error)
}

type ClusterMinified

type ClusterMinified struct {
	Cluster struct {
		Name string `json:"name"`
	} `json:"cluster"`
	BehindFirewall bool   `json:"behindFirewall"`
	Selector       string `json:"selector"`
	Provider       string `json:"provider"`
}

type CodefreshEvent

type CodefreshEvent struct {
	Event string            `json:"event"`
	Props map[string]string `json:"props"`
}

type Commit

type Commit struct {
	Time    *time.Time `json:"time,omitempty"`
	Message *string    `json:"message"`
	Avatar  *string    `json:"avatar"`
}

type ContextAPI

type ContextAPI interface {
	GetDefaultGitContext() (*ContextPayload, error)
	GetGitContextByName(name string) (*ContextPayload, error)
	GetGitContexts() ([]ContextPayload, error)
}

type ContextPayload

type ContextPayload struct {
	Metadata struct {
		Name string `json:"name"`
	}
	Spec struct {
		Type string `json:"type"`
		Data struct {
			Auth struct {
				Type     string `json:"type"`
				Username string `json:"username"`
				Password string `json:"password"`
				ApiHost  string `json:"apiHost"`
				// for gitlab
				ApiURL         string `json:"apiURL"`
				ApiPathPrefix  string `json:"apiPathPrefix"`
				SshPrivateKey  string `json:"sshPrivateKey"`
				AppId          string `json:"appId"`
				InstallationId string `json:"installationId"`
				PrivateKey     string `json:"privateKey"`
			} `json:"auth"`
		} `json:"data"`
	} `json:"spec"`
}

type CreateResponse

type CreateResponse struct {
	Name string
}

type CreateRuntimeOptions

type CreateRuntimeOptions struct {
	Cluster            string
	Namespace          string
	HasAgent           bool
	StorageClass       string
	RunnerType         string
	DockerDaemonParams string
	NodeSelector       map[string]string
	Annotations        map[string]string
}

type DockerDaemonScheduler

type DockerDaemonScheduler struct {
	Cluster struct {
		ClusterProvider struct {
			AccountID string `json:"accountId"`
			Selector  string `json:"selector"`
		} `json:"clusterProvider"`
		Namespace string `json:"namespace"`
	} `json:"cluster"`
	UserAccess bool `json:"userAccess"`
}

type Environment

type Environment struct {
	Gitops       Gitops                `json:"gitops"`
	FinishedAt   string                `json:"finishedAt"`
	HealthStatus string                `json:"healthStatus"`
	SyncStatus   string                `json:"status"`
	HistoryId    int64                 `json:"historyId"`
	SyncRevision string                `json:"revision"`
	Name         string                `json:"name"`
	Activities   []EnvironmentActivity `json:"activities"`
	Resources    any                   `json:"resources"`
	RepoUrl      string                `json:"repoUrl"`
	Commit       Commit                `json:"commit"`
	SyncPolicy   SyncPolicy            `json:"syncPolicy"`
	Date         string                `json:"date"`
	ParentApp    string                `json:"parentApp"`
	Namespace    string                `json:"namespace"`
	Server       string                `json:"server"`
	Context      *string               `json:"context"`
}

type EnvironmentActivity

type EnvironmentActivity struct {
	Name         string                `json:"name"`
	TargetImages []string              `json:"targetImages"`
	Status       string                `json:"status"`
	LiveImages   []string              `json:"liveImages"`
	ReplicaSet   EnvironmentActivityRS `json:"replicaSet"`
}

type EnvironmentActivityRS

type EnvironmentActivityRS struct {
	From ReplicaState `json:"from"`
	To   ReplicaState `json:"to"`
}

type EnvironmentMetadata

type EnvironmentMetadata struct {
	Name string `json:"name"`
}

type EnvironmentPayload

type EnvironmentPayload struct {
	Version  string              `json:"version"`
	Metadata EnvironmentMetadata `json:"metadata"`
	Spec     EnvironmentSpec     `json:"spec"`
}

type EnvironmentSpec

type EnvironmentSpec struct {
	Type        string `json:"type"`
	Context     string `json:"context"`
	Project     string `json:"project"`
	Application string `json:"application"`
}

type GitContextsQs

type GitContextsQs struct {
	Type    []string `url:"type"`
	Decrypt string   `url:"decrypt"`
}

type Gitops

type Gitops struct {
	Comitters []GitopsUser `json:"comitters"`
	Prs       []Annotation `json:"prs"`
	Issues    []Annotation `json:"issues"`
}

type GitopsAPI

type GitopsAPI interface {
	CreateEnvironment(name string, project string, application string, integration string) error
	DeleteEnvironment(name string) error
	GetEnvironments() ([]CFEnvironment, error)
	SendApplicationResources(resources *ApplicationResources) error
	SendEnvironment(environment Environment) (map[string]any, error)
	SendEvent(name string, props map[string]string) error
}

type GitopsUser

type GitopsUser struct {
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
}

type Heartbeat

type Heartbeat struct {
	Error        string `json:"error"`
	AgentVersion string `json:"agentVersion"`
}

type IntegrationItem

type IntegrationItem struct {
	Amount int `json:"amount"`
}

type IntegrationPayload

type IntegrationPayload struct {
	Type string                 `json:"type"`
	Data IntegrationPayloadData `json:"data"`
}

type IntegrationPayloadData

type IntegrationPayloadData struct {
	Name          string          `json:"name"`
	Url           string          `json:"url"`
	Clusters      IntegrationItem `json:"clusters"`
	Applications  IntegrationItem `json:"applications"`
	Repositories  IntegrationItem `json:"repositories"`
	Username      *string         `json:"username"`
	Password      *string         `json:"password"`
	Token         *string         `json:"token"`
	ClusterName   *string         `json:"clusterName"`
	ServerVersion *string         `json:"serverVersion"`
	Provider      *string         `json:"provider"`
}

type Location

type Location struct {
	Type string `json:"type"`
	URL  string `json:"url"`
}

type MongoCFEnvWrapper

type MongoCFEnvWrapper struct {
	Docs []CFEnvironment `json:"docs"`
}

type Pipeline

type Pipeline struct {
	Metadata PipelineMetadata `json:"metadata"`
	Spec     PipelineSpec     `json:"spec"`
}

type PipelineAPI

type PipelineAPI interface {
	List(query map[string]string) ([]Pipeline, error)
	Run(string, *RunOptions) (string, error)
}

type PipelineMetadata

type PipelineMetadata struct {
	Name     string `json:"name"`
	IsPublic bool   `json:"isPublic"`
	Labels   struct {
		Tags []string `json:"tags"`
	} `json:"labels"`
	Deprecate struct {
		ApplicationPort string `json:"applicationPort"`
		RepoPipeline    bool   `json:"repoPipeline"`
	} `json:"deprecate"`
	OriginalYamlString string    `json:"originalYamlString"`
	AccountID          string    `json:"accountId"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
	Project            string    `json:"project"`
	ID                 string    `json:"id"`
}

type PipelineSpec

type PipelineSpec struct {
	Triggers []struct {
		Type     string   `json:"type"`
		Repo     string   `json:"repo"`
		Events   []string `json:"events"`
		Provider string   `json:"provider"`
		Context  string   `json:"context"`
	} `json:"triggers"`
	Contexts  []any `json:"contexts"`
	Variables []struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	} `json:"variables"`
	Steps  map[string]any `json:"steps"`
	Stages []any          `json:"stages"`
	Mode   string         `json:"mode"`
}

type Progress

type Progress struct {
	ID       string   `json:"id"`
	Status   string   `json:"status"`
	Location Location `json:"location"`
}

type ProgressAPI

type ProgressAPI interface {
	Get(string) (*Progress, error)
}

type ReplicaState

type ReplicaState struct {
	Current int64 `json:"current"`
	Desired int64 `json:"desired"`
}

type RestAPI

type RestAPI interface {
	Argo() ArgoAPI
	Cluster() ClusterAPI
	Context() ContextAPI
	Gitops() GitopsAPI
	Pipeline() PipelineAPI
	Progress() ProgressAPI
	RuntimeEnvironment() RuntimeEnvironmentAPI
	Token() TokenAPI
	User() UserAPI
	Workflow() WorkflowAPI
}

func NewRestClient

func NewRestClient(c *client.CfClient) RestAPI

type RunOptions

type RunOptions struct {
	Branch    string
	Variables map[string]string
}

type RuntimeEnvironment

type RuntimeEnvironment struct {
	Version               int                   `json:"version"`
	Metadata              RuntimeMetadata       `json:"metadata"`
	Extends               []string              `json:"extends"`
	Description           string                `json:"description"`
	AccountID             string                `json:"accountId"`
	RuntimeScheduler      RuntimeScheduler      `json:"runtimeScheduler"`
	DockerDaemonScheduler DockerDaemonScheduler `json:"dockerDaemonScheduler"`
	Status                struct {
		Message   string    `json:"message"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"status"`
}

type RuntimeEnvironmentAPI

type RuntimeEnvironmentAPI interface {
	Create(*CreateRuntimeOptions) (*RuntimeEnvironment, error)
	Default(string) (bool, error)
	Delete(string) (bool, error)
	Get(string) (*RuntimeEnvironment, error)
	List() ([]RuntimeEnvironment, error)
	SignCertificate(*SignCertificatesOptions) ([]byte, error)
	Validate(*ValidateRuntimeOptions) error
}

RuntimeEnvironmentAPI declers Codefresh runtime environment API

type RuntimeMetadata

type RuntimeMetadata struct {
	Agent        bool   `json:"agent"`
	Name         string `json:"name"`
	ChangedBy    string `json:"changedBy"`
	CreationTime string `json:"creationTime"`
}

type RuntimeScheduler

type RuntimeScheduler struct {
	Cluster struct {
		ClusterProvider struct {
			AccountID string `json:"accountId"`
			Selector  string `json:"selector"`
		} `json:"clusterProvider"`
		Namespace string `json:"namespace"`
	} `json:"cluster"`
	UserAccess bool `json:"userAccess"`
	Pvcs       struct {
		Dind struct {
			StorageClassName string `yaml:"storageClassName"`
		} `yaml:"dind"`
	} `yaml:"pvcs"`
}

type SignCertificatesOptions

type SignCertificatesOptions struct {
	AltName string
	CSR     string
}

type SyncPolicy

type SyncPolicy struct {
	AutoSync bool `json:"autoSync"`
}

type Token

type Token struct {
	ID          string    `json:"_id"`
	Name        string    `json:"name"`
	TokenPrefix string    `json:"tokenPrefix"`
	Created     time.Time `json:"created"`
	Subject     struct {
		Type string `json:"type"`
		Ref  string `json:"ref"`
	} `json:"subject"`
	Value string
}

type TokenAPI

type TokenAPI interface {
	Create(name string, subject string) (*Token, error)
	List() ([]Token, error)
}

type User

type User struct {
	ID                string    `json:"_id"`
	Name              string    `json:"userName"`
	Email             string    `json:"email"`
	Accounts          []Account `json:"account"`
	ActiveAccountName string    `json:"activeAccountName"`
	Roles             []string  `json:"roles"`
	UserData          struct {
		Avatar string `json:"image"`
	} `json:"user_data"`
}

func (*User) GetActiveAccount

func (u *User) GetActiveAccount() *Account

type UserAPI

type UserAPI interface {
	GetCurrent(ctx context.Context) (*User, error)
}

type ValidateRuntimeOptions

type ValidateRuntimeOptions struct {
	Cluster   string
	Namespace string
}

type Workflow

type Workflow struct {
	ID                 string    `json:"id"`
	Status             string    `json:"status"`
	UserYamlDescriptor string    `json:"userYamlDescriptor"`
	Progress           string    `json:"progress"`
	Created            time.Time `json:"created"`
	Updated            time.Time `json:"updated"`
	Finished           time.Time `json:"finished"`
}

type WorkflowAPI

type WorkflowAPI interface {
	Get(string) (*Workflow, error)
	WaitForStatus(string, string, time.Duration, time.Duration) error
}

Jump to

Keyboard shortcuts

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