github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/schema/v1alpha2/config.go (about)

     1  /*
     2  Copyright 2019 The Skaffold Authors
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1alpha2
    18  
    19  import (
    20  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
    21  )
    22  
    23  // !!! WARNING !!! This config version is already released, please DO NOT MODIFY the structs in this file.
    24  const Version string = "skaffold/v1alpha2"
    25  
    26  // NewSkaffoldConfig creates a SkaffoldConfig
    27  func NewSkaffoldConfig() util.VersionedConfig {
    28  	return new(SkaffoldConfig)
    29  }
    30  
    31  type SkaffoldConfig struct {
    32  	APIVersion string `yaml:"apiVersion"`
    33  	Kind       string `yaml:"kind"`
    34  
    35  	Build    BuildConfig  `yaml:"build,omitempty"`
    36  	Deploy   DeployConfig `yaml:"deploy,omitempty"`
    37  	Profiles []Profile    `yaml:"profiles,omitempty"`
    38  }
    39  
    40  func (c *SkaffoldConfig) GetVersion() string {
    41  	return c.APIVersion
    42  }
    43  
    44  // BuildConfig contains all the configuration for the build steps
    45  type BuildConfig struct {
    46  	Artifacts []*Artifact `yaml:"artifacts,omitempty"`
    47  	TagPolicy TagPolicy   `yaml:"tagPolicy,omitempty"`
    48  	BuildType `yaml:",inline"`
    49  }
    50  
    51  // TagPolicy contains all the configuration for the tagging step
    52  type TagPolicy struct {
    53  	GitTagger         *GitTagger         `yaml:"gitCommit,omitempty" yamltags:"oneOf=tag"`
    54  	ShaTagger         *ShaTagger         `yaml:"sha256,omitempty" yamltags:"oneOf=tag"`
    55  	EnvTemplateTagger *EnvTemplateTagger `yaml:"envTemplate,omitempty" yamltags:"oneOf=tag"`
    56  	DateTimeTagger    *DateTimeTagger    `yaml:"dateTime,omitempty" yamltags:"oneOf=tag"`
    57  }
    58  
    59  // ShaTagger contains the configuration for the SHA tagger.
    60  type ShaTagger struct{}
    61  
    62  // GitTagger contains the configuration for the git tagger.
    63  type GitTagger struct{}
    64  
    65  // EnvTemplateTagger contains the configuration for the envTemplate tagger.
    66  type EnvTemplateTagger struct {
    67  	Template string `yaml:"template"`
    68  }
    69  
    70  // DateTimeTagger contains the configuration for the DateTime tagger.
    71  type DateTimeTagger struct {
    72  	Format   string `yaml:"format,omitempty"`
    73  	TimeZone string `yaml:"timezone,omitempty"`
    74  }
    75  
    76  // BuildType contains the specific implementation and parameters needed
    77  // for the build step. Only one field should be populated.
    78  type BuildType struct {
    79  	LocalBuild       *LocalBuild       `yaml:"local,omitempty" yamltags:"oneOf=build"`
    80  	GoogleCloudBuild *GoogleCloudBuild `yaml:"googleCloudBuild,omitempty" yamltags:"oneOf=build"`
    81  	KanikoBuild      *KanikoBuild      `yaml:"kaniko,omitempty" yamltags:"oneOf=build"`
    82  }
    83  
    84  // LocalBuild contains the fields needed to do a build on the local docker daemon
    85  // and optionally push to a repository.
    86  type LocalBuild struct {
    87  	SkipPush     *bool `yaml:"skipPush,omitempty"`
    88  	UseDockerCLI bool  `yaml:"useDockerCLI,omitempty"`
    89  	UseBuildkit  bool  `yaml:"useBuildkit,omitempty"`
    90  }
    91  
    92  // GoogleCloudBuild contains the fields needed to do a remote build on
    93  // Google Cloud Build.
    94  type GoogleCloudBuild struct {
    95  	ProjectID   string `yaml:"projectId"`
    96  	DiskSizeGb  int64  `yaml:"diskSizeGb,omitempty"`
    97  	MachineType string `yaml:"machineType,omitempty"`
    98  	Timeout     string `yaml:"timeout,omitempty"`
    99  	DockerImage string `yaml:"dockerImage,omitempty"`
   100  }
   101  
   102  // KanikoBuild contains the fields needed to do a on-cluster build using
   103  // the kaniko image
   104  type KanikoBuild struct {
   105  	GCSBucket      string `yaml:"gcsBucket,omitempty"`
   106  	PullSecret     string `yaml:"pullSecret,omitempty"`
   107  	PullSecretName string `yaml:"pullSecretName,omitempty"`
   108  	Namespace      string `yaml:"namespace,omitempty"`
   109  	Timeout        string `yaml:"timeout,omitempty"`
   110  }
   111  
   112  // DeployConfig contains all the configuration needed by the deploy steps
   113  type DeployConfig struct {
   114  	DeployType `yaml:",inline"`
   115  }
   116  
   117  // DeployType contains the specific implementation and parameters needed
   118  // for the deploy step. Only one field should be populated.
   119  type DeployType struct {
   120  	HelmDeploy      *HelmDeploy      `yaml:"helm,omitempty" yamltags:"oneOf=deploy"`
   121  	KubectlDeploy   *KubectlDeploy   `yaml:"kubectl,omitempty" yamltags:"oneOf=deploy"`
   122  	KustomizeDeploy *KustomizeDeploy `yaml:"kustomize,omitempty" yamltags:"oneOf=deploy"`
   123  }
   124  
   125  // KubectlDeploy contains the configuration needed for deploying with `kubectl apply`
   126  type KubectlDeploy struct {
   127  	Manifests       []string     `yaml:"manifests,omitempty"`
   128  	RemoteManifests []string     `yaml:"remoteManifests,omitempty"`
   129  	Flags           KubectlFlags `yaml:"flags,omitempty"`
   130  }
   131  
   132  // KubectlFlags describes additional options flags that are passed on the command
   133  // line to kubectl either on every command (Global), on creations (Apply)
   134  // or deletions (Delete).
   135  type KubectlFlags struct {
   136  	Global []string `yaml:"global,omitempty"`
   137  	Apply  []string `yaml:"apply,omitempty"`
   138  	Delete []string `yaml:"delete,omitempty"`
   139  }
   140  
   141  // HelmDeploy contains the configuration needed for deploying with helm
   142  type HelmDeploy struct {
   143  	Releases []HelmRelease `yaml:"releases,omitempty"`
   144  }
   145  
   146  type KustomizeDeploy struct {
   147  	KustomizePath string       `yaml:"kustomizePath,omitempty"`
   148  	Flags         KubectlFlags `yaml:"flags,omitempty"`
   149  }
   150  
   151  type HelmRelease struct {
   152  	Name              string             `yaml:"name"`
   153  	ChartPath         string             `yaml:"chartPath"`
   154  	ValuesFilePath    string             `yaml:"valuesFilePath"`
   155  	Values            map[string]string  `yaml:"values,omitempty"`
   156  	Namespace         string             `yaml:"namespace"`
   157  	Version           string             `yaml:"version"`
   158  	SetValues         map[string]string  `yaml:"setValues"`
   159  	SetValueTemplates map[string]string  `yaml:"setValueTemplates"`
   160  	Wait              bool               `yaml:"wait"`
   161  	RecreatePods      bool               `yaml:"recreatePods"`
   162  	Overrides         util.HelmOverrides `yaml:"overrides"`
   163  	Packaged          *HelmPackaged      `yaml:"packaged"`
   164  	ImageStrategy     HelmImageStrategy  `yaml:"imageStrategy"`
   165  }
   166  
   167  // HelmPackaged represents parameters for packaging helm chart.
   168  type HelmPackaged struct {
   169  	// Version sets the version on the chart to this semver version.
   170  	Version string `yaml:"version"`
   171  
   172  	// AppVersion set the appVersion on the chart to this version
   173  	AppVersion string `yaml:"appVersion"`
   174  }
   175  
   176  type HelmImageStrategy struct {
   177  	HelmImageConfig `yaml:",inline"`
   178  }
   179  
   180  type HelmImageConfig struct {
   181  	HelmFQNConfig        *HelmFQNConfig        `yaml:"fqn" yamltags:"oneOf=helmImageStrategy"`
   182  	HelmConventionConfig *HelmConventionConfig `yaml:"helm" yamltags:"oneOf=helmImageStrategy"`
   183  }
   184  
   185  // HelmFQNConfig represents image config to use the FullyQualifiedImageName as param to set
   186  type HelmFQNConfig struct {
   187  	Property string `yaml:"property"`
   188  }
   189  
   190  // HelmConventionConfig represents image config in the syntax of image.repository and image.tag
   191  type HelmConventionConfig struct {
   192  }
   193  
   194  // Artifact represents items that need to be built, along with the context in which
   195  // they should be built.
   196  type Artifact struct {
   197  	ImageName    string `yaml:"imageName"`
   198  	Workspace    string `yaml:"workspace,omitempty"`
   199  	ArtifactType `yaml:",inline"`
   200  }
   201  
   202  // Profile is additional configuration that overrides default
   203  // configuration when it is activated.
   204  type Profile struct {
   205  	Name   string       `yaml:"name"`
   206  	Build  BuildConfig  `yaml:"build,omitempty"`
   207  	Deploy DeployConfig `yaml:"deploy,omitempty"`
   208  }
   209  
   210  type ArtifactType struct {
   211  	DockerArtifact *DockerArtifact `yaml:"docker,omitempty" yamltags:"oneOf=artifact"`
   212  	BazelArtifact  *BazelArtifact  `yaml:"bazel,omitempty" yamltags:"oneOf=artifact"`
   213  }
   214  
   215  type DockerArtifact struct {
   216  	DockerfilePath string             `yaml:"dockerfilePath,omitempty"`
   217  	BuildArgs      map[string]*string `yaml:"buildArgs,omitempty"`
   218  	CacheFrom      []string           `yaml:"cacheFrom,omitempty"`
   219  	Target         string             `yaml:"target,omitempty"`
   220  }
   221  
   222  type BazelArtifact struct {
   223  	BuildTarget string `yaml:"target"`
   224  }