github.com/drone/runner-go@v1.12.0/pipeline/runtime/type.go (about) 1 // Copyright 2019 Drone.IO Inc. All rights reserved. 2 // Use of this source code is governed by the Polyform License 3 // that can be found in the LICENSE file. 4 5 package runtime 6 7 import ( 8 "context" 9 "io" 10 11 "github.com/drone/drone-go/drone" 12 "github.com/drone/runner-go/manifest" 13 "github.com/drone/runner-go/secret" 14 ) 15 16 type ( 17 // CompilerArgs provides compiler arguments. 18 CompilerArgs struct { 19 // Manifest provides the parsed manifest. 20 Manifest *manifest.Manifest 21 22 // Pipeline provides the parsed pipeline. This pipeline is 23 // the compiler source and is converted to the intermediate 24 // representation by the Compile method. 25 Pipeline manifest.Resource 26 27 // Build provides the compiler with stage information that 28 // is converted to environment variable format and passed to 29 // each pipeline step. It is also used to clone the commit. 30 Build *drone.Build 31 32 // Stage provides the compiler with stage information that 33 // is converted to environment variable format and passed to 34 // each pipeline step. 35 Stage *drone.Stage 36 37 // Repo provides the compiler with repo information. This 38 // repo information is converted to environment variable 39 // format and passed to each pipeline step. It is also used 40 // to clone the repository. 41 Repo *drone.Repo 42 43 // System provides the compiler with system information that 44 // is converted to environment variable format and passed to 45 // each pipeline step. 46 System *drone.System 47 48 // Netrc provides netrc parameters that can be used by the 49 // default clone step to authenticate to the remote 50 // repository. 51 Netrc *drone.Netrc 52 53 // Secret returns a named secret value that can be injected 54 // into the pipeline step. 55 Secret secret.Provider 56 } 57 58 // Compiler compiles the Yaml configuration file to an 59 // intermediate representation optimized for simple execution. 60 Compiler interface { 61 Compile(context.Context, CompilerArgs) Spec 62 } 63 64 // LinterArgs provides linting arguments. 65 LinterArgs struct { 66 Build *drone.Build 67 Repo *drone.Repo 68 } 69 70 // Linter lints the Yaml configuration file and returns an 71 // error if one or more linting rules fails. 72 Linter interface { 73 Lint(context.Context, LinterArgs) error 74 } 75 76 // Engine is the interface that must be implemented by a 77 // pipeline execution engine. 78 Engine interface { 79 // Setup the pipeline environment. 80 Setup(context.Context, Spec) error 81 82 // Destroy the pipeline environment. 83 Destroy(context.Context, Spec) error 84 85 // Run runs the pipeline step. 86 Run(context.Context, Spec, Step, io.Writer) (*State, error) 87 } 88 89 // Spec is an interface that must be implemented by all 90 // pipeline specifications. 91 Spec interface { 92 // StepAt returns the step at the specified index. 93 StepAt(int) Step 94 95 // StepLen returns the number of steps. 96 StepLen() int 97 } 98 99 // Step is an interface that must be implemented by all 100 // pipeline steps. 101 Step interface { 102 // GetName returns the step name. 103 GetName() string 104 105 // GetDependencies returns the step dependencies 106 // used to define an execution graph. 107 GetDependencies() []string 108 109 // GetEnviron returns the step environment variables. 110 GetEnviron() map[string]string 111 112 // SetEnviron updates the step environment variables. 113 SetEnviron(map[string]string) 114 115 // GetErrPolicy returns the step error policy. 116 GetErrPolicy() ErrPolicy 117 118 // GetRunPolicy returns the step run policy. 119 GetRunPolicy() RunPolicy 120 121 // GetSecretAt returns the secret at the specified 122 // index. 123 GetSecretAt(int) Secret 124 125 // GetSecretLen returns the number of secrets. 126 GetSecretLen() int 127 128 // IsDetached returns true if the step is detached 129 // and executed in the background. 130 IsDetached() bool 131 132 // Clone returns a copy of the Step. 133 Clone() Step 134 135 // GetImage returns the image used in the step. 136 GetImage() string 137 } 138 139 // State reports the step state. 140 State struct { 141 // ExitCode returns the exit code of the exited step. 142 ExitCode int 143 144 // GetExited reports whether the step has exited. 145 Exited bool 146 147 // OOMKilled reports whether the step has been 148 // killed by the process manager. 149 OOMKilled bool 150 } 151 152 // Secret is an interface that must be implemented 153 // by all pipeline secrets. 154 Secret interface { 155 // GetName returns the secret name. 156 GetName() string 157 158 // GetValue returns the secret value. 159 GetValue() string 160 161 // IsMasked returns true if the secret value should 162 // be masked. If true the secret value is masked in 163 // the logs. 164 IsMasked() bool 165 } 166 )