models

package
v0.0.0-...-deacbb2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 19 Imported by: 37

Documentation

Index

Constants

View Source
const (
	FormatVersion                   = "18"
	StepListItemWithKey             = "with"
	StepListItemStepBundleKeyPrefix = "bundle::"
)
View Source
const LogFormatVersion = "2"

Variables

This section is empty.

Functions

func MergeStepWith

func MergeStepWith(step, otherStep stepmanModels.StepModel) (stepmanModels.StepModel, error)

Types

type AppModel

type AppModel struct {
	Title        string                              `json:"title,omitempty" yaml:"title,omitempty"`
	Summary      string                              `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description  string                              `json:"description,omitempty" yaml:"description,omitempty"`
	Environments []envmanModels.EnvironmentItemModel `json:"envs,omitempty" yaml:"envs,omitempty"`
}

func (*AppModel) FillMissingDefaults

func (app *AppModel) FillMissingDefaults() error

func (*AppModel) Normalize

func (app *AppModel) Normalize() error

func (*AppModel) Validate

func (app *AppModel) Validate() error

type BitriseDataModel

type BitriseDataModel struct {
	FormatVersion        string `json:"format_version" yaml:"format_version"`
	DefaultStepLibSource string `json:"default_step_lib_source,omitempty" yaml:"default_step_lib_source,omitempty"`
	ProjectType          string `json:"project_type" yaml:"project_type"`
	//
	Title       string `json:"title,omitempty" yaml:"title,omitempty"`
	Summary     string `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	//
	Services    map[string]Container       `json:"services,omitempty" yaml:"services,omitempty"`
	Containers  map[string]Container       `json:"containers,omitempty" yaml:"containers,omitempty"`
	App         AppModel                   `json:"app,omitempty" yaml:"app,omitempty"`
	Meta        map[string]interface{}     `json:"meta,omitempty" yaml:"meta,omitempty"`
	TriggerMap  TriggerMapModel            `json:"trigger_map,omitempty" yaml:"trigger_map,omitempty"`
	Pipelines   map[string]PipelineModel   `json:"pipelines,omitempty" yaml:"pipelines,omitempty"`
	Stages      map[string]StageModel      `json:"stages,omitempty" yaml:"stages,omitempty"`
	Workflows   map[string]WorkflowModel   `json:"workflows,omitempty" yaml:"workflows,omitempty"`
	StepBundles map[string]StepBundleModel `json:"step_bundles,omitempty" yaml:"step_bundles,omitempty"`
}

func (*BitriseDataModel) FillMissingDefaults

func (config *BitriseDataModel) FillMissingDefaults() error

func (*BitriseDataModel) Normalize

func (config *BitriseDataModel) Normalize() error

func (*BitriseDataModel) RemoveRedundantFields

func (config *BitriseDataModel) RemoveRedundantFields() error

func (*BitriseDataModel) Validate

func (config *BitriseDataModel) Validate() ([]string, error)

type BuildRunResultsModel

type BuildRunResultsModel struct {
	WorkflowID           string                `json:"workflow_id" yaml:"workflow_id"`
	EventName            string                `json:"event_name" yaml:"event_name"`
	ProjectType          string                `json:"project_type" yaml:"project_type"`
	StartTime            time.Time             `json:"start_time" yaml:"start_time"`
	StepmanUpdates       map[string]int        `json:"stepman_updates" yaml:"stepman_updates"`
	SuccessSteps         []StepRunResultsModel `json:"success_steps" yaml:"success_steps"`
	FailedSteps          []StepRunResultsModel `json:"failed_steps" yaml:"failed_steps"`
	FailedSkippableSteps []StepRunResultsModel `json:"failed_skippable_steps" yaml:"failed_skippable_steps"`
	SkippedSteps         []StepRunResultsModel `json:"skipped_steps" yaml:"skipped_steps"`
}

func (BuildRunResultsModel) ExitCode

func (buildRes BuildRunResultsModel) ExitCode() int

func (BuildRunResultsModel) HasFailedSkippableSteps

func (buildRes BuildRunResultsModel) HasFailedSkippableSteps() bool

func (BuildRunResultsModel) IsBuildFailed

func (buildRes BuildRunResultsModel) IsBuildFailed() bool

func (BuildRunResultsModel) IsStepLibUpdated

func (buildRes BuildRunResultsModel) IsStepLibUpdated(stepLib string) bool

func (BuildRunResultsModel) OrderedResults

func (buildRes BuildRunResultsModel) OrderedResults() []StepRunResultsModel

func (BuildRunResultsModel) ResultsCount

func (buildRes BuildRunResultsModel) ResultsCount() int

type BuildRunStartModel

type BuildRunStartModel struct {
	EventName   string    `json:"event_name" yaml:"event_name"`
	ProjectType string    `json:"project_type" yaml:"project_type"`
	StartTime   time.Time `json:"start_time" yaml:"start_time"`
}

type ConfigFileTreeModel

type ConfigFileTreeModel struct {
	Path     string                `json:"path" yaml:"path"`
	Contents string                `json:"contents,omitempty" yaml:"contents,omitempty"`
	Includes []ConfigFileTreeModel `json:"includes,omitempty" yaml:"includes,omitempty"`
}

func (*ConfigFileTreeModel) Merge

func (configTree *ConfigFileTreeModel) Merge() (string, error)

type Container

type Container struct {
	Image       string                              `json:"image,omitempty" yaml:"image,omitempty"`
	Credentials DockerCredentials                   `json:"credentials,omitempty" yaml:"credentials,omitempty"`
	Ports       []string                            `json:"ports,omitempty" yaml:"ports,omitempty"`
	Envs        []envmanModels.EnvironmentItemModel `json:"envs,omitempty" yaml:"envs,omitempty"`
	Options     string                              `json:"options,omitempty" yaml:"options,omitempty"`
}

func (*Container) Normalize

func (container *Container) Normalize() error

func (*Container) Validate

func (container *Container) Validate() error

type ContainerPlan

type ContainerPlan struct {
	Image string `json:"image"`
}

type DockerCredentials

type DockerCredentials struct {
	Username string `json:"username,omitempty" yaml:"username,omitempty"`
	Password string `json:"password,omitempty" yaml:"password,omitempty"`
	Server   string `json:"server,omitempty" yaml:"server,omitempty"`
}

type GraphPipelineAlwaysRunMode

type GraphPipelineAlwaysRunMode string
const (
	GraphPipelineAlwaysRunModeOff      GraphPipelineAlwaysRunMode = "off"
	GraphPipelineAlwaysRunModeWorkflow GraphPipelineAlwaysRunMode = "workflow"
)

func (*GraphPipelineAlwaysRunMode) UnmarshalYAML

func (d *GraphPipelineAlwaysRunMode) UnmarshalYAML(unmarshal func(interface{}) error) error

type GraphPipelineRunIfModel

type GraphPipelineRunIfModel struct {
	Expression string `json:"expression,omitempty" yaml:"expression,omitempty"`
}

type GraphPipelineWorkflowListItemModel

type GraphPipelineWorkflowListItemModel map[string]GraphPipelineWorkflowModel

type GraphPipelineWorkflowModel

type GraphPipelineWorkflowModel struct {
	DependsOn       []string                   `json:"depends_on,omitempty" yaml:"depends_on,omitempty"`
	AbortOnFail     bool                       `json:"abort_on_fail,omitempty" yaml:"abort_on_fail,omitempty"`
	RunIf           GraphPipelineRunIfModel    `json:"run_if,omitempty" yaml:"run_if,omitempty"`
	ShouldAlwaysRun GraphPipelineAlwaysRunMode `json:"should_always_run,omitempty" yaml:"should_always_run,omitempty"`
}

type PipelineModel

type PipelineModel struct {
	Title       string                             `json:"title,omitempty" yaml:"title,omitempty"`
	Summary     string                             `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description string                             `json:"description,omitempty" yaml:"description,omitempty"`
	Triggers    Triggers                           `json:"triggers,omitempty" yaml:"triggers,omitempty"`
	Stages      []StageListItemModel               `json:"stages,omitempty" yaml:"stages,omitempty"`
	Workflows   GraphPipelineWorkflowListItemModel `json:"workflows,omitempty" yaml:"workflows,omitempty"`
}

type PullRequestGitEventTriggerItem

type PullRequestGitEventTriggerItem struct {
	Enabled       *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	DraftEnabled  *bool `json:"draft_enabled,omitempty" yaml:"draft_enabled,omitempty"`
	SourceBranch  any   `json:"source_branch,omitempty" yaml:"source_branch,omitempty"`
	TargetBranch  any   `json:"target_branch,omitempty" yaml:"target_branch,omitempty"`
	Label         any   `json:"label,omitempty" yaml:"label,omitempty"`
	Comment       any   `json:"comment,omitempty" yaml:"comment,omitempty"`
	CommitMessage any   `json:"commit_message,omitempty" yaml:"commit_message,omitempty"`
	ChangedFiles  any   `json:"changed_files,omitempty" yaml:"changed_files,omitempty"`
}

type PullRequestReadyState

type PullRequestReadyState string
const (
	PullRequestReadyStateDraft                     PullRequestReadyState = "draft"
	PullRequestReadyStateReadyForReview            PullRequestReadyState = "ready_for_review"
	PullRequestReadyStateConvertedToReadyForReview PullRequestReadyState = "converted_to_ready_for_review"
)

type PushGitEventTriggerItem

type PushGitEventTriggerItem struct {
	Enabled       *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Branch        any   `json:"branch,omitempty" yaml:"branch,omitempty"`
	CommitMessage any   `json:"commit_message,omitempty" yaml:"commit_message,omitempty"`
	ChangedFiles  any   `json:"changed_files,omitempty" yaml:"changed_files,omitempty"`
}

type StageListItemModel

type StageListItemModel map[string]StageModel

type StageModel

type StageModel struct {
	Title           string                       `json:"title,omitempty" yaml:"title,omitempty"`
	Summary         string                       `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description     string                       `json:"description,omitempty" yaml:"description,omitempty"`
	ShouldAlwaysRun bool                         `json:"should_always_run,omitempty" yaml:"should_always_run,omitempty"`
	AbortOnFail     bool                         `json:"abort_on_fail,omitempty" yaml:"abort_on_fail,omitempty"`
	RunIf           string                       `json:"run_if,omitempty" yaml:"run_if,omitempty"`
	Workflows       []StageWorkflowListItemModel `json:"workflows,omitempty" yaml:"workflows,omitempty"`
}

type StageWorkflowListItemModel

type StageWorkflowListItemModel map[string]StageWorkflowModel

type StageWorkflowModel

type StageWorkflowModel struct {
	RunIf string `json:"run_if,omitempty" yaml:"run_if,omitempty"`
}

type StepBundleListItemModel

type StepBundleListItemModel struct {
	Environments []envmanModels.EnvironmentItemModel `json:"envs,omitempty" yaml:"envs,omitempty"`
}

func (*StepBundleListItemModel) Normalize

func (bundle *StepBundleListItemModel) Normalize() error

func (*StepBundleListItemModel) Validate

func (bundle *StepBundleListItemModel) Validate() error

type StepBundleModel

type StepBundleModel struct {
	Environments []envmanModels.EnvironmentItemModel `json:"envs,omitempty" yaml:"envs,omitempty"`
	Steps        []StepListStepItemModel             `json:"steps,omitempty" yaml:"steps,omitempty"`
}

func (*StepBundleModel) Normalize

func (bundle *StepBundleModel) Normalize() error

func (*StepBundleModel) Validate

func (bundle *StepBundleModel) Validate() ([]string, error)

type StepBundlePlan

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

type StepError

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

type StepExecutionPlan

type StepExecutionPlan struct {
	UUID   string `json:"uuid"`
	StepID string `json:"step_id"`

	Step stepmanModels.StepModel `json:"-"`
	// With (container) group
	WithGroupUUID string   `json:"with_group_uuid,omitempty"`
	ContainerID   string   `json:"-"`
	ServiceIDs    []string `json:"-"`
	// Step Bundle group
	StepBundleUUID string                              `json:"step_bundle_uuid,omitempty"`
	StepBundleEnvs []envmanModels.EnvironmentItemModel `json:"-"`
}

type StepListItemModel

type StepListItemModel map[string]interface{}

func (*StepListItemModel) GetBundle

func (stepListItem *StepListItemModel) GetBundle() (*StepBundleListItemModel, error)

func (*StepListItemModel) GetKeyAndType

func (stepListItem *StepListItemModel) GetKeyAndType() (string, StepListItemType, error)

func (*StepListItemModel) GetStep

func (stepListItem *StepListItemModel) GetStep() (*stepmanModels.StepModel, error)

func (*StepListItemModel) GetWith

func (stepListItem *StepListItemModel) GetWith() (*WithModel, error)

func (*StepListItemModel) UnmarshalJSON

func (stepListItem *StepListItemModel) UnmarshalJSON(b []byte) error

func (*StepListItemModel) UnmarshalYAML

func (stepListItem *StepListItemModel) UnmarshalYAML(unmarshal func(interface{}) error) error

type StepListItemType

type StepListItemType int
const (
	StepListItemTypeUnknown StepListItemType = iota
	StepListItemTypeStep
	StepListItemTypeWith
	StepListItemTypeBundle
)

type StepListStepBundleItemModel

type StepListStepBundleItemModel map[string]StepBundleListItemModel

type StepListStepItemModel

type StepListStepItemModel map[string]stepmanModels.StepModel

func (*StepListStepItemModel) GetStepIDAndStep

func (stepListStepItem *StepListStepItemModel) GetStepIDAndStep() (string, stepmanModels.StepModel, error)

type StepListWithItemModel

type StepListWithItemModel map[string]WithModel

type StepRunResultsModel

type StepRunResultsModel struct {
	StepInfo   stepmanModels.StepInfoModel `json:"step_info" yaml:"step_info"`
	StepInputs map[string]string           `json:"step_inputs" yaml:"step_inputs"`
	Status     StepRunStatus               `json:"status" yaml:"status"`
	Idx        int                         `json:"idx" yaml:"idx"`
	RunTime    time.Duration               `json:"run_time" yaml:"run_time"`
	StartTime  time.Time                   `json:"start_time" yaml:"start_time"`
	ErrorStr   string                      `json:"error_str" yaml:"error_str"`
	ExitCode   int                         `json:"exit_code" yaml:"exit_code"`

	Timeout         time.Duration `json:"-"`
	NoOutputTimeout time.Duration `json:"-"`
}

func (StepRunResultsModel) StatusReasonAndErrors

func (s StepRunResultsModel) StatusReasonAndErrors() (string, []StepError)

type StepRunStatus

type StepRunStatus int

StepRunStatus ...

const (
	StepRunStatusCodeSuccess                StepRunStatus = 0
	StepRunStatusCodeFailed                 StepRunStatus = 1
	StepRunStatusCodeFailedSkippable        StepRunStatus = 2
	StepRunStatusCodeSkipped                StepRunStatus = 3
	StepRunStatusCodeSkippedWithRunIf       StepRunStatus = 4
	StepRunStatusCodePreparationFailed      StepRunStatus = 5
	StepRunStatusAbortedWithCustomTimeout   StepRunStatus = 7 // step times out due to a custom timeout
	StepRunStatusAbortedWithNoOutputTimeout StepRunStatus = 8 // step times out due to no output received (hang)
)

func NewStepRunStatus

func NewStepRunStatus(status string) StepRunStatus

func (StepRunStatus) Name

func (s StepRunStatus) Name() string

func (StepRunStatus) String

func (s StepRunStatus) String() string

type TagGitEventTriggerItem

type TagGitEventTriggerItem struct {
	Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Name    any   `json:"name,omitempty" yaml:"name,omitempty"`
}

type TestResultStepInfo

type TestResultStepInfo struct {
	ID      string `json:"id" yaml:"id"`
	Version string `json:"version" yaml:"version"`
	Title   string `json:"title" yaml:"title"`
	Number  int    `json:"number" yaml:"number"`
}

type TriggerEventType

type TriggerEventType string
const (
	TriggerEventTypeCodePush    TriggerEventType = "code-push"
	TriggerEventTypePullRequest TriggerEventType = "pull-request"
	TriggerEventTypeTag         TriggerEventType = "tag"
	TriggerEventTypeUnknown     TriggerEventType = "unknown"
)

type TriggerItemType

type TriggerItemType string
const (
	CodePushType    TriggerItemType = "push"
	PullRequestType TriggerItemType = "pull_request"
	TagPushType     TriggerItemType = "tag"
)

type TriggerMapItemModel

type TriggerMapItemModel struct {
	// Trigger Item shared properties
	Type       TriggerItemType `json:"type,omitempty" yaml:"type,omitempty"`
	Enabled    *bool           `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	PipelineID string          `json:"pipeline,omitempty" yaml:"pipeline,omitempty"`
	WorkflowID string          `json:"workflow,omitempty" yaml:"workflow,omitempty"`

	// Code Push Item conditions
	PushBranch interface{} `json:"push_branch,omitempty" yaml:"push_branch,omitempty"`

	// Code Push and Pull Request Item conditions
	CommitMessage interface{} `json:"commit_message,omitempty" yaml:"commit_message,omitempty"`
	ChangedFiles  interface{} `json:"changed_files,omitempty" yaml:"changed_files,omitempty"`

	// Tag Push Item conditions
	Tag interface{} `json:"tag,omitempty" yaml:"tag,omitempty"`

	// Pull Request Item conditions
	PullRequestSourceBranch interface{} `json:"pull_request_source_branch,omitempty" yaml:"pull_request_source_branch,omitempty"`
	PullRequestTargetBranch interface{} `json:"pull_request_target_branch,omitempty" yaml:"pull_request_target_branch,omitempty"`
	DraftPullRequestEnabled *bool       `json:"draft_pull_request_enabled,omitempty" yaml:"draft_pull_request_enabled,omitempty"`
	PullRequestLabel        interface{} `json:"pull_request_label,omitempty" yaml:"pull_request_label,omitempty"`
	PullRequestComment      interface{} `json:"pull_request_comment,omitempty" yaml:"pull_request_comment,omitempty"`

	// Deprecated properties
	Pattern              string `json:"pattern,omitempty" yaml:"pattern,omitempty"`
	IsPullRequestAllowed bool   `json:"is_pull_request_allowed,omitempty" yaml:"is_pull_request_allowed,omitempty"`
}

func (TriggerMapItemModel) IsDraftPullRequestEnabled

func (item TriggerMapItemModel) IsDraftPullRequestEnabled() bool

func (TriggerMapItemModel) MatchWithParams

func (item TriggerMapItemModel) MatchWithParams(pushBranch, prSourceBranch, prTargetBranch string, prReadyState PullRequestReadyState, tag string) (bool, error)

func (TriggerMapItemModel) Normalized

func (item TriggerMapItemModel) Normalized(idx int) (TriggerMapItemModel, error)

Normalized casts trigger item values from map[interface{}]interface{} to map[string]interface{} to support JSON marshalling of the bitrise.yml.

func (TriggerMapItemModel) Validate

func (item TriggerMapItemModel) Validate(idx int, workflows, pipelines []string) ([]string, error)

type TriggerMapModel

type TriggerMapModel []TriggerMapItemModel

func (TriggerMapModel) FirstMatchingTarget

func (triggerMap TriggerMapModel) FirstMatchingTarget(pushBranch, prSourceBranch, prTargetBranch string, prReadyState PullRequestReadyState, tag string) (string, string, error)

func (TriggerMapModel) Normalized

func (triggerMap TriggerMapModel) Normalized() ([]TriggerMapItemModel, error)

func (TriggerMapModel) Validate

func (triggerMap TriggerMapModel) Validate(workflows, pipelines []string) ([]string, error)

type Triggers

type Triggers struct {
	Enabled             *bool                            `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	PushTriggers        []PushGitEventTriggerItem        `json:"push,omitempty" yaml:"push,omitempty"`
	PullRequestTriggers []PullRequestGitEventTriggerItem `json:"pull_request,omitempty" yaml:"pull_request,omitempty"`
	TagTriggers         []TagGitEventTriggerItem         `json:"tag,omitempty" yaml:"tag,omitempty"`
}

func (*Triggers) UnmarshalYAML

func (triggers *Triggers) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for Triggers, allowing additional validation of the triggers YAML configuration.

type WithGroupPlan

type WithGroupPlan struct {
	Services  []ContainerPlan `json:"services,omitempty"`
	Container ContainerPlan   `json:"container,omitempty"`
}

type WithModel

type WithModel struct {
	ContainerID string                  `json:"container,omitempty" yaml:"container,omitempty"`
	ServiceIDs  []string                `json:"services,omitempty" yaml:"services,omitempty"`
	Steps       []StepListStepItemModel `json:"steps,omitempty" yaml:"steps,omitempty"`
}

func (*WithModel) Normalize

func (with *WithModel) Normalize() error

func (*WithModel) Validate

func (with *WithModel) Validate(workflowID string, containers, services map[string]Container) ([]string, error)

type WorkflowExecutionPlan

type WorkflowExecutionPlan struct {
	UUID                 string              `json:"uuid"`
	WorkflowID           string              `json:"workflow_id"`
	Steps                []StepExecutionPlan `json:"steps"`
	WorkflowTitle        string              `json:"-"`
	IsSteplibOfflineMode bool                `json:"-"`
}

type WorkflowListItemModel

type WorkflowListItemModel map[string]WorkflowModel

type WorkflowModel

type WorkflowModel struct {
	Title        string                              `json:"title,omitempty" yaml:"title,omitempty"`
	Summary      string                              `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description  string                              `json:"description,omitempty" yaml:"description,omitempty"`
	Triggers     Triggers                            `json:"triggers,omitempty" yaml:"triggers,omitempty"`
	BeforeRun    []string                            `json:"before_run,omitempty" yaml:"before_run,omitempty"`
	AfterRun     []string                            `json:"after_run,omitempty" yaml:"after_run,omitempty"`
	Environments []envmanModels.EnvironmentItemModel `json:"envs,omitempty" yaml:"envs,omitempty"`
	Steps        []StepListItemModel                 `json:"steps,omitempty" yaml:"steps,omitempty"`
	Meta         map[string]interface{}              `json:"meta,omitempty" yaml:"meta,omitempty"`
}

func (*WorkflowModel) FillMissingDefaults

func (workflow *WorkflowModel) FillMissingDefaults(title string) error

func (*WorkflowModel) Normalize

func (workflow *WorkflowModel) Normalize() error

func (*WorkflowModel) Validate

func (workflow *WorkflowModel) Validate() error

type WorkflowRunModes

type WorkflowRunModes struct {
	CIMode                  bool
	PRMode                  bool
	DebugMode               bool
	SecretFilteringMode     bool
	SecretEnvsFilteringMode bool
	NoOutputTimeout         time.Duration
	IsSteplibOfflineMode    bool
}

type WorkflowRunPlan

type WorkflowRunPlan struct {
	Version          string `json:"version"`
	LogFormatVersion string `json:"log_format_version"`

	CIMode                  bool `json:"ci_mode"`
	PRMode                  bool `json:"pr_mode"`
	DebugMode               bool `json:"debug_mode"`
	IsSteplibOfflineMode    bool `json:"-"`
	NoOutputTimeoutMode     bool `json:"no_output_timeout_mode"`
	SecretFilteringMode     bool `json:"secret_filtering_mode"`
	SecretEnvsFilteringMode bool `json:"secret_envs_filtering_mode"`

	WithGroupPlans  map[string]WithGroupPlan  `json:"with_groups,omitempty"`
	StepBundlePlans map[string]StepBundlePlan `json:"step_bundles,omitempty"`
	ExecutionPlan   []WorkflowExecutionPlan   `json:"execution_plan"`
}

Jump to

Keyboard shortcuts

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