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