github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/schema/v1beta12/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 v1beta12 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/v1beta12" 25 26 // NewSkaffoldConfig creates a SkaffoldConfig 27 func NewSkaffoldConfig() util.VersionedConfig { 28 return new(SkaffoldConfig) 29 } 30 31 // SkaffoldConfig holds the fields parsed from the Skaffold configuration file (skaffold.yaml). 32 type SkaffoldConfig struct { 33 // APIVersion is the version of the configuration. 34 APIVersion string `yaml:"apiVersion" yamltags:"required"` 35 36 // Kind is always `Config`. Defaults to `Config`. 37 Kind string `yaml:"kind" yamltags:"required"` 38 39 // Pipeline defines the Build/Test/Deploy phases. 40 Pipeline `yaml:",inline"` 41 42 // Profiles *beta* can override be used to `build`, `test` or `deploy` configuration. 43 Profiles []Profile `yaml:"profiles,omitempty"` 44 } 45 46 // Pipeline describes a Skaffold pipeline. 47 type Pipeline struct { 48 // Build describes how images are built. 49 Build BuildConfig `yaml:"build,omitempty"` 50 51 // Test describes how images are tested. 52 Test []*TestCase `yaml:"test,omitempty"` 53 54 // Deploy describes how images are deployed. 55 Deploy DeployConfig `yaml:"deploy,omitempty"` 56 57 // PortForward describes user defined resources to port-forward. 58 PortForward []*PortForwardResource `yaml:"portForward,omitempty"` 59 } 60 61 func (c *SkaffoldConfig) GetVersion() string { 62 return c.APIVersion 63 } 64 65 // ResourceType describes the Kubernetes resource types used for port forwarding. 66 type ResourceType string 67 68 // PortForwardResource describes a resource to port forward. 69 type PortForwardResource struct { 70 // Type is the Kubernetes type that should be port forwarded. 71 // Acceptable resource types include: `Service`, `Pod` and Controller resource type that has a pod spec: `ReplicaSet`, `ReplicationController`, `Deployment`, `StatefulSet`, `DaemonSet`, `Job`, `CronJob`. 72 Type ResourceType `yaml:"resourceType,omitempty"` 73 74 // Name is the name of the Kubernetes resource to port forward. 75 Name string `yaml:"resourceName,omitempty"` 76 77 // Namespace is the namespace of the resource to port forward. 78 Namespace string `yaml:"namespace,omitempty"` 79 80 // Port is the resource port that will be forwarded. 81 Port int32 `yaml:"port,omitempty"` 82 83 // LocalPort is the local port to forward to. If the port is unavailable, Skaffold will choose a random open port to forward to. *Optional*. 84 LocalPort int32 `yaml:"localPort,omitempty"` 85 } 86 87 // BuildConfig contains all the configuration for the build steps. 88 type BuildConfig struct { 89 // Artifacts lists the images you're going to be building. 90 Artifacts []*Artifact `yaml:"artifacts,omitempty"` 91 92 // InsecureRegistries is a list of registries declared by the user to be insecure. 93 // These registries will be connected to via HTTP instead of HTTPS. 94 InsecureRegistries []string `yaml:"insecureRegistries,omitempty"` 95 96 // TagPolicy *beta* determines how images are tagged. 97 // A few strategies are provided here, although you most likely won't need to care! 98 // If not specified, it defaults to `gitCommit: {variant: Tags}`. 99 TagPolicy TagPolicy `yaml:"tagPolicy,omitempty"` 100 101 BuildType `yaml:",inline"` 102 } 103 104 // TagPolicy contains all the configuration for the tagging step. 105 type TagPolicy struct { 106 // GitTagger *beta* tags images with the git tag or commit of the artifact's workspace. 107 GitTagger *GitTagger `yaml:"gitCommit,omitempty" yamltags:"oneOf=tag"` 108 109 // ShaTagger *beta* tags images with their sha256 digest. 110 ShaTagger *ShaTagger `yaml:"sha256,omitempty" yamltags:"oneOf=tag"` 111 112 // EnvTemplateTagger *beta* tags images with a configurable template string. 113 EnvTemplateTagger *EnvTemplateTagger `yaml:"envTemplate,omitempty" yamltags:"oneOf=tag"` 114 115 // DateTimeTagger *beta* tags images with the build timestamp. 116 DateTimeTagger *DateTimeTagger `yaml:"dateTime,omitempty" yamltags:"oneOf=tag"` 117 } 118 119 // ShaTagger *beta* tags images with their sha256 digest. 120 type ShaTagger struct{} 121 122 // GitTagger *beta* tags images with the git tag or commit of the artifact's workspace. 123 type GitTagger struct { 124 // Variant determines the behavior of the git tagger. Valid variants are 125 // `Tags` (default): use git tags or fall back to abbreviated commit hash. 126 // `CommitSha`: use the full git commit sha. 127 // `AbbrevCommitSha`: use the abbreviated git commit sha. 128 // `TreeSha`: use the full tree hash of the artifact workingdir. 129 // `AbbrevTreeSha`: use the abbreviated tree hash of the artifact workingdir. 130 Variant string `yaml:"variant,omitempty"` 131 } 132 133 // EnvTemplateTagger *beta* tags images with a configurable template string. 134 type EnvTemplateTagger struct { 135 // Template used to produce the image name and tag. 136 // See golang [text/template](https://golang.org/pkg/text/template/). 137 // The template is executed against the current environment, 138 // with those variables injected: 139 // IMAGE_NAME | Name of the image being built, as supplied in the artifacts section. 140 // For example: `{{.RELEASE}}-{{.IMAGE_NAME}}`. 141 Template string `yaml:"template,omitempty" yamltags:"required"` 142 } 143 144 // DateTimeTagger *beta* tags images with the build timestamp. 145 type DateTimeTagger struct { 146 // Format formats the date and time. 147 // See [#Time.Format](https://golang.org/pkg/time/#Time.Format). 148 // Defaults to `2006-01-02_15-04-05.999_MST`. 149 Format string `yaml:"format,omitempty"` 150 151 // TimeZone sets the timezone for the date and time. 152 // See [Time.LoadLocation](https://golang.org/pkg/time/#Time.LoadLocation). 153 // Defaults to the local timezone. 154 TimeZone string `yaml:"timezone,omitempty"` 155 } 156 157 // BuildType contains the specific implementation and parameters needed 158 // for the build step. Only one field should be populated. 159 type BuildType struct { 160 // LocalBuild *beta* describes how to do a build on the local docker daemon 161 // and optionally push to a repository. 162 LocalBuild *LocalBuild `yaml:"local,omitempty" yamltags:"oneOf=build"` 163 164 // GoogleCloudBuild *beta* describes how to do a remote build on 165 // [Google Cloud Build](https://cloud.google.com/cloud-build/). 166 GoogleCloudBuild *GoogleCloudBuild `yaml:"googleCloudBuild,omitempty" yamltags:"oneOf=build"` 167 168 // Cluster *beta* describes how to do an on-cluster build. 169 Cluster *ClusterDetails `yaml:"cluster,omitempty" yamltags:"oneOf=build"` 170 } 171 172 // LocalBuild *beta* describes how to do a build on the local docker daemon 173 // and optionally push to a repository. 174 type LocalBuild struct { 175 // Push should images be pushed to a registry. 176 // If not specified, images are pushed only if the current Kubernetes context 177 // connects to a remote cluster. 178 Push *bool `yaml:"push,omitempty"` 179 180 // UseDockerCLI use `docker` command-line interface instead of Docker Engine APIs. 181 UseDockerCLI bool `yaml:"useDockerCLI,omitempty"` 182 183 // UseBuildkit use BuildKit to build Docker images. If unspecified, uses the Docker default. 184 UseBuildkit *bool `yaml:"useBuildkit,omitempty"` 185 } 186 187 // GoogleCloudBuild *beta* describes how to do a remote build on 188 // [Google Cloud Build](https://cloud.google.com/cloud-build/docs/). 189 // Docker and Jib artifacts can be built on Cloud Build. The `projectId` needs 190 // to be provided and the currently logged in user should be given permissions to trigger 191 // new builds. 192 type GoogleCloudBuild struct { 193 // ProjectID is the ID of your Cloud Platform Project. 194 // If it is not provided, Skaffold will guess it from the image name. 195 // For example, given the artifact image name `gcr.io/myproject/image`, Skaffold 196 // will use the `myproject` GCP project. 197 ProjectID string `yaml:"projectId,omitempty"` 198 199 // DiskSizeGb is the disk size of the VM that runs the build. 200 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#buildoptions). 201 DiskSizeGb int64 `yaml:"diskSizeGb,omitempty"` 202 203 // MachineType is the type of the VM that runs the build. 204 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#buildoptions). 205 MachineType string `yaml:"machineType,omitempty"` 206 207 // Timeout is the amount of time (in seconds) that this build should be allowed to run. 208 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#resource-build). 209 Timeout string `yaml:"timeout,omitempty"` 210 211 // DockerImage is the image that runs a Docker build. 212 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 213 // Defaults to `gcr.io/cloud-builders/docker`. 214 DockerImage string `yaml:"dockerImage,omitempty"` 215 216 // MavenImage is the image that runs a Maven build. 217 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 218 // Defaults to `gcr.io/cloud-builders/mvn`. 219 MavenImage string `yaml:"mavenImage,omitempty"` 220 221 // GradleImage is the image that runs a Gradle build. 222 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 223 // Defaults to `gcr.io/cloud-builders/gradle`. 224 GradleImage string `yaml:"gradleImage,omitempty"` 225 } 226 227 // LocalDir configures how Kaniko mounts sources directly via an `emptyDir` volume. 228 type LocalDir struct { 229 // InitImage is the image used to run init container which mounts kaniko context. 230 InitImage string `yaml:"initImage,omitempty"` 231 } 232 233 // KanikoBuildContext contains the different fields available to specify 234 // a Kaniko build context. 235 type KanikoBuildContext struct { 236 // GCSBucket is the GCS bucket to which sources are uploaded. 237 // Kaniko will need access to that bucket to download the sources. 238 GCSBucket string `yaml:"gcsBucket,omitempty" yamltags:"oneOf=buildContext"` 239 240 // LocalDir configures how Kaniko mounts sources directly via an `emptyDir` volume. 241 LocalDir *LocalDir `yaml:"localDir,omitempty" yamltags:"oneOf=buildContext"` 242 } 243 244 // KanikoCache configures Kaniko caching. If a cache is specified, Kaniko will 245 // use a remote cache which will speed up builds. 246 type KanikoCache struct { 247 // Repo is a remote repository to store cached layers. If none is specified, one will be 248 // inferred from the image name. See [Kaniko Caching](https://github.com/GoogleContainerTools/kaniko#caching). 249 Repo string `yaml:"repo,omitempty"` 250 // HostPath specifies a path on the host that is mounted to each pod as read only cache volume containing base images. 251 // If set, must exist on each node and prepopulated with kaniko-warmer. 252 HostPath string `yaml:"hostPath,omitempty"` 253 } 254 255 // ClusterDetails *beta* describes how to do an on-cluster build. 256 type ClusterDetails struct { 257 // PullSecret is the path to the Google Cloud service account secret key file. 258 PullSecret string `yaml:"pullSecret,omitempty"` 259 260 // PullSecretName is the name of the Kubernetes secret for pulling the files 261 // from the build context and pushing the final image. If given, the secret needs to 262 // contain the Google Cloud service account secret key under the key `kaniko-secret`. 263 // Defaults to `kaniko-secret`. 264 PullSecretName string `yaml:"pullSecretName,omitempty"` 265 266 // Namespace is the Kubernetes namespace. 267 // Defaults to current namespace in Kubernetes configuration. 268 Namespace string `yaml:"namespace,omitempty"` 269 270 // Timeout is the amount of time (in seconds) that this build is allowed to run. 271 // Defaults to 20 minutes (`20m`). 272 Timeout string `yaml:"timeout,omitempty"` 273 274 // DockerConfig describes how to mount the local Docker configuration into a pod. 275 DockerConfig *DockerConfig `yaml:"dockerConfig,omitempty"` 276 277 // Resources define the resource requirements for the kaniko pod. 278 Resources *ResourceRequirements `yaml:"resources,omitempty"` 279 } 280 281 // DockerConfig contains information about the docker `config.json` to mount. 282 type DockerConfig struct { 283 // Path is the path to the docker `config.json`. 284 Path string `yaml:"path,omitempty"` 285 286 // SecretName is the Kubernetes secret that contains the `config.json` Docker configuration. 287 // Note that the expected secret type is not 'kubernetes.io/dockerconfigjson' but 'Opaque'. 288 SecretName string `yaml:"secretName,omitempty"` 289 } 290 291 // ResourceRequirements describes the resource requirements for the kaniko pod. 292 type ResourceRequirements struct { 293 // Requests [resource requests](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) for the Kaniko pod. 294 Requests *ResourceRequirement `yaml:"requests,omitempty"` 295 296 // Limits [resource limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container) for the Kaniko pod. 297 Limits *ResourceRequirement `yaml:"limits,omitempty"` 298 } 299 300 // ResourceRequirement stores the CPU/Memory requirements for the pod. 301 type ResourceRequirement struct { 302 // CPU the number cores to be used. 303 // For example: `2`, `2.0` or `200m`. 304 CPU string `yaml:"cpu,omitempty"` 305 306 // Memory the amount of memory to allocate to the pod. 307 // For example: `1Gi` or `1000Mi`. 308 Memory string `yaml:"memory,omitempty"` 309 } 310 311 // TestCase is a list of structure tests to run on images that Skaffold builds. 312 type TestCase struct { 313 // ImageName is the artifact on which to run those tests. 314 // For example: `gcr.io/k8s-skaffold/example`. 315 ImageName string `yaml:"image" yamltags:"required"` 316 317 // StructureTests lists the [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) 318 // to run on that artifact. 319 // For example: `["./test/*"]`. 320 StructureTests []string `yaml:"structureTests,omitempty"` 321 } 322 323 // DeployConfig contains all the configuration needed by the deploy steps. 324 type DeployConfig struct { 325 DeployType `yaml:",inline"` 326 } 327 328 // DeployType contains the specific implementation and parameters needed 329 // for the deploy step. Only one field should be populated. 330 type DeployType struct { 331 // HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. 332 HelmDeploy *HelmDeploy `yaml:"helm,omitempty" yamltags:"oneOf=deploy"` 333 334 // KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. 335 // You'll need a `kubectl` CLI version installed that's compatible with your cluster. 336 KubectlDeploy *KubectlDeploy `yaml:"kubectl,omitempty" yamltags:"oneOf=deploy"` 337 338 // KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. 339 KustomizeDeploy *KustomizeDeploy `yaml:"kustomize,omitempty" yamltags:"oneOf=deploy"` 340 } 341 342 // KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. 343 // You'll need a `kubectl` CLI version installed that's compatible with your cluster. 344 type KubectlDeploy struct { 345 // Manifests lists the Kubernetes yaml or json manifests. 346 // Defaults to `["k8s/*.yaml"]`. 347 Manifests []string `yaml:"manifests,omitempty"` 348 349 // RemoteManifests lists Kubernetes manifests in remote clusters. 350 RemoteManifests []string `yaml:"remoteManifests,omitempty"` 351 352 // Flags are additional flags passed to `kubectl`. 353 Flags KubectlFlags `yaml:"flags,omitempty"` 354 } 355 356 // KubectlFlags are additional flags passed on the command 357 // line to kubectl either on every command (Global), on creations (Apply) 358 // or deletions (Delete). 359 type KubectlFlags struct { 360 // Global are additional flags passed on every command. 361 Global []string `yaml:"global,omitempty"` 362 363 // Apply are additional flags passed on creations (`kubectl apply`). 364 Apply []string `yaml:"apply,omitempty"` 365 366 // Delete are additional flags passed on deletions (`kubectl delete`). 367 Delete []string `yaml:"delete,omitempty"` 368 } 369 370 // HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. 371 type HelmDeploy struct { 372 // Releases is a list of Helm releases. 373 Releases []HelmRelease `yaml:"releases,omitempty" yamltags:"required"` 374 375 // Flags are additional option flags that are passed on the command 376 // line to `helm`. 377 Flags HelmDeployFlags `yaml:"flags,omitempty"` 378 } 379 380 // HelmDeployFlags are additional option flags that are passed on the command 381 // line to `helm`. 382 type HelmDeployFlags struct { 383 // Global are additional flags passed on every command. 384 Global []string `yaml:"global,omitempty"` 385 386 // Install are additional flags passed to (`helm install`). 387 Install []string `yaml:"install,omitempty"` 388 389 // Upgrade are additional flags passed to (`helm upgrade`). 390 Upgrade []string `yaml:"upgrade,omitempty"` 391 } 392 393 // KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. 394 type KustomizeDeploy struct { 395 // KustomizePath is the path to Kustomization files. 396 // Defaults to `.`. 397 KustomizePath string `yaml:"path,omitempty"` 398 399 // Flags are additional flags passed to `kubectl`. 400 Flags KubectlFlags `yaml:"flags,omitempty"` 401 } 402 403 // HelmRelease describes a helm release to be deployed. 404 type HelmRelease struct { 405 // Name is the name of the Helm release. 406 Name string `yaml:"name,omitempty" yamltags:"required"` 407 408 // ChartPath is the path to the Helm chart. 409 ChartPath string `yaml:"chartPath,omitempty" yamltags:"required"` 410 411 // ValuesFiles are the paths to the Helm `values` files. 412 ValuesFiles []string `yaml:"valuesFiles,omitempty"` 413 414 // Values are key-value pairs supplementing the Helm `values` file. 415 Values map[string]string `yaml:"values,omitempty,omitempty"` 416 417 // Namespace is the Kubernetes namespace. 418 Namespace string `yaml:"namespace,omitempty"` 419 420 // Version is the version of the chart. 421 Version string `yaml:"version,omitempty"` 422 423 // SetValues are key-value pairs. 424 // If present, Skaffold will send `--set` flag to Helm CLI and append all pairs after the flag. 425 SetValues map[string]string `yaml:"setValues,omitempty"` 426 427 // SetValueTemplates are key-value pairs. 428 // If present, Skaffold will try to parse the value part of each key-value pair using 429 // environment variables in the system, then send `--set` flag to Helm CLI and append 430 // all parsed pairs after the flag. 431 SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` 432 433 // Wait if `true`, Skaffold will send `--wait` flag to Helm CLI. 434 // Defaults to `false`. 435 Wait bool `yaml:"wait,omitempty"` 436 437 // RecreatePods if `true`, Skaffold will send `--recreate-pods` flag to Helm CLI. 438 // Defaults to `false`. 439 RecreatePods bool `yaml:"recreatePods,omitempty"` 440 441 // SkipBuildDependencies should build dependencies be skipped. 442 SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"` 443 444 // UseHelmSecrets instructs skaffold to use secrets plugin on deployment. 445 UseHelmSecrets bool `yaml:"useHelmSecrets,omitempty"` 446 447 // Remote specifies whether the chart path is remote, or exists on the host filesystem. 448 // `remote: true` implies `skipBuildDependencies: true`. 449 Remote bool `yaml:"remote,omitempty"` 450 451 // Overrides are key-value pairs. 452 // If present, Skaffold will build a Helm `values` file that overrides 453 // the original and use it to call Helm CLI (`--f` flag). 454 Overrides util.HelmOverrides `yaml:"overrides,omitempty"` 455 456 // Packaged parameters for packaging helm chart (`helm package`). 457 Packaged *HelmPackaged `yaml:"packaged,omitempty"` 458 459 // ImageStrategy adds image configurations to the Helm `values` file. 460 ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` 461 } 462 463 // HelmPackaged parameters for packaging helm chart (`helm package`). 464 type HelmPackaged struct { 465 // Version sets the `version` on the chart to this semver version. 466 Version string `yaml:"version,omitempty"` 467 468 // AppVersion sets the `appVersion` on the chart to this version. 469 AppVersion string `yaml:"appVersion,omitempty"` 470 } 471 472 // HelmImageStrategy adds image configurations to the Helm `values` file. 473 type HelmImageStrategy struct { 474 HelmImageConfig `yaml:",inline"` 475 } 476 477 // HelmImageConfig describes an image configuration. 478 type HelmImageConfig struct { 479 // HelmFQNConfig is the image configuration uses the syntax `IMAGE-NAME=IMAGE-REPOSITORY:IMAGE-TAG`. 480 HelmFQNConfig *HelmFQNConfig `yaml:"fqn,omitempty" yamltags:"oneOf=helmImageStrategy"` 481 482 // HelmConventionConfig is the image configuration uses the syntax `IMAGE-NAME.repository=IMAGE-REPOSITORY, IMAGE-NAME.tag=IMAGE-TAG`. 483 HelmConventionConfig *HelmConventionConfig `yaml:"helm,omitempty" yamltags:"oneOf=helmImageStrategy"` 484 } 485 486 // HelmFQNConfig is the image config to use the FullyQualifiedImageName as param to set. 487 type HelmFQNConfig struct { 488 // Property defines the image config. 489 Property string `yaml:"property,omitempty"` 490 } 491 492 // HelmConventionConfig is the image config in the syntax of image.repository and image.tag. 493 type HelmConventionConfig struct { 494 } 495 496 // Artifact are the items that need to be built, along with the context in which 497 // they should be built. 498 type Artifact struct { 499 // ImageName is the name of the image to be built. 500 // For example: `gcr.io/k8s-skaffold/example`. 501 ImageName string `yaml:"image,omitempty" yamltags:"required"` 502 503 // Workspace is the directory containing the artifact's sources. 504 // Defaults to `.`. 505 Workspace string `yaml:"context,omitempty"` 506 507 // Sync *alpha* lists local files synced to pods instead 508 // of triggering an image build when modified. 509 Sync *Sync `yaml:"sync,omitempty"` 510 511 // ArtifactType describes how to build an artifact. 512 ArtifactType `yaml:",inline"` 513 } 514 515 // Sync *alpha* specifies what files to sync into the container. 516 // This is a list of sync rules indicating the intent to sync for source files. 517 type Sync struct { 518 // Manual lists manual sync rules indicating the source and destination. 519 Manual []*SyncRule `yaml:"manual,omitempty" yamltags:"oneOf=sync"` 520 } 521 522 // SyncRule specifies which local files to sync to remote folders. 523 type SyncRule struct { 524 // Src is a glob pattern to match local paths against. 525 // Directories should be delimited by `/` on all platforms. 526 // For example: `"css/**/*.css"`. 527 Src string `yaml:"src,omitempty" yamltags:"required"` 528 529 // Dest is the destination path in the container where the files should be synced to. 530 // For example: `"app/"` 531 Dest string `yaml:"dest,omitempty" yamltags:"required"` 532 533 // Strip specifies the path prefix to remove from the source path when 534 // transplanting the files into the destination folder. 535 // For example: `"css/"` 536 Strip string `yaml:"strip,omitempty"` 537 } 538 539 // Profile *beta* profiles are used to override any `build`, `test` or `deploy` configuration. 540 type Profile struct { 541 // Name is a unique profile name. 542 // For example: `profile-prod`. 543 Name string `yaml:"name,omitempty" yamltags:"required"` 544 545 // Pipeline contains the definitions to replace the default skaffold pipeline. 546 Pipeline `yaml:",inline"` 547 548 // Patches lists patches applied to the configuration. 549 // Patches use the JSON patch notation. 550 Patches []JSONPatch `yaml:"patches,omitempty"` 551 552 // Activation criteria by which a profile can be auto-activated. 553 // The profile is auto-activated if any one of the activations are triggered. 554 // An activation is triggered if all of the criteria (env, kubeContext, command) are triggered. 555 Activation []Activation `yaml:"activation,omitempty"` 556 } 557 558 // JSONPatch patch to be applied by a profile. 559 type JSONPatch struct { 560 // Op is the operation carried by the patch: `add`, `remove`, `replace`, `move`, `copy` or `test`. 561 // Defaults to `replace`. 562 Op string `yaml:"op,omitempty"` 563 564 // Path is the position in the yaml where the operation takes place. 565 // For example, this targets the `dockerfile` of the first artifact built. 566 // For example: `/build/artifacts/0/docker/dockerfile`. 567 Path string `yaml:"path,omitempty" yamltags:"required"` 568 569 // From is the source position in the yaml, used for `copy` or `move` operations. 570 From string `yaml:"from,omitempty"` 571 572 // Value is the value to apply. Can be any portion of yaml. 573 Value *util.YamlpatchNode `yaml:"value,omitempty"` 574 } 575 576 // Activation criteria by which a profile is auto-activated. 577 type Activation struct { 578 // Env is a `key=value` pair. The profile is auto-activated if an Environment 579 // Variable `key` has value `value`. 580 // For example: `ENV=production`. 581 Env string `yaml:"env,omitempty"` 582 583 // KubeContext is a Kubernetes context for which the profile is auto-activated. 584 // For example: `minikube`. 585 KubeContext string `yaml:"kubeContext,omitempty"` 586 587 // Command is a Skaffold command for which the profile is auto-activated. 588 // For example: `dev`. 589 Command string `yaml:"command,omitempty"` 590 } 591 592 // ArtifactType describes how to build an artifact. 593 type ArtifactType struct { 594 // DockerArtifact *beta* describes an artifact built from a Dockerfile. 595 DockerArtifact *DockerArtifact `yaml:"docker,omitempty" yamltags:"oneOf=artifact"` 596 597 // BazelArtifact *beta* requires bazel CLI to be installed and the sources to 598 // contain [Bazel](https://bazel.build/) configuration files. 599 BazelArtifact *BazelArtifact `yaml:"bazel,omitempty" yamltags:"oneOf=artifact"` 600 601 // JibMavenArtifact *alpha* builds images using the 602 // [Jib plugin for Maven](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin). 603 JibMavenArtifact *JibMavenArtifact `yaml:"jibMaven,omitempty" yamltags:"oneOf=artifact"` 604 605 // JibGradleArtifact *alpha* builds images using the 606 // [Jib plugin for Gradle](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin). 607 JibGradleArtifact *JibGradleArtifact `yaml:"jibGradle,omitempty" yamltags:"oneOf=artifact"` 608 609 // KanikoArtifact *alpha* builds images using [kaniko](https://github.com/GoogleContainerTools/kaniko). 610 KanikoArtifact *KanikoArtifact `yaml:"kaniko,omitempty" yamltags:"oneOf=artifact"` 611 612 // CustomArtifact *alpha* builds images using a custom build script written by the user. 613 CustomArtifact *CustomArtifact `yaml:"custom,omitempty" yamltags:"oneOf=artifact"` 614 } 615 616 // CustomArtifact *alpha* describes an artifact built from a custom build script 617 // written by the user. It can be used to build images with builders that aren't directly integrated with skaffold. 618 type CustomArtifact struct { 619 // BuildCommand is the command executed to build the image. 620 BuildCommand string `yaml:"buildCommand,omitempty"` 621 // Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. 622 Dependencies *CustomDependencies `yaml:"dependencies,omitempty"` 623 } 624 625 // CustomDependencies *alpha* is used to specify dependencies for an artifact built by a custom build script. 626 // Either `dockerfile` or `paths` should be specified for file watching to work as expected. 627 type CustomDependencies struct { 628 // Dockerfile should be set if the artifact is built from a Dockerfile, from which skaffold can determine dependencies. 629 Dockerfile *DockerfileDependency `yaml:"dockerfile,omitempty" yamltags:"oneOf=dependency"` 630 // Command represents a custom command that skaffold executes to obtain dependencies. The output of this command *must* be a valid JSON array. 631 Command string `yaml:"command,omitempty" yamltags:"oneOf=dependency"` 632 // Paths should be set to the file dependencies for this artifact, so that the skaffold file watcher knows when to rebuild and perform file synchronization. 633 Paths []string `yaml:"paths,omitempty" yamltags:"oneOf=dependency"` 634 // Ignore specifies the paths that should be ignored by skaffold's file watcher. If a file exists in both `paths` and in `ignore`, it will be ignored, and will be excluded from both rebuilds and file synchronization. 635 // Will only work in conjunction with `paths`. 636 Ignore []string `yaml:"ignore,omitempty"` 637 } 638 639 // DockerfileDependency *alpha* is used to specify a custom build artifact that is built from a Dockerfile. This allows skaffold to determine dependencies from the Dockerfile. 640 type DockerfileDependency struct { 641 // Path locates the Dockerfile relative to workspace. 642 Path string `yaml:"path,omitempty"` 643 644 // BuildArgs are arguments passed to the docker build. 645 // It also accepts environment variables via the go template syntax. 646 // For example: `{"key1": "value1", "key2": "value2", "key3": "{{.ENV_VARIABLE}}"}`. 647 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 648 } 649 650 // KanikoArtifact *alpha* describes an artifact built from a Dockerfile, 651 // with kaniko. 652 type KanikoArtifact struct { 653 // AdditionalFlags are additional flags to be passed to Kaniko command line. 654 // See [Kaniko Additional Flags](https://github.com/GoogleContainerTools/kaniko#additional-flags). 655 // Deprecated - instead the named, unique fields should be used, e.g. `buildArgs`, `cache`, `target`. 656 AdditionalFlags []string `yaml:"flags,omitempty"` 657 658 // DockerfilePath locates the Dockerfile relative to workspace. 659 // Defaults to `Dockerfile`. 660 DockerfilePath string `yaml:"dockerfile,omitempty"` 661 662 // Target is the Dockerfile target name to build. 663 Target string `yaml:"target,omitempty"` 664 665 // BuildArgs are arguments passed to the docker build. 666 // It also accepts environment variables via the go template syntax. 667 // For example: `{"key1": "value1", "key2": "value2", "key3": "{{.ENV_VARIABLE}}"}`. 668 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 669 670 // BuildContext is where the build context for this artifact resides. 671 BuildContext *KanikoBuildContext `yaml:"buildContext,omitempty"` 672 673 // Image is the Docker image used by the Kaniko pod. 674 // Defaults to the latest released version of `gcr.io/kaniko-project/executor`. 675 Image string `yaml:"image,omitempty"` 676 677 // Cache configures Kaniko caching. If a cache is specified, Kaniko will 678 // use a remote cache which will speed up builds. 679 Cache *KanikoCache `yaml:"cache,omitempty"` 680 } 681 682 // DockerArtifact *beta* describes an artifact built from a Dockerfile, 683 // usually using `docker build`. 684 type DockerArtifact struct { 685 // DockerfilePath locates the Dockerfile relative to workspace. 686 // Defaults to `Dockerfile`. 687 DockerfilePath string `yaml:"dockerfile,omitempty"` 688 689 // Target is the Dockerfile target name to build. 690 Target string `yaml:"target,omitempty"` 691 692 // BuildArgs are arguments passed to the docker build. 693 // For example: `{"key1": "value1", "key2": "value2"}`. 694 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 695 696 // NetworkMode is passed through to docker and overrides the 697 // network configuration of docker builder. If unset, use whatever 698 // is configured in the underlying docker daemon. Valid modes are 699 // `host`: use the host's networking stack. 700 // `bridge`: use the bridged network configuration. 701 // `none`: no networking in the container. 702 NetworkMode string `yaml:"network,omitempty"` 703 704 // CacheFrom lists the Docker images used as cache sources. 705 // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. 706 CacheFrom []string `yaml:"cacheFrom,omitempty"` 707 708 // NoCache used to pass in --no-cache to docker build to prevent caching. 709 NoCache bool `yaml:"noCache,omitempty"` 710 } 711 712 // BazelArtifact *beta* describes an artifact built with [Bazel](https://bazel.build/). 713 type BazelArtifact struct { 714 // BuildTarget is the `bazel build` target to run. 715 // For example: `//:skaffold_example.tar`. 716 BuildTarget string `yaml:"target,omitempty" yamltags:"required"` 717 718 // BuildArgs are additional args to pass to `bazel build`. 719 // For example: `["-flag", "--otherflag"]`. 720 BuildArgs []string `yaml:"args,omitempty"` 721 } 722 723 // JibMavenArtifact *alpha* builds images using the 724 // [Jib plugin for Maven](https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin). 725 type JibMavenArtifact struct { 726 // Module selects which Maven module to build, for a multi module project. 727 Module string `yaml:"module"` 728 729 // Profile selects which Maven profile to activate. 730 Profile string `yaml:"profile"` 731 732 // Flags are additional build flags passed to Maven. 733 // For example: `["-x", "-DskipTests"]`. 734 Flags []string `yaml:"args,omitempty"` 735 } 736 737 // JibGradleArtifact *alpha* builds images using the 738 // [Jib plugin for Gradle](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin). 739 type JibGradleArtifact struct { 740 // Project selects which Gradle project to build. 741 Project string `yaml:"project"` 742 743 // Flags are additional build flags passed to Gradle. 744 // For example: `["--no-build-cache"]`. 745 Flags []string `yaml:"args,omitempty"` 746 }