github.com/drone/go-convert@v0.0.0-20240307072510-6bd371c65e61/convert/harness/yaml/pipeline.go (about)

     1  // Copyright 2022 Harness, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package yaml
    16  
    17  type (
    18  	// Config defines resource configuration.
    19  	Config struct {
    20  		Pipeline Pipeline `json:"pipeline" yaml:"pipeline"`
    21  	}
    22  
    23  	// Pipeline defines a pipeline.
    24  	Pipeline struct {
    25  		ID        string      `json:"identifier,omitempty"        yaml:"identifier,omitempty"`
    26  		Name      string      `json:"name,omitempty"              yaml:"name,omitempty"`
    27  		Desc      string      `json:"description,omitempty"       yaml:"description,omitempty"`
    28  		Account   string      `json:"accountIdentifier,omitempty" yaml:"accountIdentifier,omitempty"`
    29  		Project   string      `json:"projectIdentifier,omitempty" yaml:"projectIdentifier,omitempty"`
    30  		Org       string      `json:"orgIdentifier,omitempty"     yaml:"orgIdentifier,omitempty"`
    31  		Props     Properties  `json:"properties,omitempty"        yaml:"properties,omitempty"`
    32  		Stages    []*Stages   `json:"stages,omitempty"            yaml:"stages"`
    33  		Variables []*Variable `json:"variables,omitempty"         yaml:"variables,omitempty"`
    34  	}
    35  
    36  	// Properties defines pipeline properties.
    37  	Properties struct {
    38  		CI CI `json:"ci,omitempty" yaml:"ci"`
    39  	}
    40  
    41  	// CI defines CI pipeline properties.
    42  	CI struct {
    43  		Codebase Codebase `json:"codebase,omitempty" yaml:"codebase,omitempty"`
    44  	}
    45  
    46  	// Cache defines the cache settings.
    47  	Cache struct {
    48  		Enabled bool     `json:"enabled,omitempty" yaml:"enabled,omitempty"`
    49  		Key     string   `json:"key,omitempty"     yaml:"key,omitempty"`
    50  		Paths   []string `json:"paths,omitempty"   yaml:"paths,omitempty"`
    51  	}
    52  
    53  	// Codebase defines a codebase.
    54  	Codebase struct {
    55  		Name  string `json:"repoName,omitempty"     yaml:"repoName,omitempty"`
    56  		Conn  string `json:"connectorRef,omitempty" yaml:"connectorRef,omitempty"`
    57  		Build string `json:"build,omitempty"        yaml:"build,omitempty"` // branch|tag
    58  	}
    59  
    60  	Stages struct {
    61  		Stage    *Stage    `json:"stage,omitempty"    yaml:"stage,omitempty"`
    62  		Parallel []*Stages `json:"parallel,omitempty" yaml:"parallel,omitempty"`
    63  	}
    64  
    65  	// Infrastructure provides pipeline infrastructure.
    66  	Infrastructure struct {
    67  		Type string     `json:"type,omitempty"          yaml:"type,omitempty"`
    68  		From string     `json:"useFromStage,omitempty"  yaml:"useFromStage,omitempty"` // this is also weird
    69  		Spec *InfraSpec `json:"spec,omitempty"          yaml:"spec,omitempty"`
    70  	}
    71  
    72  	// InfraSpec describes pipeline infastructure.
    73  	InfraSpec struct {
    74  		Namespace string `json:"namespace,omitempty"    yaml:"namespace,omitempty"`
    75  		Conn      string `json:"connectorRef,omitempty" yaml:"connectorRef,omitempty"`
    76  	}
    77  
    78  	Platform struct {
    79  		OS   string `json:"os,omitempty"   yaml:"os,omitempty"`
    80  		Arch string `json:"arch,omitempty" yaml:"arch,omitempty"`
    81  	}
    82  
    83  	Runtime struct {
    84  		Type string      `json:"type,omitempty"   yaml:"type,omitempty"`
    85  		Spec interface{} `json:"spec,omitempty"   yaml:"spec,omitempty"`
    86  	}
    87  
    88  	Variable struct {
    89  		Name  string `json:"name,omitempty"  yaml:"name,omitempty"`
    90  		Type  string `json:"type,omitempty"  yaml:"type,omitempty"` // Secret|Text
    91  		Value string `json:"value,omitempty" yaml:"value,omitempty"`
    92  	}
    93  
    94  	Execution struct {
    95  		Steps []*Steps `json:"steps,omitempty" yaml:"steps,omitempty"` // Un-necessary
    96  	}
    97  
    98  	Steps struct {
    99  		Step     *Step    `json:"step,omitempty" yaml:"step,omitempty"` // Un-necessary
   100  		Parallel []*Steps `json:"parallel,omitempty" yaml:"parallel,omitempty"`
   101  	}
   102  
   103  	Report struct {
   104  		Type string       `json:"type" yaml:"type,omitempty"` // JUnit|JUnit
   105  		Spec *ReportJunit `json:"spec" yaml:"spec,omitempty"` // TODO
   106  	}
   107  
   108  	ReportJunit struct {
   109  		Paths []string `json:"paths" yaml:"paths,omitempty"`
   110  	}
   111  
   112  	Service struct {
   113  		ID   string       `json:"identifier,omitempty"   yaml:"identifier,omitempty"`
   114  		Name string       `json:"name,omitempty"         yaml:"name,omitempty"`
   115  		Type string       `json:"type,omitempty"         yaml:"type,omitempty"` // Service
   116  		Desc string       `json:"description,omitempty"  yaml:"description,omitempty"`
   117  		Spec *ServiceSpec `json:"spec,omitempty"         yaml:"spec,omitempty"`
   118  	}
   119  
   120  	ServiceSpec struct {
   121  		Env        map[string]string `json:"envVariables,omitempty"   yaml:"envVariables,omitempty"`
   122  		Entrypoint []string          `json:"entrypoint,omitempty"     yaml:"entrypoint,omitempty"`
   123  		Args       []string          `json:"args,omitempty"           yaml:"args,omitempty"`
   124  		Conn       string            `json:"connectorRef,omitempty"   yaml:"connectorRef,omitempty"`
   125  		Image      string            `json:"image,omitempty"          yaml:"image,omitempty"`
   126  		Resources  *Resources        `json:"resources,omitempty"      yaml:"resources,omitempty"`
   127  	}
   128  
   129  	Resources struct {
   130  		Limits Limits `json:"limits,omitempty" yaml:"limits,omitempty"`
   131  	}
   132  
   133  	Limits struct {
   134  		Memory BytesSize `json:"memory,omitempty" yaml:"memory,omitempty"`
   135  		CPU    MilliSize `json:"cpu,omitempty"    yaml:"cpu,omitempty"` // TODO
   136  	}
   137  )