github.com/rancher/types@v0.0.0-20220328215343-4370ff10ecd5/apis/project.cattle.io/v3/pipeline_types.go (about)

     1  package v3
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/pkg/errors"
     7  	"github.com/rancher/norman/condition"
     8  	"github.com/rancher/norman/types"
     9  	"github.com/rancher/norman/types/convert"
    10  	v1 "k8s.io/api/core/v1"
    11  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    12  )
    13  
    14  type PipelineConditionType string
    15  
    16  const (
    17  	PipelineExecutionConditionProvisioned condition.Cond = "Provisioned"
    18  	PipelineExecutionConditionInitialized condition.Cond = "Initialized"
    19  	PipelineExecutionConditionBuilt       condition.Cond = "Built"
    20  	PipelineExecutionConditionNotified    condition.Cond = "Notified"
    21  )
    22  
    23  type SourceCodeProvider struct {
    24  	metav1.TypeMeta   `json:",inline"`
    25  	metav1.ObjectMeta `json:"metadata,omitempty"`
    26  
    27  	ProjectName string `json:"projectName" norman:"type=reference[project]"`
    28  	Type        string `json:"type" norman:"options=github|gitlab|bitbucketcloud|bitbucketserver"`
    29  }
    30  
    31  func (s *SourceCodeProvider) ObjClusterName() string {
    32  	if parts := strings.SplitN(s.ProjectName, ":", 2); len(parts) == 2 {
    33  		return parts[0]
    34  	}
    35  	return ""
    36  }
    37  
    38  type OauthProvider struct {
    39  	metav1.TypeMeta    `json:",inline"`
    40  	metav1.ObjectMeta  `json:"metadata,omitempty"`
    41  	SourceCodeProvider `json:",inline"`
    42  
    43  	RedirectURL string `json:"redirectUrl"`
    44  }
    45  
    46  type GithubProvider struct {
    47  	OauthProvider `json:",inline"`
    48  }
    49  
    50  type GitlabProvider struct {
    51  	OauthProvider `json:",inline"`
    52  }
    53  
    54  type BitbucketCloudProvider struct {
    55  	OauthProvider `json:",inline"`
    56  }
    57  
    58  type BitbucketServerProvider struct {
    59  	OauthProvider `json:",inline"`
    60  }
    61  
    62  type SourceCodeProviderConfig struct {
    63  	types.Namespaced
    64  
    65  	metav1.TypeMeta   `json:",inline"`
    66  	metav1.ObjectMeta `json:"metadata,omitempty"`
    67  
    68  	ProjectName      string `json:"projectName" norman:"required,type=reference[project]"`
    69  	Type             string `json:"type" norman:"noupdate,options=github|gitlab|bitbucketcloud|bitbucketserver"`
    70  	Enabled          bool   `json:"enabled,omitempty"`
    71  	CredentialSecret string `json:"credentialSecret,omitempty" norman:"nocreate,noupdate"`
    72  }
    73  
    74  func (s *SourceCodeProviderConfig) ObjClusterName() string {
    75  	if parts := strings.SplitN(s.ProjectName, ":", 2); len(parts) == 2 {
    76  		return parts[0]
    77  	}
    78  	return ""
    79  }
    80  
    81  type GithubPipelineConfig struct {
    82  	metav1.TypeMeta          `json:",inline"`
    83  	metav1.ObjectMeta        `json:"metadata,omitempty"`
    84  	SourceCodeProviderConfig `json:",inline" mapstructure:",squash"`
    85  
    86  	Hostname     string `json:"hostname,omitempty" norman:"default=github.com" norman:"noupdate"`
    87  	TLS          bool   `json:"tls,omitempty" norman:"notnullable,default=true" norman:"noupdate"`
    88  	ClientID     string `json:"clientId,omitempty" norman:"noupdate"`
    89  	ClientSecret string `json:"clientSecret,omitempty" norman:"noupdate,type=password"`
    90  	Inherit      bool   `json:"inherit,omitempty" norman:"noupdate"`
    91  }
    92  
    93  type GitlabPipelineConfig struct {
    94  	metav1.TypeMeta          `json:",inline"`
    95  	metav1.ObjectMeta        `json:"metadata,omitempty"`
    96  	SourceCodeProviderConfig `json:",inline" mapstructure:",squash"`
    97  
    98  	Hostname     string `json:"hostname,omitempty" norman:"default=gitlab.com" norman:"noupdate"`
    99  	TLS          bool   `json:"tls,omitempty" norman:"notnullable,default=true" norman:"noupdate"`
   100  	ClientID     string `json:"clientId,omitempty" norman:"noupdate"`
   101  	ClientSecret string `json:"clientSecret,omitempty" norman:"noupdate,type=password"`
   102  	RedirectURL  string `json:"redirectUrl,omitempty" norman:"noupdate"`
   103  }
   104  
   105  type BitbucketCloudPipelineConfig struct {
   106  	metav1.TypeMeta          `json:",inline"`
   107  	metav1.ObjectMeta        `json:"metadata,omitempty"`
   108  	SourceCodeProviderConfig `json:",inline" mapstructure:",squash"`
   109  
   110  	ClientID     string `json:"clientId,omitempty" norman:"noupdate"`
   111  	ClientSecret string `json:"clientSecret,omitempty" norman:"noupdate,type=password"`
   112  	RedirectURL  string `json:"redirectUrl,omitempty" norman:"noupdate"`
   113  }
   114  
   115  type BitbucketServerPipelineConfig struct {
   116  	metav1.TypeMeta          `json:",inline"`
   117  	metav1.ObjectMeta        `json:"metadata,omitempty"`
   118  	SourceCodeProviderConfig `json:",inline" mapstructure:",squash"`
   119  
   120  	Hostname    string `json:"hostname,omitempty"`
   121  	TLS         bool   `json:"tls,omitempty"`
   122  	ConsumerKey string `json:"consumerKey,omitempty"`
   123  	PublicKey   string `json:"publicKey,omitempty"`
   124  	PrivateKey  string `json:"privateKey,omitempty" norman:"type=password"`
   125  	RedirectURL string `json:"redirectUrl,omitempty"`
   126  }
   127  
   128  type Pipeline struct {
   129  	types.Namespaced
   130  
   131  	metav1.TypeMeta   `json:",inline"`
   132  	metav1.ObjectMeta `json:"metadata,omitempty"`
   133  
   134  	Spec   PipelineSpec   `json:"spec"`
   135  	Status PipelineStatus `json:"status"`
   136  }
   137  
   138  func (p *Pipeline) ObjClusterName() string {
   139  	return p.Spec.ObjClusterName()
   140  }
   141  
   142  type PipelineExecution struct {
   143  	types.Namespaced
   144  
   145  	metav1.TypeMeta   `json:",inline"`
   146  	metav1.ObjectMeta `json:"metadata,omitempty"`
   147  
   148  	Spec   PipelineExecutionSpec   `json:"spec"`
   149  	Status PipelineExecutionStatus `json:"status"`
   150  }
   151  
   152  func (p *PipelineExecution) ObjClusterName() string {
   153  	return p.Spec.ObjClusterName()
   154  }
   155  
   156  type PipelineSetting struct {
   157  	types.Namespaced
   158  
   159  	ProjectName       string `json:"projectName" norman:"type=reference[project]"`
   160  	metav1.TypeMeta   `json:",inline"`
   161  	metav1.ObjectMeta `json:"metadata,omitempty"`
   162  
   163  	Value      string `json:"value" norman:"required"`
   164  	Default    string `json:"default" norman:"nocreate,noupdate"`
   165  	Customized bool   `json:"customized" norman:"nocreate,noupdate"`
   166  }
   167  
   168  func (p *PipelineSetting) ObjClusterName() string {
   169  	if parts := strings.SplitN(p.ProjectName, ":", 2); len(parts) == 2 {
   170  		return parts[0]
   171  	}
   172  	return ""
   173  }
   174  
   175  type SourceCodeCredential struct {
   176  	types.Namespaced
   177  
   178  	metav1.TypeMeta   `json:",inline"`
   179  	metav1.ObjectMeta `json:"metadata,omitempty"`
   180  
   181  	Spec   SourceCodeCredentialSpec   `json:"spec"`
   182  	Status SourceCodeCredentialStatus `json:"status"`
   183  }
   184  
   185  func (s *SourceCodeCredential) ObjClusterName() string {
   186  	return s.Spec.ObjClusterName()
   187  }
   188  
   189  type SourceCodeRepository struct {
   190  	types.Namespaced
   191  
   192  	metav1.TypeMeta   `json:",inline"`
   193  	metav1.ObjectMeta `json:"metadata,omitempty"`
   194  
   195  	Spec   SourceCodeRepositorySpec   `json:"spec"`
   196  	Status SourceCodeRepositoryStatus `json:"status"`
   197  }
   198  
   199  func (s *SourceCodeRepository) ObjClusterName() string {
   200  	return s.Spec.ObjClusterName()
   201  }
   202  
   203  type PipelineStatus struct {
   204  	PipelineState        string                `json:"pipelineState,omitempty" norman:"required,options=active|inactive,default=active"`
   205  	NextRun              int                   `json:"nextRun" yaml:"nextRun,omitempty" norman:"default=1,min=1"`
   206  	LastExecutionID      string                `json:"lastExecutionId,omitempty" yaml:"lastExecutionId,omitempty"`
   207  	LastRunState         string                `json:"lastRunState,omitempty" yaml:"lastRunState,omitempty"`
   208  	LastStarted          string                `json:"lastStarted,omitempty" yaml:"lastStarted,omitempty"`
   209  	NextStart            string                `json:"nextStart,omitempty" yaml:"nextStart,omitempty"`
   210  	WebHookID            string                `json:"webhookId,omitempty" yaml:"webhookId,omitempty"`
   211  	Token                string                `json:"token,omitempty" yaml:"token,omitempty" norman:"writeOnly,noupdate"`
   212  	SourceCodeCredential *SourceCodeCredential `json:"sourceCodeCredential,omitempty" yaml:"sourceCodeCredential,omitempty"`
   213  }
   214  
   215  type PipelineSpec struct {
   216  	ProjectName string `json:"projectName" yaml:"projectName" norman:"required,type=reference[project]"`
   217  
   218  	DisplayName        string `json:"displayName,omitempty" yaml:"displayName,omitempty"`
   219  	TriggerWebhookPush bool   `json:"triggerWebhookPush,omitempty" yaml:"triggerWebhookPush,omitempty"`
   220  	TriggerWebhookPr   bool   `json:"triggerWebhookPr,omitempty" yaml:"triggerWebhookPr,omitempty"`
   221  	TriggerWebhookTag  bool   `json:"triggerWebhookTag,omitempty" yaml:"triggerWebhookTag,omitempty"`
   222  
   223  	RepositoryURL            string `json:"repositoryUrl,omitempty" yaml:"repositoryUrl,omitempty"`
   224  	SourceCodeCredentialName string `json:"sourceCodeCredentialName,omitempty" yaml:"sourceCodeCredentialName,omitempty" norman:"type=reference[sourceCodeCredential],noupdate"`
   225  }
   226  
   227  func (p *PipelineSpec) ObjClusterName() string {
   228  	if parts := strings.SplitN(p.ProjectName, ":", 2); len(parts) == 2 {
   229  		return parts[0]
   230  	}
   231  	return ""
   232  }
   233  
   234  type PipelineConfig struct {
   235  	Stages []Stage `json:"stages,omitempty" yaml:"stages,omitempty"`
   236  
   237  	Timeout      int                   `json:"timeout,omitempty" yaml:"timeout,omitempty"`
   238  	Branch       *Constraint           `json:"branch,omitempty" yaml:"branch,omitempty"`
   239  	Notification *PipelineNotification `json:"notification,omitempty" yaml:"notification,omitempty"`
   240  }
   241  
   242  type PipelineNotification struct {
   243  	Recipients []Recipient   `json:"recipients,omitempty" yaml:"recipients,omitempty"`
   244  	Message    string        `json:"message,omitempty" yaml:"message,omitempty"`
   245  	Condition  stringorslice `json:"condition,omitempty" yaml:"condition,omitempty"`
   246  }
   247  
   248  type Recipient struct {
   249  	Recipient string `json:"recipient,omitempty"`
   250  	Notifier  string `json:"notifier,omitempty"`
   251  }
   252  
   253  type PipelineCondition struct {
   254  	// Type of cluster condition.
   255  	Type PipelineConditionType `json:"type"`
   256  	// Status of the condition, one of True, False, Unknown.
   257  	Status v1.ConditionStatus `json:"status"`
   258  	// The last time this condition was updated.
   259  	LastUpdateTime string `json:"lastUpdateTime,omitempty"`
   260  	// Last time the condition transitioned from one status to another.
   261  	LastTransitionTime string `json:"lastTransitionTime,omitempty"`
   262  	// The reason for the condition's last transition.
   263  	Reason string `json:"reason,omitempty"`
   264  	// Human-readable message indicating details about last transition
   265  	Message string `json:"message,omitempty"`
   266  }
   267  
   268  type Stage struct {
   269  	Name  string `json:"name,omitempty" yaml:"name,omitempty" norman:"required"`
   270  	Steps []Step `json:"steps,omitempty" yaml:"steps,omitempty" norman:"required"`
   271  
   272  	When *Constraints `json:"when,omitempty" yaml:"when,omitempty"`
   273  }
   274  
   275  type Step struct {
   276  	SourceCodeConfig     *SourceCodeConfig     `json:"sourceCodeConfig,omitempty" yaml:"sourceCodeConfig,omitempty"`
   277  	RunScriptConfig      *RunScriptConfig      `json:"runScriptConfig,omitempty" yaml:"runScriptConfig,omitempty"`
   278  	PublishImageConfig   *PublishImageConfig   `json:"publishImageConfig,omitempty" yaml:"publishImageConfig,omitempty"`
   279  	ApplyYamlConfig      *ApplyYamlConfig      `json:"applyYamlConfig,omitempty" yaml:"applyYamlConfig,omitempty"`
   280  	PublishCatalogConfig *PublishCatalogConfig `json:"publishCatalogConfig,omitempty" yaml:"publishCatalogConfig,omitempty"`
   281  	ApplyAppConfig       *ApplyAppConfig       `json:"applyAppConfig,omitempty" yaml:"applyAppConfig,omitempty"`
   282  
   283  	Env           map[string]string `json:"env,omitempty" yaml:"env,omitempty"`
   284  	EnvFrom       []EnvFrom         `json:"envFrom,omitempty" yaml:"envFrom,omitempty"`
   285  	Privileged    bool              `json:"privileged,omitempty" yaml:"privileged,omitempty"`
   286  	CPURequest    string            `json:"cpuRequest,omitempty" yaml:"cpuRequest,omitempty"`
   287  	CPULimit      string            `json:"cpuLimit,omitempty" yaml:"cpuLimit,omitempty"`
   288  	MemoryRequest string            `json:"memoryRequest,omitempty" yaml:"memoryRequest,omitempty"`
   289  	MemoryLimit   string            `json:"memoryLimit,omitempty" yaml:"memoryLimit,omitempty"`
   290  	When          *Constraints      `json:"when,omitempty" yaml:"when,omitempty"`
   291  }
   292  
   293  type Constraints struct {
   294  	Branch *Constraint `json:"branch,omitempty" yaml:"branch,omitempty"`
   295  	Event  *Constraint `json:"event,omitempty" yaml:"event,omitempty"`
   296  }
   297  
   298  type Constraint struct {
   299  	Include []string `json:"include,omitempty" yaml:"include,omitempty"`
   300  	Exclude []string `json:"exclude,omitempty" yaml:"exclude,omitempty"`
   301  }
   302  
   303  type SourceCodeConfig struct {
   304  }
   305  
   306  type RunScriptConfig struct {
   307  	Image       string `json:"image,omitempty" yaml:"image,omitempty" norman:"required"`
   308  	ShellScript string `json:"shellScript,omitempty" yaml:"shellScript,omitempty"`
   309  }
   310  
   311  type PublishImageConfig struct {
   312  	DockerfilePath string `json:"dockerfilePath,omittempty" yaml:"dockerfilePath,omitempty" norman:"required,default=./Dockerfile"`
   313  	BuildContext   string `json:"buildContext,omitempty" yaml:"buildContext,omitempty" norman:"required,default=."`
   314  	Tag            string `json:"tag,omitempty" yaml:"tag,omitempty" norman:"required,default=${CICD_GIT_REPOSITORY_NAME}:${CICD_GIT_BRANCH}"`
   315  	PushRemote     bool   `json:"pushRemote,omitempty" yaml:"pushRemote,omitempty"`
   316  	Registry       string `json:"registry,omitempty" yaml:"registry,omitempty"`
   317  }
   318  
   319  type ApplyYamlConfig struct {
   320  	Path      string `json:"path,omitempty" yaml:"path,omitempty"`
   321  	Content   string `json:"content,omitempty" yaml:"content,omitempty"`
   322  	Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
   323  }
   324  
   325  type PublishCatalogConfig struct {
   326  	Path            string `json:"path,omitempty" yaml:"path,omitempty"`
   327  	CatalogTemplate string `json:"catalogTemplate,omitempty" yaml:"catalogTemplate,omitempty"`
   328  	Version         string `json:"version,omitempty" yaml:"version,omitempty"`
   329  	GitURL          string `json:"gitUrl,omitempty" yaml:"gitUrl,omitempty"`
   330  	GitBranch       string `json:"gitBranch,omitempty" yaml:"gitBranch,omitempty"`
   331  	GitAuthor       string `json:"gitAuthor,omitempty" yaml:"gitAuthor,omitempty"`
   332  	GitEmail        string `json:"gitEmail,omitempty" yaml:"gitEmail,omitempty"`
   333  }
   334  
   335  type ApplyAppConfig struct {
   336  	CatalogTemplate string            `json:"catalogTemplate,omitempty" yaml:"catalogTemplate,omitempty"`
   337  	Version         string            `json:"version,omitempty" yaml:"version,omitempty"`
   338  	Answers         map[string]string `json:"answers,omitempty" yaml:"answers,omitempty"`
   339  	Name            string            `json:"name,omitempty" yaml:"name,omitempty"`
   340  	TargetNamespace string            `json:"targetNamespace,omitempty" yaml:"targetNamespace,omitempty"`
   341  }
   342  
   343  type PipelineExecutionSpec struct {
   344  	ProjectName string `json:"projectName" yaml:"projectName" norman:"required,type=reference[project]"`
   345  
   346  	PipelineName    string         `json:"pipelineName" norman:"required,type=reference[pipeline]"`
   347  	PipelineConfig  PipelineConfig `json:"pipelineConfig,omitempty" norman:"required"`
   348  	RepositoryURL   string         `json:"repositoryUrl,omitempty"`
   349  	Run             int            `json:"run,omitempty" norman:"required,min=1"`
   350  	TriggeredBy     string         `json:"triggeredBy,omitempty" norman:"required,options=user|cron|webhook"`
   351  	TriggerUserName string         `json:"triggerUserName,omitempty" norman:"type=reference[user]"`
   352  	Commit          string         `json:"commit,omitempty"`
   353  	Event           string         `json:"event,omitempty"`
   354  	Branch          string         `json:"branch,omitempty"`
   355  	Ref             string         `json:"ref,omitempty"`
   356  	HTMLLink        string         `json:"htmlLink,omitempty"`
   357  	Title           string         `json:"title,omitempty"`
   358  	Message         string         `json:"message,omitempty"`
   359  	Author          string         `json:"author,omitempty"`
   360  	AvatarURL       string         `json:"avatarUrl,omitempty"`
   361  	Email           string         `json:"email,omitempty"`
   362  }
   363  
   364  func (p *PipelineExecutionSpec) ObjClusterName() string {
   365  	if parts := strings.SplitN(p.ProjectName, ":", 2); len(parts) == 2 {
   366  		return parts[0]
   367  	}
   368  	return ""
   369  }
   370  
   371  type PipelineExecutionStatus struct {
   372  	Conditions []PipelineCondition `json:"conditions,omitempty"`
   373  
   374  	ExecutionState string        `json:"executionState,omitempty"`
   375  	Started        string        `json:"started,omitempty"`
   376  	Ended          string        `json:"ended,omitempty"`
   377  	Stages         []StageStatus `json:"stages,omitempty"`
   378  }
   379  
   380  type StageStatus struct {
   381  	State   string       `json:"state,omitempty"`
   382  	Started string       `json:"started,omitempty"`
   383  	Ended   string       `json:"ended,omitempty"`
   384  	Steps   []StepStatus `json:"steps,omitempty"`
   385  }
   386  
   387  type StepStatus struct {
   388  	State   string `json:"state,omitempty"`
   389  	Started string `json:"started,omitempty"`
   390  	Ended   string `json:"ended,omitempty"`
   391  }
   392  
   393  type SourceCodeCredentialSpec struct {
   394  	ProjectName    string `json:"projectName" norman:"type=reference[project]"`
   395  	SourceCodeType string `json:"sourceCodeType,omitempty" norman:"required,options=github|gitlab|bitbucketcloud|bitbucketserver"`
   396  	UserName       string `json:"userName" norman:"required,type=reference[user]"`
   397  	DisplayName    string `json:"displayName,omitempty" norman:"required"`
   398  	AvatarURL      string `json:"avatarUrl,omitempty"`
   399  	HTMLURL        string `json:"htmlUrl,omitempty"`
   400  	LoginName      string `json:"loginName,omitempty"`
   401  	GitLoginName   string `json:"gitLoginName,omitempty"`
   402  	GitCloneToken  string `json:"gitCloneToken,omitempty" norman:"writeOnly,noupdate"`
   403  	AccessToken    string `json:"accessToken,omitempty" norman:"writeOnly,noupdate"`
   404  	RefreshToken   string `json:"refreshToken,omitempty" norman:"writeOnly,noupdate"`
   405  	Expiry         string `json:"expiry,omitempty"`
   406  }
   407  
   408  func (s *SourceCodeCredentialSpec) ObjClusterName() string {
   409  	if parts := strings.SplitN(s.ProjectName, ":", 2); len(parts) == 2 {
   410  		return parts[0]
   411  	}
   412  	return ""
   413  }
   414  
   415  type SourceCodeCredentialStatus struct {
   416  	Logout bool `json:"logout,omitempty"`
   417  }
   418  
   419  type SourceCodeRepositorySpec struct {
   420  	ProjectName              string   `json:"projectName" norman:"type=reference[project]"`
   421  	SourceCodeType           string   `json:"sourceCodeType,omitempty" norman:"required,options=github|gitlab|bitbucketcloud|bitbucketserver"`
   422  	UserName                 string   `json:"userName" norman:"required,type=reference[user]"`
   423  	SourceCodeCredentialName string   `json:"sourceCodeCredentialName,omitempty" norman:"required,type=reference[sourceCodeCredential]"`
   424  	URL                      string   `json:"url,omitempty"`
   425  	Permissions              RepoPerm `json:"permissions,omitempty"`
   426  	Language                 string   `json:"language,omitempty"`
   427  	DefaultBranch            string   `json:"defaultBranch,omitempty"`
   428  }
   429  
   430  func (s *SourceCodeRepositorySpec) ObjClusterName() string {
   431  	if parts := strings.SplitN(s.ProjectName, ":", 2); len(parts) == 2 {
   432  		return parts[0]
   433  	}
   434  	return ""
   435  }
   436  
   437  type SourceCodeRepositoryStatus struct {
   438  }
   439  
   440  type RepoPerm struct {
   441  	Pull  bool `json:"pull,omitempty"`
   442  	Push  bool `json:"push,omitempty"`
   443  	Admin bool `json:"admin,omitempty"`
   444  }
   445  
   446  type RunPipelineInput struct {
   447  	Branch string `json:"branch,omitempty"`
   448  }
   449  
   450  type AuthAppInput struct {
   451  	InheritGlobal  bool   `json:"inheritGlobal,omitempty"`
   452  	SourceCodeType string `json:"sourceCodeType,omitempty" norman:"type=string,required,options=github|gitlab|bitbucketcloud|bitbucketserver"`
   453  	RedirectURL    string `json:"redirectUrl,omitempty" norman:"type=string"`
   454  	TLS            bool   `json:"tls,omitempty"`
   455  	Host           string `json:"host,omitempty"`
   456  	ClientID       string `json:"clientId,omitempty" norman:"type=string,required"`
   457  	ClientSecret   string `json:"clientSecret,omitempty" norman:"type=string,required"`
   458  	Code           string `json:"code,omitempty" norman:"type=string,required"`
   459  }
   460  
   461  type AuthUserInput struct {
   462  	SourceCodeType string `json:"sourceCodeType,omitempty" norman:"type=string,required,options=github|gitlab|bitbucketcloud|bitbucketserver"`
   463  	RedirectURL    string `json:"redirectUrl,omitempty" norman:"type=string"`
   464  	Code           string `json:"code,omitempty" norman:"type=string,required"`
   465  }
   466  
   467  type PushPipelineConfigInput struct {
   468  	Configs map[string]PipelineConfig `json:"configs,omitempty"`
   469  }
   470  
   471  type PipelineSystemImages struct {
   472  	Jenkins       string `json:"jenkins,omitempty"`
   473  	JenkinsJnlp   string `json:"jenkinsJnlp,omitempty"`
   474  	AlpineGit     string `json:"alpineGit,omitempty"`
   475  	PluginsDocker string `json:"pluginsDocker,omitempty"`
   476  	Minio         string `json:"minio,omitempty"`
   477  	Registry      string `json:"registry,omitempty"`
   478  	RegistryProxy string `json:"registryProxy,omitempty"`
   479  	KubeApply     string `json:"kubeApply,omitempty"`
   480  }
   481  
   482  type OauthApplyInput struct {
   483  	Hostname     string `json:"hostname,omitempty"`
   484  	TLS          bool   `json:"tls,omitempty"`
   485  	RedirectURL  string `json:"redirectUrl,omitempty"`
   486  	ClientID     string `json:"clientId,omitempty"`
   487  	ClientSecret string `json:"clientSecret,omitempty"`
   488  	Code         string `json:"code,omitempty"`
   489  }
   490  
   491  type GithubApplyInput struct {
   492  	OauthApplyInput
   493  	InheritAuth bool `json:"inheritAuth,omitempty"`
   494  }
   495  
   496  type GitlabApplyInput struct {
   497  	OauthApplyInput
   498  }
   499  
   500  type BitbucketCloudApplyInput struct {
   501  	OauthApplyInput
   502  }
   503  
   504  type BitbucketServerApplyInput struct {
   505  	OAuthToken    string `json:"oauthToken,omitempty"`
   506  	OAuthVerifier string `json:"oauthVerifier,omitempty"`
   507  	Hostname      string `json:"hostname,omitempty"`
   508  	TLS           bool   `json:"tls,omitempty"`
   509  	RedirectURL   string `json:"redirectUrl,omitempty"`
   510  }
   511  
   512  type BitbucketServerRequestLoginInput struct {
   513  	Hostname    string `json:"hostname,omitempty"`
   514  	TLS         bool   `json:"tls,omitempty"`
   515  	RedirectURL string `json:"redirectUrl,omitempty"`
   516  }
   517  
   518  type BitbucketServerRequestLoginOutput struct {
   519  	LoginURL string `json:"loginUrl"`
   520  }
   521  
   522  type EnvFrom struct {
   523  	SourceName string `json:"sourceName,omitempty" yaml:"sourceName,omitempty" norman:"type=string,required"`
   524  	SourceKey  string `json:"sourceKey,omitempty" yaml:"sourceKey,omitempty" norman:"type=string,required"`
   525  	TargetKey  string `json:"targetKey,omitempty" yaml:"targetKey,omitempty"`
   526  }
   527  
   528  // UnmarshalYAML unmarshals the constraint.
   529  // So as to support yaml syntax including:
   530  // branch: dev,  branch: ["dev","hotfix"], branch: {include:[],exclude:[]}
   531  func (c *Constraint) UnmarshalYAML(unmarshal func(interface{}) error) error {
   532  	var out1 = struct {
   533  		Include stringorslice
   534  		Exclude stringorslice
   535  	}{}
   536  
   537  	var out2 stringorslice
   538  
   539  	unmarshal(&out1)
   540  	unmarshal(&out2)
   541  
   542  	c.Exclude = out1.Exclude
   543  	c.Include = append(
   544  		out1.Include,
   545  		out2...,
   546  	)
   547  	return nil
   548  }
   549  
   550  type stringorslice []string
   551  
   552  // UnmarshalYAML implements the Unmarshaller interface.
   553  func (s *stringorslice) UnmarshalYAML(unmarshal func(interface{}) error) error {
   554  	var stringType string
   555  	if err := unmarshal(&stringType); err == nil {
   556  		*s = []string{stringType}
   557  		return nil
   558  	}
   559  
   560  	var sliceType []interface{}
   561  	if err := unmarshal(&sliceType); err == nil {
   562  		*s = convert.ToStringSlice(sliceType)
   563  		return nil
   564  	}
   565  
   566  	return errors.New("Failed to unmarshal stringorslice")
   567  }