semaphore

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PipelineStateDone    = "done"
	PipelineResultPassed = "passed"
	PipelineResultFailed = "failed"

	ResourceTypeTask         = "task"
	ResourceTypeProject      = "project"
	ResourceTypeWorkflow     = "workflow"
	ResourceTypeNotification = "notification"
	ResourceTypeSecret       = "secret"
	ResourceTypePipeline     = "pipeline"
)
View Source
const (
	PipelineDoneEvent = "pipeline_done"
)

Variables

This section is empty.

Functions

func NewSemaphoreResourceManager

func NewSemaphoreResourceManager(ctx context.Context, URL string, authenticate integrations.AuthenticateFn) (integrations.ResourceManager, error)

Types

type CreateWorkflowRequest

type CreateWorkflowRequest struct {
	ProjectID    string            `json:"project_id"`
	Reference    string            `json:"reference"`
	PipelineFile string            `json:"pipeline_file"`
	Parameters   map[string]string `json:"parameters"`
}

type CreateWorkflowResponse

type CreateWorkflowResponse struct {
	WorkflowID string `json:"workflow_id"`
}

type Hook

type Hook struct {
	Workflow HookWorkflow
	Pipeline HookPipeline
}

type HookPipeline

type HookPipeline struct {
	ID     string `json:"id"`
	State  string `json:"state"`
	Result string `json:"result"`
}

type HookWorkflow

type HookWorkflow struct {
	ID string `json:"id"`
}

type Notification

type Notification struct {
	APIVersion string               `json:"apiVersion"`
	Kind       string               `json:"kind"`
	Metadata   NotificationMetadata `json:"metadata"`
	Spec       NotificationSpec     `json:"spec"`
}

func (*Notification) Id

func (p *Notification) Id() string

func (*Notification) Name

func (p *Notification) Name() string

func (*Notification) Type

func (p *Notification) Type() string

func (*Notification) URL

func (p *Notification) URL() string

type NotificationMetadata

type NotificationMetadata struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type NotificationNotifySlack

type NotificationNotifySlack struct {
	Endpoint string   `json:"endpoint,omitempty"`
	Channels []string `json:"channels,omitempty"`
}

type NotificationNotifyWebhook

type NotificationNotifyWebhook struct {
	Endpoint string `json:"endpoint"`
	Secret   string `json:"secret"`
}

type NotificationRule

type NotificationRule struct {
	Name   string                 `json:"name"`
	Filter NotificationRuleFilter `json:"filter"`
	Notify NotificationRuleNotify `json:"notify"`
}

type NotificationRuleFilter

type NotificationRuleFilter struct {
	Branches  []string `json:"branches"`
	Pipelines []string `json:"pipelines"`
	Projects  []string `json:"projects"`
	Results   []string `json:"results"`
}

type NotificationRuleNotify

type NotificationRuleNotify struct {
	Webhook NotificationNotifyWebhook `json:"webhook"`

	// TODO
	// we don't really need this, but if it's not in the request,
	// the API does not work properly.
	// Once it's fixed, or we migrate to v2 API, we can remove it from here.
	//
	Slack NotificationNotifySlack `json:"slack"`
}

type NotificationSpec

type NotificationSpec struct {
	Rules []NotificationRule `json:"rules"`
}

type Pipeline

type Pipeline struct {
	PipelineURL  string `json:"-"`
	PipelineName string `json:"name"`
	PipelineID   string `json:"ppl_id"`
	WorkflowID   string `json:"wf_id"`
	State        string `json:"state"`
	Result       string `json:"result"`
}

func (*Pipeline) Finished

func (p *Pipeline) Finished() bool

func (*Pipeline) Id

func (p *Pipeline) Id() string

func (*Pipeline) Name

func (p *Pipeline) Name() string

func (*Pipeline) Successful

func (p *Pipeline) Successful() bool

func (*Pipeline) Type

func (p *Pipeline) Type() string

func (*Pipeline) URL

func (p *Pipeline) URL() string

type PipelineResponse

type PipelineResponse struct {
	Pipeline *Pipeline `json:"pipeline"`
}

type Project

type Project struct {
	ProjectURL string           `json:"-"`
	Metadata   *ProjectMetadata `json:"metadata"`
}

func (*Project) Id

func (p *Project) Id() string

func (*Project) Name

func (p *Project) Name() string

func (*Project) Type

func (p *Project) Type() string

func (*Project) URL

func (p *Project) URL() string

type ProjectMetadata

type ProjectMetadata struct {
	ProjectName string `json:"name"`
	ProjectID   string `json:"id"`
}

type RunTaskRequest

type RunTaskRequest struct {
	TaskID       string
	Branch       string            `json:"branch"`
	PipelineFile string            `json:"pipeline_file"`
	Parameters   map[string]string `json:"parameters"`
}

type RunTaskResponse

type RunTaskResponse struct {
	WorkflowID string `json:"workflow_id"`
}

type Secret

type Secret struct {
	APIVersion string         `json:"apiVersion"`
	Kind       string         `json:"kind"`
	Metadata   SecretMetadata `json:"metadata"`
	Data       SecretSpecData `json:"data"`
}

func (*Secret) Id

func (p *Secret) Id() string

func (*Secret) Name

func (p *Secret) Name() string

func (*Secret) Type

func (p *Secret) Type() string

func (*Secret) URL

func (p *Secret) URL() string

type SecretMetadata

type SecretMetadata struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type SecretSpecData

type SecretSpecData struct {
	EnvVars []SecretSpecDataEnvVar `json:"env_vars"`
}

type SecretSpecDataEnvVar

type SecretSpecDataEnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type SemaphoreEvent

type SemaphoreEvent struct {
	PayloadSignature string `json:"signature"`
	Payload          Hook   `json:"payload"`
}

func (*SemaphoreEvent) Signature

func (e *SemaphoreEvent) Signature() string

func (*SemaphoreEvent) Type

func (e *SemaphoreEvent) Type() string

Semaphore only has one type of event. Even though the event type is not in the event payload, this event is always sent when a pipeline is done, so we use the 'pipeline_done' type here.

type SemaphoreEventHandler

type SemaphoreEventHandler struct{}

func (*SemaphoreEventHandler) EventTypes

func (i *SemaphoreEventHandler) EventTypes() []string

func (*SemaphoreEventHandler) Handle

func (i *SemaphoreEventHandler) Handle(data []byte, header http.Header) (integrations.Event, error)

func (*SemaphoreEventHandler) Status

type SemaphoreOIDCVerifier

type SemaphoreOIDCVerifier struct{}

func (*SemaphoreOIDCVerifier) Verify

type SemaphoreResourceManager

type SemaphoreResourceManager struct {
	URL   string
	Token string
}

func (*SemaphoreResourceManager) Cancel

func (i *SemaphoreResourceManager) Cancel(resourceType, id string, _ integrations.Resource) error

func (*SemaphoreResourceManager) CleanupWebhook

func (i *SemaphoreResourceManager) CleanupWebhook(options integrations.WebhookOptions) error

func (*SemaphoreResourceManager) Get

func (i *SemaphoreResourceManager) Get(resourceType, id string) (integrations.Resource, error)

func (*SemaphoreResourceManager) List

func (i *SemaphoreResourceManager) List(resourceTypes string) ([]integrations.Resource, error)

func (*SemaphoreResourceManager) RunWorkflow

func (*SemaphoreResourceManager) SetupWebhook

func (i *SemaphoreResourceManager) SetupWebhook(options integrations.WebhookOptions) (any, error)

func (*SemaphoreResourceManager) Status

type Task

type Task struct {
	ID       string `json:"id"`
	TaskName string `json:"name"`
	TaskURL  string `json:"-"`
}

func (*Task) Id

func (t *Task) Id() string

func (*Task) Name

func (t *Task) Name() string

func (*Task) Type

func (t *Task) Type() string

func (*Task) URL

func (t *Task) URL() string

type WebhookMetadata

type WebhookMetadata struct {
	Secret       WebhookSecretMetadata       `json:"secret"`
	Notification WebhookNotificationMetadata `json:"notification"`
}

type WebhookNotificationMetadata

type WebhookNotificationMetadata struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type WebhookSecretMetadata

type WebhookSecretMetadata struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Workflow

type Workflow struct {
	WorkflowURL  string    `json:"url"`
	WfID         string    `json:"wf_id"`
	InitialPplID string    `json:"initial_ppl_id"`
	Pipeline     *Pipeline `json:"pipeline"`
}

func (*Workflow) Finished

func (w *Workflow) Finished() bool

func (*Workflow) Id

func (w *Workflow) Id() string

func (*Workflow) Name

func (w *Workflow) Name() string

func (*Workflow) Successful

func (w *Workflow) Successful() bool

func (*Workflow) Type

func (w *Workflow) Type() string

func (*Workflow) URL

func (w *Workflow) URL() string

type WorkflowResponse

type WorkflowResponse struct {
	Workflow *Workflow `json:"workflow"`
}

Jump to

Keyboard shortcuts

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