-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[V3] (Part 2) Add new schema to latest/v2
- Define a new schema `v3alpha1` for the skaffold v2 feature. - Create `latest/v2` dir to track `v3alpha*` schemas.
- Loading branch information
Showing
4 changed files
with
813 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,379 @@ | ||
/* | ||
Copyright 2021 The Skaffold Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v2 | ||
|
||
import ( | ||
latest_v1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1" | ||
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util" | ||
) | ||
|
||
const Version string = "skaffold/v3alpha2" | ||
|
||
// NewSkaffoldConfig creates a SkaffoldConfig | ||
func NewSkaffoldConfig() util.VersionedConfig { | ||
return new(SkaffoldConfig) | ||
} | ||
|
||
func (c *SkaffoldConfig) GetVersion() string { | ||
return c.APIVersion | ||
} | ||
|
||
// SkaffoldConfig holds the fields parsed from the Skaffold configuration file (skaffold.yaml). | ||
type SkaffoldConfig struct { | ||
// APIVersion is the version of the configuration. | ||
APIVersion string `yaml:"apiVersion" yamltags:"required"` | ||
|
||
// Kind is always `Config`. Defaults to `Config`. | ||
Kind string `yaml:"kind" yamltags:"required"` | ||
|
||
// Metadata holds additional information about the config. | ||
Metadata Metadata `yaml:"metadata,omitempty"` | ||
|
||
// Dependencies describes a list of other required configs for the current config. | ||
Dependencies []latest_v1.ConfigDependency `yaml:"requires,omitempty"` | ||
|
||
// Pipeline defines the Build/Test/Deploy phases. | ||
Pipeline `yaml:",inline"` | ||
|
||
// Profiles *beta* can override be used to `build`, `test` or `deploy` configuration. | ||
Profiles []Profile `yaml:"profiles,omitempty"` | ||
} | ||
|
||
// Metadata holds an optional name of the project. | ||
type Metadata struct { | ||
// Name is an identifier for the project. | ||
Name string `yaml:"name,omitempty"` | ||
} | ||
|
||
// Pipeline describes a Skaffold pipeline. | ||
type Pipeline struct { | ||
// Build describes how images are built. | ||
Build latest_v1.BuildConfig `yaml:"build,omitempty"` | ||
|
||
// Test describes how images are tested. | ||
Test []*latest_v1.TestCase `yaml:"test,omitempty"` | ||
|
||
// Render describes how the original manifests are hydrated, validated and transformed. | ||
Render RenderConfig `yaml:"render,omitempty"` | ||
|
||
// Deploy describes how the manifests are deployed. | ||
Deploy DeployConfig `yaml:"deploy,omitempty"` | ||
|
||
// PortForward describes user defined resources to port-forward. | ||
PortForward []*latest_v1.PortForwardResource `yaml:"portForward,omitempty"` | ||
} | ||
|
||
// RenderConfig contains all the configuration needed by the render steps. | ||
type RenderConfig struct { | ||
|
||
// Generate defines the dry manifests from a variety of sources. | ||
Generate *Generate `yaml:"generate,omitempty"` | ||
|
||
// Transform defines a set of transformation operations to run in series | ||
Transform *[]Transformer `yaml:"transform,omitempty"` | ||
|
||
// Validate defines a set of validator operations to run in series. | ||
Validate *[]Validator `yaml:"validate,omitempty"` | ||
|
||
// Output is the path to the hydrated directory. | ||
Output string `yaml:"output,omitempty"` | ||
} | ||
|
||
// Generate defines the dry manifests from a variety of sources. | ||
type Generate struct { | ||
|
||
// Manifests contains the raw kubernetes manifest paths and kustomize paths. | ||
Manifests []string `yaml:"Manifests,omitempty"` | ||
|
||
// TODO: Implement the "HelmCharts" and "RemoteResoruces" fields. | ||
} | ||
|
||
// Transformer describes the supported kpt transformers. | ||
type Transformer struct { | ||
// Name is the transformer name. Can only accept skaffold whitelisted tools. | ||
Name string `yaml:"name" yamltags:"required"` | ||
} | ||
|
||
// Transformer describes the supported kpt transformers. | ||
type Validator struct { | ||
// Name is the Validator name. Can only accept skaffold whitelisted tools. | ||
Name string `yaml:"name" yamltags:"required"` | ||
} | ||
|
||
// DeployConfig contains all the configuration needed by the deploy steps. | ||
type DeployConfig struct { | ||
|
||
// Dir is equivalent to the dir in `kpt live apply <dir>`. If not provided, skaffold renders the raw manifests | ||
// and store them to a a hidden directory `.kpt-hydrated`, and deploys the hidden directory. | ||
Dir string `yaml:"dir,omitempty"` | ||
|
||
// **************** kpt live Inventory ************* | ||
// InventoryID *alpha* is the identifier for a group of applied resources. | ||
// This value is only needed when the `kpt live` is working on a pre-applied cluster resources. | ||
InventoryID string `yaml:"inventoryID,omitempty"` | ||
// InventoryNamespace *alpha* sets the inventory namespace. | ||
InventoryNamespace string `yaml:"inventoryNamespace,omitempty"` | ||
// ********************** END *********************** | ||
|
||
// **************** kpt live Options **************** | ||
// PollPeriod sets for the polling period for resource statuses. Default to 2s. Values can be "2s", "1min", "3h", etc | ||
PollPeriod string `statusCheckDeadlineSeconds:"pollPeriod,omitempty"` | ||
// PrunePropagationPolicy sets the propagation policy for pruning. | ||
// Possible settings are Background, Foreground, Orphan. | ||
// Default to "Background". | ||
PrunePropagationPolicy string `yaml:"prunePropagationPolicy,omitempty"` | ||
// PruneTimeout sets the time threshold to wait for all pruned resources to be deleted. | ||
PruneTimeout string `yaml:"pruneTimeout,omitempty"` | ||
// ReconcileTimeout sets the time threshold to wait for all resources to reach the current status. | ||
ReconcileTimeout string `yaml:"reconcileTimeout,omitempty"` | ||
// ********************** END *********************** | ||
|
||
// KubeContext is the Kubernetes context that Skaffold should deploy to. | ||
// For example: `minikube`. | ||
KubeContext string `yaml:"kubeContext,omitempty"` | ||
|
||
// Logs configures how container logs are printed as a result of a deployment. | ||
Logs LogsConfig `yaml:"logs,omitempty"` | ||
} | ||
|
||
/* DO NOT REMOVE. This comment tracks the unimplemented deployer features. Implemented features have been removed | ||
from each deployer. | ||
************** DEPRECATED: KubectlDeploy ****************** | ||
// KubectlDeploy *beta* uses a client side `kubectl apply` to deploy manifests. | ||
// You'll need a `kubectl` CLI version installed that's compatible with your cluster. | ||
type KubectlDeploy struct { | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// RemoteManifests lists Kubernetes manifests in remote clusters. | ||
RemoteManifests []string `yaml:"remoteManifests,omitempty"` | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// Flags are additional flags passed to `kubectl`. | ||
Flags KubectlFlags `yaml:"flags,omitempty"` | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// DefaultNamespace is the default namespace passed to kubectl on deployment if no other override is given. | ||
DefaultNamespace *string `yaml:"defaultNamespace,omitempty"` | ||
} | ||
// KubectlFlags are additional flags passed on the command | ||
// line to kubectl either on every command (Global), on creations (Apply) | ||
// or deletions (Delete). | ||
type KubectlFlags struct { | ||
// Global are additional flags passed on every command. | ||
Global []string `yaml:"global,omitempty"` | ||
// TODO: Deprecated. Need to udpate the skaffold documents. | ||
// Delete are additional flags passed on deletions (`kubectl delete`). | ||
Delete []string `yaml:"delete,omitempty"` | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// DisableValidation passes the `--validate=false` flag to supported | ||
// `kubectl` commands when enabled. | ||
DisableValidation bool `yaml:"disableValidation,omitempty"` | ||
} | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// HelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. | ||
type HelmDeploy struct { | ||
// Releases is a list of Helm releases. | ||
Releases []HelmRelease `yaml:"releases,omitempty" yamltags:"required"` | ||
// Flags are additional option flags that are passed on the command | ||
// line to `helm`. | ||
Flags HelmDeployFlags `yaml:"flags,omitempty"` | ||
} | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// HelmDeployFlags are additional option flags that are passed on the command | ||
// line to `helm`. | ||
type HelmDeployFlags struct { | ||
// Global are additional flags passed on every command. | ||
Global []string `yaml:"global,omitempty"` | ||
// Install are additional flags passed to (`helm install`). | ||
Install []string `yaml:"install,omitempty"` | ||
// Upgrade are additional flags passed to (`helm upgrade`). | ||
Upgrade []string `yaml:"upgrade,omitempty"` | ||
} | ||
// KustomizeDeploy *beta* uses the `kustomize` CLI to "patch" a deployment for a target environment. | ||
type KustomizeDeploy struct { | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// BuildArgs are additional args passed to `kustomize build`. | ||
BuildArgs []string `yaml:"buildArgs,omitempty"` | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// DefaultNamespace is the default namespace passed to kubectl on deployment if no other override is given. | ||
DefaultNamespace *string `yaml:"defaultNamespace,omitempty"` | ||
} | ||
// TODO: Not implemented yet. Support this feature (may not be this field) | ||
// HelmRelease describes a helm release to be deployed. | ||
type HelmRelease struct { | ||
// Name is the name of the Helm release. | ||
// It accepts environment variables via the go template syntax. | ||
Name string `yaml:"name,omitempty" yamltags:"required"` | ||
// ChartPath is the local path to a packaged Helm chart or an unpacked Helm chart directory. | ||
ChartPath string `yaml:"chartPath,omitempty" yamltags:"oneOf=chartSource" skaffold:"filepath"` | ||
// RemoteChart refers to a remote Helm chart reference or URL. | ||
RemoteChart string `yaml:"remoteChart,omitempty" yamltags:"oneOf=chartSource"` | ||
// ValuesFiles are the paths to the Helm `values` files. | ||
ValuesFiles []string `yaml:"valuesFiles,omitempty" skaffold:"filepath"` | ||
// ArtifactOverrides are key value pairs where the | ||
// key represents the parameter used in the `--set-string` Helm CLI flag to define a container | ||
// image and the value corresponds to artifact i.e. `ImageName` defined in `Build.Artifacts` section. | ||
// The resulting command-line is controlled by `ImageStrategy`. | ||
ArtifactOverrides util.FlatMap `yaml:"artifactOverrides,omitempty"` | ||
// Namespace is the Kubernetes namespace. | ||
Namespace string `yaml:"namespace,omitempty"` | ||
// Version is the version of the chart. | ||
Version string `yaml:"version,omitempty"` | ||
// SetValues are key-value pairs. | ||
// If present, Skaffold will send `--set` flag to Helm CLI and append all pairs after the flag. | ||
SetValues util.FlatMap `yaml:"setValues,omitempty"` | ||
// SetValueTemplates are key-value pairs. | ||
// If present, Skaffold will try to parse the value part of each key-value pair using | ||
// environment variables in the system, then send `--set` flag to Helm CLI and append | ||
// all parsed pairs after the flag. | ||
SetValueTemplates util.FlatMap `yaml:"setValueTemplates,omitempty"` | ||
// SetFiles are key-value pairs. | ||
// If present, Skaffold will send `--set-file` flag to Helm CLI and append all pairs after the flag. | ||
SetFiles map[string]string `yaml:"setFiles,omitempty" skaffold:"filepath"` | ||
// CreateNamespace if `true`, Skaffold will send `--create-namespace` flag to Helm CLI. | ||
// `--create-namespace` flag is available in Helm since version 3.2. | ||
// Defaults is `false`. | ||
CreateNamespace *bool `yaml:"createNamespace,omitempty"` | ||
// Wait if `true`, Skaffold will send `--wait` flag to Helm CLI. | ||
// Defaults to `false`. | ||
Wait bool `yaml:"wait,omitempty"` | ||
// RecreatePods if `true`, Skaffold will send `--recreate-pods` flag to Helm CLI | ||
// when upgrading a new version of a chart in subsequent dev loop deploy. | ||
// Defaults to `false`. | ||
RecreatePods bool `yaml:"recreatePods,omitempty"` | ||
// SkipBuildDependencies should build dependencies be skipped. | ||
// Ignored when `remote: true`. | ||
SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"` | ||
// UseHelmSecrets instructs skaffold to use secrets plugin on deployment. | ||
UseHelmSecrets bool `yaml:"useHelmSecrets,omitempty"` | ||
// Repo specifies the helm repository for remote charts. | ||
// If present, Skaffold will send `--repo` Helm CLI flag or flags. | ||
Repo string `yaml:"repo,omitempty"` | ||
// UpgradeOnChange specifies whether to upgrade helm chart on code changes. | ||
// Default is `true` when helm chart is local (`remote: false`). | ||
// Default is `false` if `remote: true`. | ||
UpgradeOnChange *bool `yaml:"upgradeOnChange,omitempty"` | ||
// Overrides are key-value pairs. | ||
// If present, Skaffold will build a Helm `values` file that overrides | ||
// the original and use it to call Helm CLI (`--f` flag). | ||
Overrides util.HelmOverrides `yaml:"overrides,omitempty"` | ||
// Packaged parameters for packaging helm chart (`helm package`). | ||
Packaged *HelmPackaged `yaml:"packaged,omitempty"` | ||
// ImageStrategy controls how an `ArtifactOverrides` entry is | ||
// turned into `--set-string` Helm CLI flag or flags. | ||
ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` | ||
} | ||
// HelmPackaged parameters for packaging helm chart (`helm package`). | ||
type HelmPackaged struct { | ||
// Version sets the `version` on the chart to this semver version. | ||
Version string `yaml:"version,omitempty"` | ||
// AppVersion sets the `appVersion` on the chart to this version. | ||
AppVersion string `yaml:"appVersion,omitempty"` | ||
} | ||
// HelmImageStrategy adds image configurations to the Helm `values` file. | ||
type HelmImageStrategy struct { | ||
HelmImageConfig `yaml:",inline"` | ||
} | ||
// HelmImageConfig describes an image configuration. | ||
type HelmImageConfig struct { | ||
// HelmFQNConfig is the image configuration uses the syntax `IMAGE-NAME=IMAGE-REPOSITORY:IMAGE-TAG`. | ||
HelmFQNConfig *HelmFQNConfig `yaml:"fqn,omitempty" yamltags:"oneOf=helmImageStrategy"` | ||
// HelmConventionConfig is the image configuration uses the syntax `IMAGE-NAME.repository=IMAGE-REPOSITORY, IMAGE-NAME.tag=IMAGE-TAG`. | ||
HelmConventionConfig *HelmConventionConfig `yaml:"helm,omitempty" yamltags:"oneOf=helmImageStrategy"` | ||
} | ||
// HelmFQNConfig is the image config to use the FullyQualifiedImageName as param to set. | ||
type HelmFQNConfig struct { | ||
// Property defines the image config. | ||
Property string `yaml:"property,omitempty"` | ||
} | ||
// HelmConventionConfig is the image config in the syntax of image.repository and image.tag. | ||
type HelmConventionConfig struct { | ||
// ExplicitRegistry separates `image.registry` to the image config syntax. Useful for some charts e.g. `postgresql`. | ||
ExplicitRegistry bool `yaml:"explicitRegistry,omitempty"` | ||
} | ||
*/ | ||
|
||
// LogsConfig configures how container logs are printed as a result of a deployment. | ||
type LogsConfig struct { | ||
// Prefix defines the prefix shown on each log line. Valid values are | ||
// `container`: prefix logs lines with the name of the container. | ||
// `podAndContainer`: prefix logs lines with the names of the pod and of the container. | ||
// `auto`: same as `podAndContainer` except that the pod name is skipped if it's the same as the container name. | ||
// `none`: don't add a prefix. | ||
// Defaults to `auto`. | ||
Prefix string `yaml:"prefix,omitempty"` | ||
} | ||
|
||
// Profile is used to override any `build`, `test` or `deploy` configuration. | ||
type Profile struct { | ||
// Name is a unique profile name. | ||
// For example: `profile-prod`. | ||
Name string `yaml:"name,omitempty" yamltags:"required"` | ||
|
||
// Activation criteria by which a profile can be auto-activated. | ||
// The profile is auto-activated if any one of the activations are triggered. | ||
// An activation is triggered if all of the criteria (env, kubeContext, command) are triggered. | ||
Activation []latest_v1.Activation `yaml:"activation,omitempty"` | ||
|
||
// Patches lists patches applied to the configuration. | ||
// Patches use the JSON patch notation. | ||
Patches []latest_v1.JSONPatch `yaml:"patches,omitempty"` | ||
|
||
// Pipeline contains the definitions to replace the default skaffold pipeline. | ||
Pipeline `yaml:",inline"` | ||
} |
Oops, something went wrong.