github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/schema/v2beta18/config.go (about) 1 /* 2 Copyright 2021 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 v2beta18 18 19 import ( 20 "encoding/json" 21 22 v1 "k8s.io/api/core/v1" 23 "sigs.k8s.io/kustomize/kyaml/yaml" 24 25 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util" 26 ) 27 28 // !!! WARNING !!! This config version is already released, please DO NOT MODIFY the structs in this file. 29 const Version string = "skaffold/v2beta18" 30 31 // NewSkaffoldConfig creates a SkaffoldConfig 32 func NewSkaffoldConfig() util.VersionedConfig { 33 return new(SkaffoldConfig) 34 } 35 36 // SkaffoldConfig holds the fields parsed from the Skaffold configuration file (skaffold.yaml). 37 type SkaffoldConfig struct { 38 // APIVersion is the version of the configuration. 39 APIVersion string `yaml:"apiVersion" yamltags:"required"` 40 41 // Kind is always `Config`. Defaults to `Config`. 42 Kind string `yaml:"kind" yamltags:"required"` 43 44 // Metadata holds additional information about the config. 45 Metadata Metadata `yaml:"metadata,omitempty"` 46 47 // Dependencies describes a list of other required configs for the current config. 48 Dependencies []ConfigDependency `yaml:"requires,omitempty"` 49 50 // Pipeline defines the Build/Test/Deploy phases. 51 Pipeline `yaml:",inline"` 52 53 // Profiles *beta* can override be used to `build`, `test` or `deploy` configuration. 54 Profiles []Profile `yaml:"profiles,omitempty"` 55 } 56 57 // Metadata holds an optional name of the project. 58 type Metadata struct { 59 // Name is an identifier for the project. 60 Name string `yaml:"name,omitempty"` 61 } 62 63 // Pipeline describes a Skaffold pipeline. 64 type Pipeline struct { 65 // Build describes how images are built. 66 Build BuildConfig `yaml:"build,omitempty"` 67 68 // Test describes how images are tested. 69 Test []*TestCase `yaml:"test,omitempty"` 70 71 // Deploy describes how images are deployed. 72 Deploy DeployConfig `yaml:"deploy,omitempty"` 73 74 // PortForward describes user defined resources to port-forward. 75 PortForward []*PortForwardResource `yaml:"portForward,omitempty"` 76 } 77 78 // GitInfo contains information on the origin of skaffold configurations cloned from a git repository. 79 type GitInfo struct { 80 // Repo is the git repository the package should be cloned from. e.g. `https://github.com/GoogleContainerTools/skaffold.git`. 81 Repo string `yaml:"repo" yamltags:"required"` 82 83 // Path is the relative path from the repo root to the skaffold configuration file. eg. `getting-started/skaffold.yaml`. 84 Path string `yaml:"path,omitempty"` 85 86 // Ref is the git ref the package should be cloned from. eg. `master` or `main`. 87 Ref string `yaml:"ref,omitempty"` 88 89 // Sync when set to `true` will reset the cached repository to the latest commit from remote on every run. To use the cached repository with uncommitted changes or unpushed commits, it needs to be set to `false`. 90 Sync *bool `yaml:"sync,omitempty"` 91 } 92 93 // ConfigDependency describes a dependency on another skaffold configuration. 94 type ConfigDependency struct { 95 // Names includes specific named configs within the file path. If empty, then all configs in the file are included. 96 Names []string `yaml:"configs,omitempty"` 97 98 // Path describes the path to the file containing the required configs. 99 Path string `yaml:"path,omitempty" skaffold:"filepath" yamltags:"oneOf=paths"` 100 101 // GitRepo describes a remote git repository containing the required configs. 102 GitRepo *GitInfo `yaml:"git,omitempty" yamltags:"oneOf=paths"` 103 104 // ActiveProfiles describes the list of profiles to activate when resolving the required configs. These profiles must exist in the imported config. 105 ActiveProfiles []ProfileDependency `yaml:"activeProfiles,omitempty"` 106 } 107 108 // ProfileDependency describes a mapping from referenced config profiles to the current config profiles. 109 // If the current config is activated with a profile in this mapping then the dependency configs are also activated with the corresponding mapped profiles. 110 type ProfileDependency struct { 111 // Name describes name of the profile to activate in the dependency config. It should exist in the dependency config. 112 Name string `yaml:"name" yamltags:"required"` 113 114 // ActivatedBy describes a list of profiles in the current config that when activated will also activate the named profile in the dependency config. If empty then the named profile is always activated. 115 ActivatedBy []string `yaml:"activatedBy,omitempty"` 116 } 117 118 func (c *SkaffoldConfig) GetVersion() string { 119 return c.APIVersion 120 } 121 122 // ResourceType describes the Kubernetes resource types used for port forwarding. 123 type ResourceType string 124 125 // PortForwardResource describes a resource to port forward. 126 type PortForwardResource struct { 127 // Type is the Kubernetes type that should be port forwarded. 128 // Acceptable resource types include: `Service`, `Pod` and Controller resource type that has a pod spec: `ReplicaSet`, `ReplicationController`, `Deployment`, `StatefulSet`, `DaemonSet`, `Job`, `CronJob`. 129 Type ResourceType `yaml:"resourceType,omitempty"` 130 131 // Name is the name of the Kubernetes resource to port forward. 132 Name string `yaml:"resourceName,omitempty"` 133 134 // Namespace is the namespace of the resource to port forward. 135 Namespace string `yaml:"namespace,omitempty"` 136 137 // Port is the resource port that will be forwarded. 138 Port util.IntOrString `yaml:"port,omitempty"` 139 140 // Address is the local address to bind to. Defaults to the loopback address 127.0.0.1. 141 Address string `yaml:"address,omitempty"` 142 143 // LocalPort is the local port to forward to. If the port is unavailable, Skaffold will choose a random open port to forward to. *Optional*. 144 LocalPort int `yaml:"localPort,omitempty"` 145 } 146 147 // BuildConfig contains all the configuration for the build steps. 148 type BuildConfig struct { 149 // Artifacts lists the images you're going to be building. 150 Artifacts []*Artifact `yaml:"artifacts,omitempty"` 151 152 // InsecureRegistries is a list of registries declared by the user to be insecure. 153 // These registries will be connected to via HTTP instead of HTTPS. 154 InsecureRegistries []string `yaml:"insecureRegistries,omitempty"` 155 156 // TagPolicy *beta* determines how images are tagged. 157 // A few strategies are provided here, although you most likely won't need to care! 158 // If not specified, it defaults to `gitCommit: {variant: Tags}`. 159 TagPolicy TagPolicy `yaml:"tagPolicy,omitempty"` 160 161 BuildType `yaml:",inline"` 162 } 163 164 // TagPolicy contains all the configuration for the tagging step. 165 type TagPolicy struct { 166 // GitTagger *beta* tags images with the git tag or commit of the artifact's workspace. 167 GitTagger *GitTagger `yaml:"gitCommit,omitempty" yamltags:"oneOf=tag"` 168 169 // ShaTagger *beta* tags images with their sha256 digest. 170 ShaTagger *ShaTagger `yaml:"sha256,omitempty" yamltags:"oneOf=tag"` 171 172 // EnvTemplateTagger *beta* tags images with a configurable template string. 173 EnvTemplateTagger *EnvTemplateTagger `yaml:"envTemplate,omitempty" yamltags:"oneOf=tag"` 174 175 // DateTimeTagger *beta* tags images with the build timestamp. 176 DateTimeTagger *DateTimeTagger `yaml:"dateTime,omitempty" yamltags:"oneOf=tag"` 177 178 // CustomTemplateTagger *beta* tags images with a configurable template string *composed of other taggers*. 179 CustomTemplateTagger *CustomTemplateTagger `yaml:"customTemplate,omitempty" yamltags:"oneOf=tag"` 180 181 // InputDigest *beta* tags images with their sha256 digest of their content. 182 InputDigest *InputDigest `yaml:"inputDigest,omitempty" yamltags:"oneOf=tag"` 183 } 184 185 // ShaTagger *beta* tags images with their sha256 digest. 186 type ShaTagger struct{} 187 188 // InputDigest *beta* tags hashes the image content. 189 type InputDigest struct{} 190 191 // GitTagger *beta* tags images with the git tag or commit of the artifact's workspace. 192 type GitTagger struct { 193 // Variant determines the behavior of the git tagger. Valid variants are: 194 // `Tags` (default): use git tags or fall back to abbreviated commit hash. 195 // `CommitSha`: use the full git commit sha. 196 // `AbbrevCommitSha`: use the abbreviated git commit sha. 197 // `TreeSha`: use the full tree hash of the artifact workingdir. 198 // `AbbrevTreeSha`: use the abbreviated tree hash of the artifact workingdir. 199 Variant string `yaml:"variant,omitempty"` 200 201 // Prefix adds a fixed prefix to the tag. 202 Prefix string `yaml:"prefix,omitempty"` 203 204 // IgnoreChanges specifies whether to omit the `-dirty` postfix if there are uncommitted changes. 205 IgnoreChanges bool `yaml:"ignoreChanges,omitempty"` 206 } 207 208 // EnvTemplateTagger *beta* tags images with a configurable template string. 209 type EnvTemplateTagger struct { 210 // Template used to produce the image name and tag. 211 // See golang [text/template](https://golang.org/pkg/text/template/). 212 // The template is executed against the current environment, 213 // with those variables injected. 214 // For example: `{{.RELEASE}}`. 215 Template string `yaml:"template,omitempty" yamltags:"required"` 216 } 217 218 // DateTimeTagger *beta* tags images with the build timestamp. 219 type DateTimeTagger struct { 220 // Format formats the date and time. 221 // See [#Time.Format](https://golang.org/pkg/time/#Time.Format). 222 // Defaults to `2006-01-02_15-04-05.999_MST`. 223 Format string `yaml:"format,omitempty"` 224 225 // TimeZone sets the timezone for the date and time. 226 // See [Time.LoadLocation](https://golang.org/pkg/time/#Time.LoadLocation). 227 // Defaults to the local timezone. 228 TimeZone string `yaml:"timezone,omitempty"` 229 } 230 231 // CustomTemplateTagger *beta* tags images with a configurable template string. 232 type CustomTemplateTagger struct { 233 // Template used to produce the image name and tag. 234 // See golang [text/template](https://golang.org/pkg/text/template/). 235 // The template is executed against the provided components with those variables injected. 236 // For example: `{{.DATE}}` where DATE references a TaggerComponent. 237 Template string `yaml:"template,omitempty" yamltags:"required"` 238 239 // Components lists TaggerComponents that the template (see field above) can be executed against. 240 Components []TaggerComponent `yaml:"components,omitempty"` 241 } 242 243 // TaggerComponent *beta* is a component of CustomTemplateTagger. 244 type TaggerComponent struct { 245 // Name is an identifier for the component. 246 Name string `yaml:"name,omitempty"` 247 248 // Component is a tagging strategy to be used in CustomTemplateTagger. 249 Component TagPolicy `yaml:",inline" yamltags:"skipTrim"` 250 } 251 252 // BuildType contains the specific implementation and parameters needed 253 // for the build step. Only one field should be populated. 254 type BuildType struct { 255 // LocalBuild *beta* describes how to do a build on the local docker daemon 256 // and optionally push to a repository. 257 LocalBuild *LocalBuild `yaml:"local,omitempty" yamltags:"oneOf=build"` 258 259 // GoogleCloudBuild *beta* describes how to do a remote build on 260 // [Google Cloud Build](https://cloud.google.com/cloud-build/). 261 GoogleCloudBuild *GoogleCloudBuild `yaml:"googleCloudBuild,omitempty" yamltags:"oneOf=build"` 262 263 // Cluster *beta* describes how to do an on-cluster build. 264 Cluster *ClusterDetails `yaml:"cluster,omitempty" yamltags:"oneOf=build"` 265 } 266 267 // LocalBuild *beta* describes how to do a build on the local docker daemon 268 // and optionally push to a repository. 269 type LocalBuild struct { 270 // Push should images be pushed to a registry. 271 // If not specified, images are pushed only if the current Kubernetes context 272 // connects to a remote cluster. 273 Push *bool `yaml:"push,omitempty"` 274 275 // TryImportMissing whether to attempt to import artifacts from 276 // Docker (either a local or remote registry) if not in the cache. 277 TryImportMissing bool `yaml:"tryImportMissing,omitempty"` 278 279 // UseDockerCLI use `docker` command-line interface instead of Docker Engine APIs. 280 UseDockerCLI bool `yaml:"useDockerCLI,omitempty"` 281 282 // UseBuildkit use BuildKit to build Docker images. If unspecified, uses the Docker default. 283 UseBuildkit *bool `yaml:"useBuildkit,omitempty"` 284 285 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 286 // Defaults to `1`. 287 Concurrency *int `yaml:"concurrency,omitempty"` 288 } 289 290 // GoogleCloudBuild *beta* describes how to do a remote build on 291 // [Google Cloud Build](https://cloud.google.com/cloud-build/docs/). 292 // Docker and Jib artifacts can be built on Cloud Build. The `projectId` needs 293 // to be provided and the currently logged in user should be given permissions to trigger 294 // new builds. 295 type GoogleCloudBuild struct { 296 // ProjectID is the ID of your Cloud Platform Project. 297 // If it is not provided, Skaffold will guess it from the image name. 298 // For example, given the artifact image name `gcr.io/myproject/image`, Skaffold 299 // will use the `myproject` GCP project. 300 ProjectID string `yaml:"projectId,omitempty"` 301 302 // DiskSizeGb is the disk size of the VM that runs the build. 303 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#buildoptions). 304 DiskSizeGb int64 `yaml:"diskSizeGb,omitempty"` 305 306 // MachineType is the type of the VM that runs the build. 307 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#buildoptions). 308 MachineType string `yaml:"machineType,omitempty"` 309 310 // Timeout is the amount of time (in seconds) that this build should be allowed to run. 311 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#resource-build). 312 Timeout string `yaml:"timeout,omitempty"` 313 314 // Logging specifies the logging mode. 315 // Valid modes are: 316 // `LOGGING_UNSPECIFIED`: The service determines the logging mode. 317 // `LEGACY`: Stackdriver logging and Cloud Storage logging are enabled (default). 318 // `GCS_ONLY`: Only Cloud Storage logging is enabled. 319 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#loggingmode). 320 Logging string `yaml:"logging,omitempty"` 321 322 // LogStreamingOption specifies the behavior when writing build logs to Google Cloud Storage. 323 // Valid options are: 324 // `STREAM_DEFAULT`: Service may automatically determine build log streaming behavior. 325 // `STREAM_ON`: Build logs should be streamed to Google Cloud Storage. 326 // `STREAM_OFF`: Build logs should not be streamed to Google Cloud Storage; they will be written when the build is completed. 327 // See [Cloud Build Reference](https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds#logstreamingoption). 328 LogStreamingOption string `yaml:"logStreamingOption,omitempty"` 329 330 // DockerImage is the image that runs a Docker build. 331 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 332 // Defaults to `gcr.io/cloud-builders/docker`. 333 DockerImage string `yaml:"dockerImage,omitempty"` 334 335 // KanikoImage is the image that runs a Kaniko build. 336 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 337 // Defaults to `gcr.io/kaniko-project/executor`. 338 KanikoImage string `yaml:"kanikoImage,omitempty"` 339 340 // MavenImage is the image that runs a Maven build. 341 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 342 // Defaults to `gcr.io/cloud-builders/mvn`. 343 MavenImage string `yaml:"mavenImage,omitempty"` 344 345 // GradleImage is the image that runs a Gradle build. 346 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 347 // Defaults to `gcr.io/cloud-builders/gradle`. 348 GradleImage string `yaml:"gradleImage,omitempty"` 349 350 // PackImage is the image that runs a Cloud Native Buildpacks build. 351 // See [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders). 352 // Defaults to `gcr.io/k8s-skaffold/pack`. 353 PackImage string `yaml:"packImage,omitempty"` 354 355 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 356 // Defaults to `0`. 357 Concurrency int `yaml:"concurrency,omitempty"` 358 359 // WorkerPool configures a pool of workers to run the build. 360 WorkerPool string `yaml:"workerPool,omitempty"` 361 } 362 363 // KanikoCache configures Kaniko caching. If a cache is specified, Kaniko will 364 // use a remote cache which will speed up builds. 365 type KanikoCache struct { 366 // Repo is a remote repository to store cached layers. If none is specified, one will be 367 // inferred from the image name. See [Kaniko Caching](https://github.com/GoogleContainerTools/kaniko#caching). 368 Repo string `yaml:"repo,omitempty"` 369 // HostPath specifies a path on the host that is mounted to each pod as read only cache volume containing base images. 370 // If set, must exist on each node and prepopulated with kaniko-warmer. 371 HostPath string `yaml:"hostPath,omitempty"` 372 // TTL Cache timeout in hours. 373 TTL string `yaml:"ttl,omitempty"` 374 } 375 376 // ClusterDetails *beta* describes how to do an on-cluster build. 377 type ClusterDetails struct { 378 // HTTPProxy for kaniko pod. 379 HTTPProxy string `yaml:"HTTP_PROXY,omitempty"` 380 381 // HTTPSProxy for kaniko pod. 382 HTTPSProxy string `yaml:"HTTPS_PROXY,omitempty"` 383 384 // PullSecretPath is the path to the Google Cloud service account secret key file. 385 PullSecretPath string `yaml:"pullSecretPath,omitempty"` 386 387 // PullSecretName is the name of the Kubernetes secret for pulling base images 388 // and pushing the final image. If given, the secret needs to contain the Google Cloud 389 // service account secret key under the key `kaniko-secret`. 390 // Defaults to `kaniko-secret`. 391 PullSecretName string `yaml:"pullSecretName,omitempty"` 392 393 // PullSecretMountPath is the path the pull secret will be mounted at within the running container. 394 PullSecretMountPath string `yaml:"pullSecretMountPath,omitempty"` 395 396 // Namespace is the Kubernetes namespace. 397 // Defaults to current namespace in Kubernetes configuration. 398 Namespace string `yaml:"namespace,omitempty"` 399 400 // Timeout is the amount of time (in seconds) that this build is allowed to run. 401 // Defaults to 20 minutes (`20m`). 402 Timeout string `yaml:"timeout,omitempty"` 403 404 // DockerConfig describes how to mount the local Docker configuration into a pod. 405 DockerConfig *DockerConfig `yaml:"dockerConfig,omitempty"` 406 407 // ServiceAccountName describes the Kubernetes service account to use for the pod. 408 // Defaults to 'default'. 409 ServiceAccountName string `yaml:"serviceAccount,omitempty"` 410 411 // Tolerations describes the Kubernetes tolerations for the pod. 412 Tolerations []v1.Toleration `yaml:"tolerations,omitempty"` 413 414 // NodeSelector describes the Kubernetes node selector for the pod. 415 NodeSelector map[string]string `yaml:"nodeSelector,omitempty"` 416 417 // Annotations describes the Kubernetes annotations for the pod. 418 Annotations map[string]string `yaml:"annotations,omitempty"` 419 420 // RunAsUser defines the UID to request for running the container. 421 // If omitted, no SecurityContext will be specified for the pod and will therefore be inherited 422 // from the service account. 423 RunAsUser *int64 `yaml:"runAsUser,omitempty"` 424 425 // Resources define the resource requirements for the kaniko pod. 426 Resources *ResourceRequirements `yaml:"resources,omitempty"` 427 428 // Concurrency is how many artifacts can be built concurrently. 0 means "no-limit". 429 // Defaults to `0`. 430 Concurrency int `yaml:"concurrency,omitempty"` 431 432 // Volumes defines container mounts for ConfigMap and Secret resources. 433 Volumes []v1.Volume `yaml:"volumes,omitempty"` 434 435 // RandomPullSecret adds a random UUID postfix to the default name of the pull secret to facilitate parallel builds, e.g. kaniko-secretdocker-cfgfd154022-c761-416f-8eb3-cf8258450b85. 436 RandomPullSecret bool `yaml:"randomPullSecret,omitempty"` 437 438 // RandomDockerConfigSecret adds a random UUID postfix to the default name of the docker secret to facilitate parallel builds, e.g. docker-cfgfd154022-c761-416f-8eb3-cf8258450b85. 439 RandomDockerConfigSecret bool `yaml:"randomDockerConfigSecret,omitempty"` 440 } 441 442 // DockerConfig contains information about the docker `config.json` to mount. 443 type DockerConfig struct { 444 // Path is the path to the docker `config.json`. 445 Path string `yaml:"path,omitempty"` 446 447 // SecretName is the Kubernetes secret that contains the `config.json` Docker configuration. 448 // Note that the expected secret type is not 'kubernetes.io/dockerconfigjson' but 'Opaque'. 449 SecretName string `yaml:"secretName,omitempty"` 450 } 451 452 // ResourceRequirements describes the resource requirements for the kaniko pod. 453 type ResourceRequirements struct { 454 // 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. 455 Requests *ResourceRequirement `yaml:"requests,omitempty"` 456 457 // 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. 458 Limits *ResourceRequirement `yaml:"limits,omitempty"` 459 } 460 461 // ResourceRequirement stores the CPU/Memory requirements for the pod. 462 type ResourceRequirement struct { 463 // CPU the number cores to be used. 464 // For example: `2`, `2.0` or `200m`. 465 CPU string `yaml:"cpu,omitempty"` 466 467 // Memory the amount of memory to allocate to the pod. 468 // For example: `1Gi` or `1000Mi`. 469 Memory string `yaml:"memory,omitempty"` 470 471 // EphemeralStorage the amount of Ephemeral storage to allocate to the pod. 472 // For example: `1Gi` or `1000Mi`. 473 EphemeralStorage string `yaml:"ephemeralStorage,omitempty"` 474 475 // ResourceStorage the amount of resource storage to allocate to the pod. 476 // For example: `1Gi` or `1000Mi`. 477 ResourceStorage string `yaml:"resourceStorage,omitempty"` 478 } 479 480 // TestCase is a list of tests to run on images that Skaffold builds. 481 type TestCase struct { 482 // ImageName is the artifact on which to run those tests. 483 // For example: `gcr.io/k8s-skaffold/example`. 484 ImageName string `yaml:"image" yamltags:"required"` 485 486 // Workspace is the directory containing the test sources. 487 // Defaults to `.`. 488 Workspace string `yaml:"context,omitempty" skaffold:"filepath"` 489 490 // CustomTests lists the set of custom tests to run after an artifact is built. 491 CustomTests []CustomTest `yaml:"custom,omitempty"` 492 493 // StructureTests lists the [Container Structure Tests](https://github.com/GoogleContainerTools/container-structure-test) 494 // to run on that artifact. 495 // For example: `["./test/*"]`. 496 StructureTests []string `yaml:"structureTests,omitempty" skaffold:"filepath"` 497 498 // StructureTestArgs lists additional configuration arguments passed to `container-structure-test` binary. 499 // For example: `["--driver=tar", "--no-color", "-q"]`. 500 StructureTestArgs []string `yaml:"structureTestsArgs,omitempty"` 501 } 502 503 // DeployConfig contains all the configuration needed by the deploy steps. 504 type DeployConfig struct { 505 DeployType `yaml:",inline"` 506 507 // StatusCheck *beta* enables waiting for deployments to stabilize. 508 StatusCheck *bool `yaml:"statusCheck,omitempty"` 509 510 // StatusCheckDeadlineSeconds *beta* is the deadline for deployments to stabilize in seconds. 511 StatusCheckDeadlineSeconds int `yaml:"statusCheckDeadlineSeconds,omitempty"` 512 513 // KubeContext is the Kubernetes context that Skaffold should deploy to. 514 // For example: `minikube`. 515 KubeContext string `yaml:"kubeContext,omitempty"` 516 517 // Logs configures how container logs are printed as a result of a deployment. 518 Logs LogsConfig `yaml:"logs,omitempty"` 519 } 520 521 // DeployType contains the specific implementation and parameters needed 522 // for the deploy step. All three deployer types can be used at the same 523 // time for hybrid workflows. 524 type DeployType struct { 525 // HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. 526 HelmDeploy *HelmDeploy `yaml:"helm,omitempty"` 527 528 // KptDeploy *alpha* uses the `kpt` CLI to manage and deploy manifests. 529 KptDeploy *KptDeploy `yaml:"kpt,omitempty"` 530 531 // KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. 532 // You'll need a `kubectl` CLI version installed that's compatible with your cluster. 533 KubectlDeploy *KubectlDeploy `yaml:"kubectl,omitempty"` 534 535 // KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. 536 KustomizeDeploy *KustomizeDeploy `yaml:"kustomize,omitempty"` 537 } 538 539 // KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. 540 // You'll need a `kubectl` CLI version installed that's compatible with your cluster. 541 type KubectlDeploy struct { 542 // Manifests lists the Kubernetes yaml or json manifests. 543 // Defaults to `["k8s/*.yaml"]`. 544 Manifests []string `yaml:"manifests,omitempty" skaffold:"filepath"` 545 546 // RemoteManifests lists Kubernetes manifests in remote clusters. 547 RemoteManifests []string `yaml:"remoteManifests,omitempty"` 548 549 // Flags are additional flags passed to `kubectl`. 550 Flags KubectlFlags `yaml:"flags,omitempty"` 551 552 // DefaultNamespace is the default namespace passed to kubectl on deployment if no other override is given. 553 DefaultNamespace *string `yaml:"defaultNamespace,omitempty"` 554 } 555 556 // KubectlFlags are additional flags passed on the command 557 // line to kubectl either on every command (Global), on creations (Apply) 558 // or deletions (Delete). 559 type KubectlFlags struct { 560 // Global are additional flags passed on every command. 561 Global []string `yaml:"global,omitempty"` 562 563 // Apply are additional flags passed on creations (`kubectl apply`). 564 Apply []string `yaml:"apply,omitempty"` 565 566 // Delete are additional flags passed on deletions (`kubectl delete`). 567 Delete []string `yaml:"delete,omitempty"` 568 569 // DisableValidation passes the `--validate=false` flag to supported 570 // `kubectl` commands when enabled. 571 DisableValidation bool `yaml:"disableValidation,omitempty"` 572 } 573 574 // HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. 575 type HelmDeploy struct { 576 // Releases is a list of Helm releases. 577 Releases []HelmRelease `yaml:"releases,omitempty" yamltags:"required"` 578 579 // Flags are additional option flags that are passed on the command 580 // line to `helm`. 581 Flags HelmDeployFlags `yaml:"flags,omitempty"` 582 } 583 584 // HelmDeployFlags are additional option flags that are passed on the command 585 // line to `helm`. 586 type HelmDeployFlags struct { 587 // Global are additional flags passed on every command. 588 Global []string `yaml:"global,omitempty"` 589 590 // Install are additional flags passed to (`helm install`). 591 Install []string `yaml:"install,omitempty"` 592 593 // Upgrade are additional flags passed to (`helm upgrade`). 594 Upgrade []string `yaml:"upgrade,omitempty"` 595 } 596 597 // KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. 598 type KustomizeDeploy struct { 599 // KustomizePaths is the path to Kustomization files. 600 // Defaults to `["."]`. 601 KustomizePaths []string `yaml:"paths,omitempty" skaffold:"filepath"` 602 603 // Flags are additional flags passed to `kubectl`. 604 Flags KubectlFlags `yaml:"flags,omitempty"` 605 606 // BuildArgs are additional args passed to `kustomize build`. 607 BuildArgs []string `yaml:"buildArgs,omitempty"` 608 609 // DefaultNamespace is the default namespace passed to kubectl on deployment if no other override is given. 610 DefaultNamespace *string `yaml:"defaultNamespace,omitempty"` 611 } 612 613 // KptDeploy *alpha* uses the `kpt` CLI to manage and deploy manifests. 614 type KptDeploy struct { 615 // Dir is the path to the config directory (Required). 616 // By default, the Dir contains the application configurations, 617 // [kustomize config files](https://kubectl.docs.kubernetes.io/pages/examples/kustomize.html) 618 // and [declarative kpt functions](https://googlecontainertools.github.io/kpt/guides/consumer/function/#declarative-run). 619 Dir string `yaml:"dir" yamltags:"required" skaffold:"filepath"` 620 621 // Fn adds additional configurations for `kpt fn`. 622 Fn KptFn `yaml:"fn,omitempty"` 623 624 // Live adds additional configurations for `kpt live`. 625 Live KptLive `yaml:"live,omitempty"` 626 } 627 628 // KptFn adds additional configurations used when calling `kpt fn`. 629 type KptFn struct { 630 // FnPath is the directory to discover the declarative kpt functions. 631 // If not provided, kpt deployer uses `kpt.Dir`. 632 FnPath string `yaml:"fnPath,omitempty" skaffold:"filepath"` 633 634 // Image is a kpt function image to run the configs imperatively. If provided, kpt.fn.fnPath 635 // will be ignored. 636 Image string `yaml:"image,omitempty"` 637 638 // NetworkName is the docker network name to run the kpt function containers (default "bridge"). 639 NetworkName string `yaml:"networkName,omitempty"` 640 641 // GlobalScope sets the global scope for the kpt functions. see `kpt help fn run`. 642 GlobalScope bool `yaml:"globalScope,omitempty"` 643 644 // Network enables network access for the kpt function containers. 645 Network bool `yaml:"network,omitempty"` 646 647 // Mount is a list of storage options to mount to the fn image. 648 Mount []string `yaml:"mount,omitempty"` 649 650 // SinkDir is the directory to where the manipulated resource output is stored. 651 SinkDir string `yaml:"sinkDir,omitempty" skaffold:"filepath"` 652 } 653 654 // KptLive adds additional configurations used when calling `kpt live`. 655 type KptLive struct { 656 // Apply sets the kpt inventory directory. 657 Apply KptApplyInventory `yaml:"apply,omitempty"` 658 659 // Options adds additional configurations for `kpt live apply` commands. 660 Options KptApplyOptions `yaml:"options,omitempty"` 661 } 662 663 // KptApplyInventory sets the kpt inventory directory. 664 type KptApplyInventory struct { 665 // Dir is equivalent to the dir in `kpt live apply <dir>`. If not provided, 666 // kpt deployer will create a hidden directory `.kpt-hydrated` to store the manipulated 667 // resource output and the kpt inventory-template.yaml file. 668 Dir string `yaml:"dir,omitempty"` 669 670 // InventoryID *alpha* is the identifier for a group of applied resources. 671 // This value is only needed when the `kpt live` is working on a pre-applied cluster resources. 672 InventoryID string `yaml:"inventoryID,omitempty"` 673 674 // InventoryNamespace *alpha* sets the inventory namespace. 675 InventoryNamespace string `yaml:"inventoryNamespace,omitempty"` 676 } 677 678 // KptApplyOptions adds additional configurations used when calling `kpt live apply`. 679 type KptApplyOptions struct { 680 // PollPeriod sets for the polling period for resource statuses. Default to 2s. 681 PollPeriod string `yaml:"pollPeriod,omitempty"` 682 683 // PrunePropagationPolicy sets the propagation policy for pruning. 684 // Possible settings are Background, Foreground, Orphan. 685 // Default to "Background". 686 PrunePropagationPolicy string `yaml:"prunePropagationPolicy,omitempty"` 687 688 // PruneTimeout sets the time threshold to wait for all pruned resources to be deleted. 689 PruneTimeout string `yaml:"pruneTimeout,omitempty"` 690 691 // ReconcileTimeout sets the time threshold to wait for all resources to reach the current status. 692 ReconcileTimeout string `yaml:"reconcileTimeout,omitempty"` 693 } 694 695 // HelmRelease describes a helm release to be deployed. 696 type HelmRelease struct { 697 // Name is the name of the Helm release. 698 // It accepts environment variables via the go template syntax. 699 Name string `yaml:"name,omitempty" yamltags:"required"` 700 701 // ChartPath is the local path to a packaged Helm chart or an unpacked Helm chart directory. 702 ChartPath string `yaml:"chartPath,omitempty" yamltags:"oneOf=chartSource" skaffold:"filepath"` 703 704 // RemoteChart refers to a remote Helm chart reference or URL. 705 RemoteChart string `yaml:"remoteChart,omitempty" yamltags:"oneOf=chartSource"` 706 707 // ValuesFiles are the paths to the Helm `values` files. 708 ValuesFiles []string `yaml:"valuesFiles,omitempty" skaffold:"filepath"` 709 710 // ArtifactOverrides are key value pairs where the 711 // key represents the parameter used in the `--set-string` Helm CLI flag to define a container 712 // image and the value corresponds to artifact i.e. `ImageName` defined in `Build.Artifacts` section. 713 // The resulting command-line is controlled by `ImageStrategy`. 714 ArtifactOverrides util.FlatMap `yaml:"artifactOverrides,omitempty"` 715 716 // Namespace is the Kubernetes namespace. 717 Namespace string `yaml:"namespace,omitempty"` 718 719 // Version is the version of the chart. 720 Version string `yaml:"version,omitempty"` 721 722 // SetValues are key-value pairs. 723 // If present, Skaffold will send `--set` flag to Helm CLI and append all pairs after the flag. 724 SetValues util.FlatMap `yaml:"setValues,omitempty"` 725 726 // SetValueTemplates are key-value pairs. 727 // If present, Skaffold will try to parse the value part of each key-value pair using 728 // environment variables in the system, then send `--set` flag to Helm CLI and append 729 // all parsed pairs after the flag. 730 SetValueTemplates util.FlatMap `yaml:"setValueTemplates,omitempty"` 731 732 // SetFiles are key-value pairs. 733 // If present, Skaffold will send `--set-file` flag to Helm CLI and append all pairs after the flag. 734 SetFiles map[string]string `yaml:"setFiles,omitempty" skaffold:"filepath"` 735 736 // CreateNamespace if `true`, Skaffold will send `--create-namespace` flag to Helm CLI. 737 // `--create-namespace` flag is available in Helm since version 3.2. 738 // Defaults is `false`. 739 CreateNamespace *bool `yaml:"createNamespace,omitempty"` 740 741 // Wait if `true`, Skaffold will send `--wait` flag to Helm CLI. 742 // Defaults to `false`. 743 Wait bool `yaml:"wait,omitempty"` 744 745 // RecreatePods if `true`, Skaffold will send `--recreate-pods` flag to Helm CLI 746 // when upgrading a new version of a chart in subsequent dev loop deploy. 747 // Defaults to `false`. 748 RecreatePods bool `yaml:"recreatePods,omitempty"` 749 750 // SkipBuildDependencies should build dependencies be skipped. 751 // Ignored for `remoteChart`. 752 SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"` 753 754 // UseHelmSecrets instructs skaffold to use secrets plugin on deployment. 755 UseHelmSecrets bool `yaml:"useHelmSecrets,omitempty"` 756 757 // Repo specifies the helm repository for remote charts. 758 // If present, Skaffold will send `--repo` Helm CLI flag or flags. 759 Repo string `yaml:"repo,omitempty"` 760 761 // UpgradeOnChange specifies whether to upgrade helm chart on code changes. 762 // Default is `true` when helm chart is local (has `chartPath`). 763 // Default is `false` when helm chart is remote (has `remoteChart`). 764 UpgradeOnChange *bool `yaml:"upgradeOnChange,omitempty"` 765 766 // Overrides are key-value pairs. 767 // If present, Skaffold will build a Helm `values` file that overrides 768 // the original and use it to call Helm CLI (`--f` flag). 769 Overrides util.HelmOverrides `yaml:"overrides,omitempty"` 770 771 // Packaged parameters for packaging helm chart (`helm package`). 772 Packaged *HelmPackaged `yaml:"packaged,omitempty"` 773 774 // ImageStrategy controls how an `ArtifactOverrides` entry is 775 // turned into `--set-string` Helm CLI flag or flags. 776 ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` 777 } 778 779 // HelmPackaged parameters for packaging helm chart (`helm package`). 780 type HelmPackaged struct { 781 // Version sets the `version` on the chart to this semver version. 782 Version string `yaml:"version,omitempty"` 783 784 // AppVersion sets the `appVersion` on the chart to this version. 785 AppVersion string `yaml:"appVersion,omitempty"` 786 } 787 788 // HelmImageStrategy adds image configurations to the Helm `values` file. 789 type HelmImageStrategy struct { 790 HelmImageConfig `yaml:",inline"` 791 } 792 793 // HelmImageConfig describes an image configuration. 794 type HelmImageConfig struct { 795 // HelmFQNConfig is the image configuration uses the syntax `IMAGE-NAME=IMAGE-REPOSITORY:IMAGE-TAG`. 796 HelmFQNConfig *HelmFQNConfig `yaml:"fqn,omitempty" yamltags:"oneOf=helmImageStrategy"` 797 798 // HelmConventionConfig is the image configuration uses the syntax `IMAGE-NAME.repository=IMAGE-REPOSITORY, IMAGE-NAME.tag=IMAGE-TAG`. 799 HelmConventionConfig *HelmConventionConfig `yaml:"helm,omitempty" yamltags:"oneOf=helmImageStrategy"` 800 } 801 802 // HelmFQNConfig is the image config to use the FullyQualifiedImageName as param to set. 803 type HelmFQNConfig struct { 804 // Property defines the image config. 805 Property string `yaml:"property,omitempty"` 806 } 807 808 // HelmConventionConfig is the image config in the syntax of image.repository and image.tag. 809 type HelmConventionConfig struct { 810 // ExplicitRegistry separates `image.registry` to the image config syntax. Useful for some charts e.g. `postgresql`. 811 ExplicitRegistry bool `yaml:"explicitRegistry,omitempty"` 812 } 813 814 // LogsConfig configures how container logs are printed as a result of a deployment. 815 type LogsConfig struct { 816 // Prefix defines the prefix shown on each log line. Valid values are 817 // `container`: prefix logs lines with the name of the container. 818 // `podAndContainer`: prefix logs lines with the names of the pod and of the container. 819 // `auto`: same as `podAndContainer` except that the pod name is skipped if it's the same as the container name. 820 // `none`: don't add a prefix. 821 // Defaults to `auto`. 822 Prefix string `yaml:"prefix,omitempty"` 823 } 824 825 // Artifact are the items that need to be built, along with the context in which 826 // they should be built. 827 type Artifact struct { 828 // ImageName is the name of the image to be built. 829 // For example: `gcr.io/k8s-skaffold/example`. 830 ImageName string `yaml:"image,omitempty" yamltags:"required"` 831 832 // Workspace is the directory containing the artifact's sources. 833 // Defaults to `.`. 834 Workspace string `yaml:"context,omitempty" skaffold:"filepath"` 835 836 // Sync *beta* lists local files synced to pods instead 837 // of triggering an image build when modified. 838 // If no files are listed, sync all the files and infer the destination. 839 // Defaults to `infer: ["**/*"]`. 840 Sync *Sync `yaml:"sync,omitempty"` 841 842 // ArtifactType describes how to build an artifact. 843 ArtifactType `yaml:",inline"` 844 845 // Dependencies describes build artifacts that this artifact depends on. 846 Dependencies []*ArtifactDependency `yaml:"requires,omitempty"` 847 } 848 849 // Sync *beta* specifies what files to sync into the container. 850 // This is a list of sync rules indicating the intent to sync for source files. 851 // If no files are listed, sync all the files and infer the destination. 852 // Defaults to `infer: ["**/*"]`. 853 type Sync struct { 854 // Manual lists manual sync rules indicating the source and destination. 855 Manual []*SyncRule `yaml:"manual,omitempty" yamltags:"oneOf=sync"` 856 857 // Infer lists file patterns which may be synced into the container 858 // The container destination is inferred by the builder 859 // based on the instructions of a Dockerfile. 860 // Available for docker and kaniko artifacts and custom 861 // artifacts that declare dependencies on a dockerfile. 862 Infer []string `yaml:"infer,omitempty" yamltags:"oneOf=sync"` 863 864 // Auto delegates discovery of sync rules to the build system. 865 // Only available for jib and buildpacks. 866 Auto *bool `yaml:"auto,omitempty" yamltags:"oneOf=sync"` 867 } 868 869 // SyncRule specifies which local files to sync to remote folders. 870 type SyncRule struct { 871 // Src is a glob pattern to match local paths against. 872 // Directories should be delimited by `/` on all platforms. 873 // For example: `"css/**/*.css"`. 874 Src string `yaml:"src,omitempty" yamltags:"required"` 875 876 // Dest is the destination path in the container where the files should be synced to. 877 // For example: `"app/"` 878 Dest string `yaml:"dest,omitempty" yamltags:"required"` 879 880 // Strip specifies the path prefix to remove from the source path when 881 // transplanting the files into the destination folder. 882 // For example: `"css/"` 883 Strip string `yaml:"strip,omitempty"` 884 } 885 886 // Profile is used to override any `build`, `test` or `deploy` configuration. 887 type Profile struct { 888 // Name is a unique profile name. 889 // For example: `profile-prod`. 890 Name string `yaml:"name,omitempty" yamltags:"required"` 891 892 // Activation criteria by which a profile can be auto-activated. 893 // The profile is auto-activated if any one of the activations are triggered. 894 // An activation is triggered if all of the criteria (env, kubeContext, command) are triggered. 895 Activation []Activation `yaml:"activation,omitempty"` 896 897 // Patches lists patches applied to the configuration. 898 // Patches use the JSON patch notation. 899 Patches []JSONPatch `yaml:"patches,omitempty"` 900 901 // Pipeline contains the definitions to replace the default skaffold pipeline. 902 Pipeline `yaml:",inline"` 903 } 904 905 // JSONPatch patch to be applied by a profile. 906 type JSONPatch struct { 907 // Op is the operation carried by the patch: `add`, `remove`, `replace`, `move`, `copy` or `test`. 908 // Defaults to `replace`. 909 Op string `yaml:"op,omitempty"` 910 911 // Path is the position in the yaml where the operation takes place. 912 // For example, this targets the `dockerfile` of the first artifact built. 913 // For example: `/build/artifacts/0/docker/dockerfile`. 914 Path string `yaml:"path,omitempty" yamltags:"required"` 915 916 // From is the source position in the yaml, used for `copy` or `move` operations. 917 From string `yaml:"from,omitempty"` 918 919 // Value is the value to apply. Can be any portion of yaml. 920 Value *util.YamlpatchNode `yaml:"value,omitempty"` 921 } 922 923 // Activation criteria by which a profile is auto-activated. 924 type Activation struct { 925 // Env is a `key=pattern` pair. The profile is auto-activated if an Environment 926 // Variable `key` matches the pattern. If the pattern starts with `!`, activation 927 // happens if the remaining pattern is _not_ matched. The pattern matches if the 928 // Environment Variable value is exactly `pattern`, or the regex `pattern` is 929 // found in it. An empty `pattern` (e.g. `env: "key="`) always only matches if 930 // the Environment Variable is undefined or empty. 931 // For example: `ENV=production` 932 Env string `yaml:"env,omitempty"` 933 934 // KubeContext is a Kubernetes context for which the profile is auto-activated. 935 // For example: `minikube`. 936 KubeContext string `yaml:"kubeContext,omitempty"` 937 938 // Command is a Skaffold command for which the profile is auto-activated. 939 // For example: `dev`. 940 Command string `yaml:"command,omitempty"` 941 } 942 943 // ArtifactType describes how to build an artifact. 944 type ArtifactType struct { 945 // DockerArtifact *beta* describes an artifact built from a Dockerfile. 946 DockerArtifact *DockerArtifact `yaml:"docker,omitempty" yamltags:"oneOf=artifact"` 947 948 // BazelArtifact *beta* requires bazel CLI to be installed and the sources to 949 // contain [Bazel](https://bazel.build/) configuration files. 950 BazelArtifact *BazelArtifact `yaml:"bazel,omitempty" yamltags:"oneOf=artifact"` 951 952 // JibArtifact builds images using the 953 // [Jib plugins for Maven or Gradle](https://github.com/GoogleContainerTools/jib/). 954 JibArtifact *JibArtifact `yaml:"jib,omitempty" yamltags:"oneOf=artifact"` 955 956 // KanikoArtifact builds images using [kaniko](https://github.com/GoogleContainerTools/kaniko). 957 KanikoArtifact *KanikoArtifact `yaml:"kaniko,omitempty" yamltags:"oneOf=artifact"` 958 959 // BuildpackArtifact builds images using [Cloud Native Buildpacks](https://buildpacks.io/). 960 BuildpackArtifact *BuildpackArtifact `yaml:"buildpacks,omitempty" yamltags:"oneOf=artifact"` 961 962 // CustomArtifact *beta* builds images using a custom build script written by the user. 963 CustomArtifact *CustomArtifact `yaml:"custom,omitempty" yamltags:"oneOf=artifact"` 964 } 965 966 // ArtifactDependency describes a specific build dependency for an artifact. 967 type ArtifactDependency struct { 968 // ImageName is a reference to an artifact's image name. 969 ImageName string `yaml:"image" yamltags:"required"` 970 // Alias is a token that is replaced with the image reference in the builder definition files. 971 // For example, the `docker` builder will use the alias as a build-arg key. 972 // Defaults to the value of `image`. 973 Alias string `yaml:"alias,omitempty"` 974 } 975 976 // BuildpackArtifact *alpha* describes an artifact built using [Cloud Native Buildpacks](https://buildpacks.io/). 977 // It can be used to build images out of project's sources without any additional configuration. 978 type BuildpackArtifact struct { 979 // Builder is the builder image used. 980 Builder string `yaml:"builder" yamltags:"required"` 981 982 // RunImage overrides the stack's default run image. 983 RunImage string `yaml:"runImage,omitempty"` 984 985 // Env are environment variables, in the `key=value` form, passed to the build. 986 // Values can use the go template syntax. 987 // For example: `["key1=value1", "key2=value2", "key3={{.ENV_VARIABLE}}"]`. 988 Env []string `yaml:"env,omitempty"` 989 990 // Buildpacks is a list of strings, where each string is a specific buildpack to use with the builder. 991 // If you specify buildpacks the builder image automatic detection will be ignored. These buildpacks will be used to build the Image from your source code. 992 // Order matters. 993 Buildpacks []string `yaml:"buildpacks,omitempty"` 994 995 // TrustBuilder indicates that the builder should be trusted. 996 TrustBuilder bool `yaml:"trustBuilder,omitempty"` 997 998 // ProjectDescriptor is the path to the project descriptor file. 999 // Defaults to `project.toml` if it exists. 1000 ProjectDescriptor string `yaml:"projectDescriptor,omitempty"` 1001 1002 // Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. 1003 Dependencies *BuildpackDependencies `yaml:"dependencies,omitempty"` 1004 1005 // Volumes support mounting host volumes into the container. 1006 Volumes *[]BuildpackVolume `yaml:"volumes,omitempty"` 1007 } 1008 1009 // BuildpackDependencies *alpha* is used to specify dependencies for an artifact built by buildpacks. 1010 type BuildpackDependencies struct { 1011 // 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. 1012 Paths []string `yaml:"paths,omitempty" yamltags:"oneOf=dependency"` 1013 1014 // 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. 1015 // Will only work in conjunction with `paths`. 1016 Ignore []string `yaml:"ignore,omitempty"` 1017 } 1018 1019 // BuildpackVolume *alpha* is used to mount host volumes or directories in the build container. 1020 type BuildpackVolume struct { 1021 // Host is the local volume or absolute directory of the path to mount. 1022 Host string `yaml:"host" skaffold:"filepath" yamltags:"required"` 1023 1024 // Target is the path where the file or directory is available in the container. 1025 // It is strongly recommended to not specify locations under `/cnb` or `/layers`. 1026 Target string `yaml:"target" yamltags:"required"` 1027 1028 // Options specify a list of comma-separated mount options. 1029 // Valid options are: 1030 // `ro` (default): volume contents are read-only. 1031 // `rw`: volume contents are readable and writable. 1032 // `volume-opt=<key>=<value>`: can be specified more than once, takes a key-value pair. 1033 Options string `yaml:"options,omitempty"` 1034 } 1035 1036 // CustomArtifact *beta* describes an artifact built from a custom build script 1037 // written by the user. It can be used to build images with builders that aren't directly integrated with skaffold. 1038 type CustomArtifact struct { 1039 // BuildCommand is the command executed to build the image. 1040 BuildCommand string `yaml:"buildCommand,omitempty"` 1041 // Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact. 1042 Dependencies *CustomDependencies `yaml:"dependencies,omitempty"` 1043 } 1044 1045 // CustomDependencies *beta* is used to specify dependencies for an artifact built by a custom build script. 1046 // Either `dockerfile` or `paths` should be specified for file watching to work as expected. 1047 type CustomDependencies struct { 1048 // Dockerfile should be set if the artifact is built from a Dockerfile, from which skaffold can determine dependencies. 1049 Dockerfile *DockerfileDependency `yaml:"dockerfile,omitempty" yamltags:"oneOf=dependency"` 1050 1051 // Command represents a custom command that skaffold executes to obtain dependencies. The output of this command *must* be a valid JSON array. 1052 Command string `yaml:"command,omitempty" yamltags:"oneOf=dependency"` 1053 1054 // 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. 1055 Paths []string `yaml:"paths,omitempty" yamltags:"oneOf=dependency"` 1056 1057 // 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. 1058 // Will only work in conjunction with `paths`. 1059 Ignore []string `yaml:"ignore,omitempty"` 1060 } 1061 1062 // CustomTest describes the custom test command provided by the user. 1063 // Custom tests are run after an image build whenever build or test dependencies are changed. 1064 type CustomTest struct { 1065 // Command is the custom command to be executed. If the command exits with a non-zero return 1066 // code, the test will be considered to have failed. 1067 Command string `yaml:"command" yamltags:"required"` 1068 1069 // TimeoutSeconds sets the wait time for skaffold for the command to complete. 1070 // If unset or 0, Skaffold will wait until the command completes. 1071 TimeoutSeconds int `yaml:"timeoutSeconds,omitempty"` 1072 1073 // Dependencies are additional test-specific file dependencies; changes to these files will re-run this test. 1074 Dependencies *CustomTestDependencies `yaml:"dependencies,omitempty"` 1075 } 1076 1077 // CustomTestDependencies is used to specify dependencies for custom test command. 1078 // `paths` should be specified for file watching to work as expected. 1079 type CustomTestDependencies struct { 1080 // Command represents a command that skaffold executes to obtain dependencies. The output of this command *must* be a valid JSON array. 1081 Command string `yaml:"command,omitempty" yamltags:"oneOf=dependency"` 1082 1083 // Paths locates the file dependencies for the command relative to workspace. 1084 // Paths should be set to the file dependencies for this command, so that the skaffold file watcher knows when to retest and perform file synchronization. 1085 // For example: `["src/test/**"]` 1086 Paths []string `yaml:"paths,omitempty" yamltags:"oneOf=dependency"` 1087 1088 // 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 retest and file synchronization. 1089 // Will only work in conjunction with `paths`. 1090 Ignore []string `yaml:"ignore,omitempty"` 1091 } 1092 1093 // DockerfileDependency *beta* is used to specify a custom build artifact that is built from a Dockerfile. This allows skaffold to determine dependencies from the Dockerfile. 1094 type DockerfileDependency struct { 1095 // Path locates the Dockerfile relative to workspace. 1096 Path string `yaml:"path,omitempty"` 1097 1098 // BuildArgs are key/value pairs used to resolve values of `ARG` instructions in a Dockerfile. 1099 // Values can be constants or environment variables via the go template syntax. 1100 // For example: `{"key1": "value1", "key2": "value2", "key3": "'{{.ENV_VARIABLE}}'"}`. 1101 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 1102 } 1103 1104 // KanikoArtifact describes an artifact built from a Dockerfile, 1105 // with kaniko. 1106 type KanikoArtifact struct { 1107 1108 // Cleanup to clean the filesystem at the end of the build. 1109 Cleanup bool `yaml:"cleanup,omitempty"` 1110 1111 // Insecure if you want to push images to a plain HTTP registry. 1112 Insecure bool `yaml:"insecure,omitempty"` 1113 1114 // InsecurePull if you want to pull images from a plain HTTP registry. 1115 InsecurePull bool `yaml:"insecurePull,omitempty"` 1116 1117 // NoPush if you only want to build the image, without pushing to a registry. 1118 NoPush bool `yaml:"noPush,omitempty"` 1119 1120 // Force building outside of a container. 1121 Force bool `yaml:"force,omitempty"` 1122 1123 // LogTimestamp to add timestamps to log format. 1124 LogTimestamp bool `yaml:"logTimestamp,omitempty"` 1125 1126 // Reproducible is used to strip timestamps out of the built image. 1127 Reproducible bool `yaml:"reproducible,omitempty"` 1128 1129 // SingleSnapshot is takes a single snapshot of the filesystem at the end of the build. 1130 // So only one layer will be appended to the base image. 1131 SingleSnapshot bool `yaml:"singleSnapshot,omitempty"` 1132 1133 // SkipTLS skips TLS certificate validation when pushing to a registry. 1134 SkipTLS bool `yaml:"skipTLS,omitempty"` 1135 1136 // SkipTLSVerifyPull skips TLS certificate validation when pulling from a registry. 1137 SkipTLSVerifyPull bool `yaml:"skipTLSVerifyPull,omitempty"` 1138 1139 // SkipUnusedStages builds only used stages if defined to true. 1140 // Otherwise it builds by default all stages, even the unnecessaries ones until it reaches the target stage / end of Dockerfile. 1141 SkipUnusedStages bool `yaml:"skipUnusedStages,omitempty"` 1142 1143 // UseNewRun to Use the experimental run implementation for detecting changes without requiring file system snapshots. 1144 // In some cases, this may improve build performance by 75%. 1145 UseNewRun bool `yaml:"useNewRun,omitempty"` 1146 1147 // WhitelistVarRun is used to ignore `/var/run` when taking image snapshot. 1148 // Set it to false to preserve /var/run/* in destination image. 1149 WhitelistVarRun bool `yaml:"whitelistVarRun,omitempty"` 1150 1151 // DockerfilePath locates the Dockerfile relative to workspace. 1152 // Defaults to `Dockerfile`. 1153 DockerfilePath string `yaml:"dockerfile,omitempty"` 1154 1155 // Target is to indicate which build stage is the target build stage. 1156 Target string `yaml:"target,omitempty"` 1157 1158 // InitImage is the image used to run init container which mounts kaniko context. 1159 InitImage string `yaml:"initImage,omitempty"` 1160 1161 // Image is the Docker image used by the Kaniko pod. 1162 // Defaults to the latest released version of `gcr.io/kaniko-project/executor`. 1163 Image string `yaml:"image,omitempty"` 1164 1165 // DigestFile to specify a file in the container. This file will receive the digest of a built image. 1166 // This can be used to automatically track the exact image built by kaniko. 1167 DigestFile string `yaml:"digestFile,omitempty"` 1168 1169 // ImageNameWithDigestFile specify a file to save the image name with digest of the built image to. 1170 ImageNameWithDigestFile string `yaml:"imageNameWithDigestFile,omitempty"` 1171 1172 // LogFormat <text|color|json> to set the log format. 1173 LogFormat string `yaml:"logFormat,omitempty"` 1174 1175 // OCILayoutPath is to specify a directory in the container where the OCI image layout of a built image will be placed. 1176 // This can be used to automatically track the exact image built by kaniko. 1177 OCILayoutPath string `yaml:"ociLayoutPath,omitempty"` 1178 1179 // RegistryMirror if you want to use a registry mirror instead of default `index.docker.io`. 1180 RegistryMirror string `yaml:"registryMirror,omitempty"` 1181 1182 // SnapshotMode is how Kaniko will snapshot the filesystem. 1183 SnapshotMode string `yaml:"snapshotMode,omitempty"` 1184 1185 // TarPath is path to save the image as a tarball at path instead of pushing the image. 1186 TarPath string `yaml:"tarPath,omitempty"` 1187 1188 // Verbosity <panic|fatal|error|warn|info|debug|trace> to set the logging level. 1189 Verbosity string `yaml:"verbosity,omitempty"` 1190 1191 // InsecureRegistry is to use plain HTTP requests when accessing a registry. 1192 InsecureRegistry []string `yaml:"insecureRegistry,omitempty"` 1193 1194 // SkipTLSVerifyRegistry skips TLS certificate validation when accessing a registry. 1195 SkipTLSVerifyRegistry []string `yaml:"skipTLSVerifyRegistry,omitempty"` 1196 1197 // Env are environment variables passed to the kaniko pod. 1198 // It also accepts environment variables via the go template syntax. 1199 // For example: `[{"name": "key1", "value": "value1"}, {"name": "key2", "value": "value2"}, {"name": "key3", "value": "'{{.ENV_VARIABLE}}'"}]`. 1200 Env []v1.EnvVar `yaml:"env,omitempty"` 1201 1202 // Cache configures Kaniko caching. If a cache is specified, Kaniko will 1203 // use a remote cache which will speed up builds. 1204 Cache *KanikoCache `yaml:"cache,omitempty"` 1205 1206 // RegistryCertificate is to provide a certificate for TLS communication with a given registry. 1207 // my.registry.url: /path/to/the/certificate.cert is the expected format. 1208 RegistryCertificate map[string]*string `yaml:"registryCertificate,omitempty"` 1209 1210 // Label key: value to set some metadata to the final image. 1211 // This is equivalent as using the LABEL within the Dockerfile. 1212 Label map[string]*string `yaml:"label,omitempty"` 1213 1214 // BuildArgs are arguments passed to the docker build. 1215 // It also accepts environment variables and generated values via the go template syntax. 1216 // Exposed generated values: IMAGE_REPO, IMAGE_NAME, IMAGE_TAG. 1217 // For example: `{"key1": "value1", "key2": "value2", "key3": "'{{.ENV_VARIABLE}}'"}`. 1218 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 1219 1220 // VolumeMounts are volume mounts passed to kaniko pod. 1221 VolumeMounts []v1.VolumeMount `yaml:"volumeMounts,omitempty"` 1222 } 1223 1224 // DockerArtifact describes an artifact built from a Dockerfile, 1225 // usually using `docker build`. 1226 type DockerArtifact struct { 1227 // DockerfilePath locates the Dockerfile relative to workspace. 1228 // Defaults to `Dockerfile`. 1229 DockerfilePath string `yaml:"dockerfile,omitempty"` 1230 1231 // Target is the Dockerfile target name to build. 1232 Target string `yaml:"target,omitempty"` 1233 1234 // BuildArgs are arguments passed to the docker build. 1235 // For example: `{"key1": "value1", "key2": "{{ .ENV_VAR }}"}`. 1236 BuildArgs map[string]*string `yaml:"buildArgs,omitempty"` 1237 1238 // NetworkMode is passed through to docker and overrides the 1239 // network configuration of docker builder. If unset, use whatever 1240 // is configured in the underlying docker daemon. Valid modes are 1241 // `host`: use the host's networking stack. 1242 // `bridge`: use the bridged network configuration. 1243 // `container:<name|id>`: reuse another container's network stack. 1244 // `none`: no networking in the container. 1245 NetworkMode string `yaml:"network,omitempty"` 1246 1247 // AddHost lists add host. 1248 // For example: `["host1:ip1", "host2:ip2"]`. 1249 AddHost []string `yaml:"addHost,omitempty"` 1250 1251 // CacheFrom lists the Docker images used as cache sources. 1252 // For example: `["golang:1.10.1-alpine3.7", "alpine:3.7"]`. 1253 CacheFrom []string `yaml:"cacheFrom,omitempty"` 1254 1255 // NoCache used to pass in --no-cache to docker build to prevent caching. 1256 NoCache bool `yaml:"noCache,omitempty"` 1257 1258 // Squash is used to pass in --squash to docker build to squash docker image layers into single layer. 1259 Squash bool `yaml:"squash,omitempty"` 1260 1261 // Secret contains information about a local secret passed to `docker build`, 1262 // along with optional destination information. 1263 Secret *DockerSecret `yaml:"secret,omitempty"` 1264 1265 // SSH is used to pass in --ssh to docker build to use SSH agent. Format is "default|<id>[=<socket>|<key>[,<key>]]". 1266 SSH string `yaml:"ssh,omitempty"` 1267 } 1268 1269 // DockerSecret contains information about a local secret passed to `docker build`, 1270 // along with optional destination information. 1271 type DockerSecret struct { 1272 // ID is the id of the secret. 1273 ID string `yaml:"id,omitempty" yamltags:"required"` 1274 1275 // Source is the path to the secret on the host machine. 1276 Source string `yaml:"src,omitempty"` 1277 } 1278 1279 // BazelArtifact describes an artifact built with [Bazel](https://bazel.build/). 1280 type BazelArtifact struct { 1281 // BuildTarget is the `bazel build` target to run. 1282 // For example: `//:skaffold_example.tar`. 1283 BuildTarget string `yaml:"target,omitempty" yamltags:"required"` 1284 1285 // BuildArgs are additional args to pass to `bazel build`. 1286 // For example: `["-flag", "--otherflag"]`. 1287 BuildArgs []string `yaml:"args,omitempty"` 1288 } 1289 1290 // JibArtifact builds images using the 1291 // [Jib plugins for Maven and Gradle](https://github.com/GoogleContainerTools/jib/). 1292 type JibArtifact struct { 1293 // Project selects which sub-project to build for multi-module builds. 1294 Project string `yaml:"project,omitempty"` 1295 1296 // Flags are additional build flags passed to the builder. 1297 // For example: `["--no-build-cache"]`. 1298 Flags []string `yaml:"args,omitempty"` 1299 1300 // Type the Jib builder type; normally determined automatically. Valid types are 1301 // `maven`: for Maven. 1302 // `gradle`: for Gradle. 1303 Type string `yaml:"type,omitempty"` 1304 1305 // BaseImage overrides the configured jib base image. 1306 BaseImage string `yaml:"fromImage,omitempty"` 1307 } 1308 1309 // UnmarshalYAML provides a custom unmarshaller to deal with 1310 // https://github.com/GoogleContainerTools/skaffold/issues/4175 1311 func (clusterDetails *ClusterDetails) UnmarshalYAML(value *yaml.Node) error { 1312 // We do this as follows 1313 // 1. We zero out the fields in the node that require custom processing 1314 // 2. We unmarshal all the non special fields using the aliased type resource 1315 // we use an alias type to avoid recursion caused by invoking this function infinitely 1316 // 3. We deserialize the special fields as required. 1317 type ClusterDetailsForUnmarshaling ClusterDetails 1318 1319 volumes, remaining, err := util.UnmarshalClusterVolumes(value) 1320 1321 if err != nil { 1322 return err 1323 } 1324 1325 // Unmarshal the remaining values 1326 aux := (*ClusterDetailsForUnmarshaling)(clusterDetails) 1327 err = yaml.Unmarshal(remaining, aux) 1328 1329 if err != nil { 1330 return err 1331 } 1332 1333 clusterDetails.Volumes = volumes 1334 return nil 1335 } 1336 1337 // UnmarshalYAML provides a custom unmarshaller to deal with 1338 // https://github.com/GoogleContainerTools/skaffold/issues/4175 1339 func (ka *KanikoArtifact) UnmarshalYAML(value *yaml.Node) error { 1340 // We do this as follows 1341 // 1. We zero out the fields in the node that require custom processing 1342 // 2. We unmarshal all the non special fields using the aliased type resource 1343 // we use an alias type to avoid recursion caused by invoking this function infinitely 1344 // 3. We deserialize the special fields as required. 1345 type KanikoArtifactForUnmarshaling KanikoArtifact 1346 1347 mounts, remaining, err := util.UnmarshalKanikoArtifact(value) 1348 1349 if err != nil { 1350 return err 1351 } 1352 1353 // Unmarshal the remaining values 1354 aux := (*KanikoArtifactForUnmarshaling)(ka) 1355 err = yaml.Unmarshal(remaining, aux) 1356 1357 if err != nil { 1358 return err 1359 } 1360 1361 ka.VolumeMounts = mounts 1362 return nil 1363 } 1364 1365 // MarshalYAML provides a custom marshaller to deal with 1366 // https://github.com/GoogleContainerTools/skaffold/issues/4175 1367 func (clusterDetails *ClusterDetails) MarshalYAML() (interface{}, error) { 1368 // We do this as follows 1369 // 1. We zero out the fields in the node that require custom processing 1370 // 2. We marshall all the non special fields using the aliased type resource 1371 // we use an alias type to avoid recursion caused by invoking this function infinitely 1372 // 3. We unmarshal to a map 1373 // 4. We marshal the special fields to json and unmarshal to a map 1374 // * This leverages the json struct annotations to marshal as expected 1375 // 5. We combine the two maps and return 1376 type ClusterDetailsForUnmarshaling ClusterDetails 1377 1378 // Marshal volumes to a list. Use json because the Kubernetes resources have json annotations. 1379 volumes := clusterDetails.Volumes 1380 1381 j, err := json.Marshal(volumes) 1382 1383 if err != nil { 1384 return err, nil 1385 } 1386 1387 vList := []interface{}{} 1388 1389 if err := json.Unmarshal(j, &vList); err != nil { 1390 return nil, err 1391 } 1392 1393 // Make a deep copy of clusterDetails because we need to zero out volumes and we don't want to modify the 1394 // current object. 1395 aux := &ClusterDetailsForUnmarshaling{} 1396 1397 b, err := json.Marshal(clusterDetails) 1398 1399 if err != nil { 1400 return nil, err 1401 } 1402 1403 if err := json.Unmarshal(b, aux); err != nil { 1404 return nil, err 1405 } 1406 1407 aux.Volumes = nil 1408 1409 marshaled, err := yaml.Marshal(aux) 1410 1411 if err != nil { 1412 return nil, err 1413 } 1414 1415 m := map[string]interface{}{} 1416 1417 err = yaml.Unmarshal(marshaled, m) 1418 1419 if len(vList) > 0 { 1420 m["volumes"] = vList 1421 } 1422 return m, err 1423 } 1424 1425 // MarshalYAML provides a custom marshaller to deal with 1426 // https://github.com/GoogleContainerTools/skaffold/issues/4175 1427 func (ka *KanikoArtifact) MarshalYAML() (interface{}, error) { 1428 // We do this as follows 1429 // 1. We zero out the fields in the node that require custom processing 1430 // 2. We marshal all the non special fields using the aliased type resource 1431 // we use an alias type to avoid recursion caused by invoking this function infinitely 1432 // 3. We unmarshal to a map 1433 // 4. We marshal the special fields to json and unmarshal to a map 1434 // * This leverages the json struct annotations to marshal as expected 1435 // 5. We combine the two maps and return 1436 type KanikoArtifactForUnmarshaling KanikoArtifact 1437 1438 // Marshal volumes to a map. User json because the Kubernetes resources have json annotations. 1439 volumeMounts := ka.VolumeMounts 1440 1441 j, err := json.Marshal(volumeMounts) 1442 1443 if err != nil { 1444 return err, nil 1445 } 1446 1447 vList := []interface{}{} 1448 1449 if err := json.Unmarshal(j, &vList); err != nil { 1450 return nil, err 1451 } 1452 1453 // Make a deep copy of kanikoArtifact because we need to zero out volumeMounts and we don't want to modify the 1454 // current object. 1455 aux := &KanikoArtifactForUnmarshaling{} 1456 1457 b, err := json.Marshal(ka) 1458 1459 if err != nil { 1460 return nil, err 1461 } 1462 1463 if err := json.Unmarshal(b, aux); err != nil { 1464 return nil, err 1465 } 1466 aux.VolumeMounts = nil 1467 1468 marshaled, err := yaml.Marshal(aux) 1469 1470 if err != nil { 1471 return nil, err 1472 } 1473 1474 m := map[string]interface{}{} 1475 1476 err = yaml.Unmarshal(marshaled, m) 1477 1478 if len(vList) > 0 { 1479 m["volumeMounts"] = vList 1480 } 1481 return m, err 1482 }