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