github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/schema/v1beta2/config.go (about) 1 /* 2 Copyright 2019 The Skaffold Authors 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1beta2 18 19 import ( 20 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util" 21 ) 22 23 // !!! WARNING !!! This config version is already released, please DO NOT MODIFY the structs in this file. 24 const Version string = "skaffold/v1beta2" 25 26 // NewSkaffoldConfig creates a SkaffoldConfig 27 func NewSkaffoldConfig() util.VersionedConfig { 28 return new(SkaffoldConfig) 29 } 30 31 type SkaffoldConfig struct { 32 APIVersion string `yaml:"apiVersion"` 33 Kind string `yaml:"kind"` 34 35 Build BuildConfig `yaml:"build,omitempty"` 36 Test TestConfig `yaml:"test,omitempty"` 37 Deploy DeployConfig `yaml:"deploy,omitempty"` 38 Profiles []Profile `yaml:"profiles,omitempty"` 39 } 40 41 func (c *SkaffoldConfig) GetVersion() string { 42 return c.APIVersion 43 } 44 45 // BuildConfig contains all the configuration for the build steps 46 type BuildConfig struct { 47 Artifacts []*Artifact `yaml:"artifacts,omitempty"` 48 TagPolicy TagPolicy `yaml:"tagPolicy,omitempty"` 49 BuildType `yaml:",inline"` 50 } 51 52 // TagPolicy contains all the configuration for the tagging step 53 type TagPolicy struct { 54 GitTagger *GitTagger `yaml:"gitCommit,omitempty" yamltags:"oneOf=tag"` 55 ShaTagger *ShaTagger `yaml:"sha256,omitempty" yamltags:"oneOf=tag"` 56 EnvTemplateTagger *EnvTemplateTagger `yaml:"envTemplate,omitempty" yamltags:"oneOf=tag"` 57 DateTimeTagger *DateTimeTagger `yaml:"dateTime,omitempty" yamltags:"oneOf=tag"` 58 } 59 60 // ShaTagger contains the configuration for the SHA tagger. 61 type ShaTagger struct{} 62 63 // GitTagger contains the configuration for the git tagger. 64 type GitTagger struct{} 65 66 // EnvTemplateTagger contains the configuration for the envTemplate tagger. 67 type EnvTemplateTagger struct { 68 Template string `yaml:"template,omitempty"` 69 } 70 71 // DateTimeTagger contains the configuration for the DateTime tagger. 72 type DateTimeTagger struct { 73 Format string `yaml:"format,omitempty"` 74 TimeZone string `yaml:"timezone,omitempty"` 75 } 76 77 // BuildType contains the specific implementation and parameters needed 78 // for the build step. Only one field should be populated. 79 type BuildType struct { 80 LocalBuild *LocalBuild `yaml:"local,omitempty" yamltags:"oneOf=build"` 81 GoogleCloudBuild *GoogleCloudBuild `yaml:"googleCloudBuild,omitempty" yamltags:"oneOf=build"` 82 KanikoBuild *KanikoBuild `yaml:"kaniko,omitempty" yamltags:"oneOf=build"` 83 } 84 85 // LocalBuild contains the fields needed to do a build on the local docker daemon 86 // and optionally push to a repository. 87 type LocalBuild struct { 88 Push *bool `yaml:"push,omitempty"` 89 UseDockerCLI bool `yaml:"useDockerCLI,omitempty"` 90 UseBuildkit bool `yaml:"useBuildkit,omitempty"` 91 } 92 93 // GoogleCloudBuild contains the fields needed to do a remote build on 94 // Google Cloud Build. 95 type GoogleCloudBuild struct { 96 ProjectID string `yaml:"projectId,omitempty"` 97 DiskSizeGb int64 `yaml:"diskSizeGb,omitempty"` 98 MachineType string `yaml:"machineType,omitempty"` 99 Timeout string `yaml:"timeout,omitempty"` 100 DockerImage string `yaml:"dockerImage,omitempty"` 101 } 102 103 // LocalDir represents the local directory kaniko build context 104 type LocalDir struct { 105 } 106 107 // KanikoBuildContext contains the different fields available to specify 108 // a kaniko build context 109 type KanikoBuildContext struct { 110 GCSBucket string `yaml:"gcsBucket,omitempty" yamltags:"oneOf=buildContext"` 111 LocalDir *LocalDir `yaml:"localDir,omitempty" yamltags:"oneOf=buildContext"` 112 } 113 114 // KanikoCache contains fields related to kaniko caching 115 type KanikoCache struct { 116 Repo string `yaml:"repo,omitempty"` 117 } 118 119 // KanikoBuild contains the fields needed to do a on-cluster build using 120 // the kaniko image 121 type KanikoBuild struct { 122 BuildContext *KanikoBuildContext `yaml:"buildContext,omitempty"` 123 Cache *KanikoCache `yaml:"cache,omitempty"` 124 AdditionalFlags []string `yaml:"flags,omitempty"` 125 PullSecret string `yaml:"pullSecret,omitempty"` 126 PullSecretName string `yaml:"pullSecretName,omitempty"` 127 Namespace string `yaml:"namespace,omitempty"` 128 Timeout string `yaml:"timeout,omitempty"` 129 Image string `yaml:"image,omitempty"` 130 } 131 132 type TestConfig []*TestCase 133 134 // TestCase is a struct containing all the specified test 135 // configuration for an image. 136 type TestCase struct { 137 ImageName string `yaml:"image"` 138 StructureTests []string `yaml:"structureTests,omitempty"` 139 } 140 141 // DeployConfig contains all the configuration needed by the deploy steps 142 type DeployConfig struct { 143 DeployType `yaml:",inline"` 144 } 145 146 // DeployType contains the specific implementation and parameters needed 147 // for the deploy step. Only one field should be populated. 148 type DeployType struct { 149 HelmDeploy *HelmDeploy `yaml:"helm,omitempty" yamltags:"oneOf=deploy"` 150 KubectlDeploy *KubectlDeploy `yaml:"kubectl,omitempty" yamltags:"oneOf=deploy"` 151 KustomizeDeploy *KustomizeDeploy `yaml:"kustomize,omitempty" yamltags:"oneOf=deploy"` 152 } 153 154 // KubectlDeploy contains the configuration needed for deploying with `kubectl apply` 155 type KubectlDeploy struct { 156 Manifests []string `yaml:"manifests,omitempty"` 157 RemoteManifests []string `yaml:"remoteManifests,omitempty"` 158 Flags KubectlFlags `yaml:"flags,omitempty"` 159 } 160 161 // KubectlFlags describes additional options flags that are passed on the command 162 // line to kubectl either on every command (Global), on creations (Apply) 163 // or deletions (Delete). 164 type KubectlFlags struct { 165 Global []string `yaml:"global,omitempty"` 166 Apply []string `yaml:"apply,omitempty"` 167 Delete []string `yaml:"delete,omitempty"` 168 } 169 170 // HelmDeploy contains the configuration needed for deploying with helm 171 type HelmDeploy struct { 172 Releases []HelmRelease `yaml:"releases,omitempty"` 173 } 174 175 // KustomizeDeploy contains the configuration needed for deploying with kustomize. 176 type KustomizeDeploy struct { 177 KustomizePath string `yaml:"path,omitempty"` 178 Flags KubectlFlags `yaml:"flags,omitempty"` 179 } 180 181 type HelmRelease struct { 182 Name string `yaml:"name,omitempty"` 183 ChartPath string `yaml:"chartPath,omitempty"` 184 ValuesFiles []string `yaml:"valuesFiles,omitempty"` 185 Values map[string]string `yaml:"values,omitempty,omitempty"` 186 Namespace string `yaml:"namespace,omitempty"` 187 Version string `yaml:"version,omitempty"` 188 SetValues map[string]string `yaml:"setValues,omitempty"` 189 SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` 190 Wait bool `yaml:"wait,omitempty"` 191 RecreatePods bool `yaml:"recreatePods,omitempty"` 192 Overrides util.HelmOverrides `yaml:"overrides,omitempty"` 193 Packaged *HelmPackaged `yaml:"packaged,omitempty"` 194 ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` 195 } 196 197 // HelmPackaged represents parameters for packaging helm chart. 198 type HelmPackaged struct { 199 // Version sets the version on the chart to this semver version. 200 Version string `yaml:"version,omitempty"` 201 202 // AppVersion set the appVersion on the chart to this version 203 AppVersion string `yaml:"appVersion,omitempty"` 204 } 205 206 type HelmImageStrategy struct { 207 HelmImageConfig `yaml:",inline"` 208 } 209 210 type HelmImageConfig struct { 211 HelmFQNConfig *HelmFQNConfig `yaml:"fqn,omitempty" yamltags:"oneOf=helmImageStrategy"` 212 HelmConventionConfig *HelmConventionConfig `yaml:"helm,omitempty" yamltags:"oneOf=helmImageStrategy"` 213 } 214 215 // HelmFQNConfig represents image config to use the FullyQualifiedImageName as param to set 216 type HelmFQNConfig struct { 217 Property string `yaml:"property,omitempty"` 218 } 219 220 // HelmConventionConfig represents image config in the syntax of image.repository and image.tag 221 type HelmConventionConfig struct { 222 } 223 224 // Artifact represents items that need to be built, along with the context in which 225 // they should be built. 226 type Artifact struct { 227 ImageName string `yaml:"image,omitempty"` 228 Workspace string `yaml:"context,omitempty"` 229 Sync map[string]string `yaml:"sync,omitempty"` 230 ArtifactType `yaml:",inline"` 231 } 232 233 // Profile is additional configuration that overrides default 234 // configuration when it is activated. 235 type Profile struct { 236 Name string `yaml:"name,omitempty"` 237 Build BuildConfig `yaml:"build,omitempty"` 238 Test TestConfig `yaml:"test,omitempty"` 239 Deploy DeployConfig `yaml:"deploy,omitempty"` 240 } 241 242 type ArtifactType struct { 243 DockerArtifact *DockerArtifact `yaml:"docker,omitempty" yamltags:"oneOf=artifact"` 244 BazelArtifact *BazelArtifact `yaml:"bazel,omitempty" yamltags:"oneOf=artifact"` 245 JibMavenArtifact *JibMavenArtifact `yaml:"jibMaven,omitempty" yamltags:"oneOf=artifact"` 246 JibGradleArtifact *JibGradleArtifact `yaml:"jibGradle,omitempty" yamltags:"oneOf=artifact"` 247 } 248 249 // DockerArtifact describes an artifact built from a Dockerfile, 250 // usually using `docker build`. 251 type DockerArtifact struct { 252 DockerfilePath string `yaml:"dockerfile,omitempty"` 253 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 254 CacheFrom []string `yaml:"cacheFrom,omitempty"` 255 Target string `yaml:"target,omitempty"` 256 } 257 258 // BazelArtifact describes an artifact built with Bazel. 259 type BazelArtifact struct { 260 BuildTarget string `yaml:"target,omitempty"` 261 BuildArgs []string `yaml:"args,omitempty"` 262 } 263 264 type JibMavenArtifact struct { 265 // Only multi-module 266 Module string `yaml:"module"` 267 Profile string `yaml:"profile"` 268 } 269 270 type JibGradleArtifact struct { 271 // Only multi-module 272 Project string `yaml:"project"` 273 }