github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/schema/v1alpha3/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 v1alpha3
    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/v1alpha3"
    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  // KanikoBuildContext contains the different fields available to specify
   103  // a kaniko build context
   104  type KanikoBuildContext struct {
   105  	GCSBucket string `yaml:"gcsBucket,omitempty" yamltags:"oneOf=buildContext"`
   106  }
   107  
   108  // KanikoBuild contains the fields needed to do a on-cluster build using
   109  // the kaniko image
   110  type KanikoBuild struct {
   111  	BuildContext   KanikoBuildContext `yaml:"buildContext,omitempty"`
   112  	PullSecret     string             `yaml:"pullSecret,omitempty"`
   113  	PullSecretName string             `yaml:"pullSecretName,omitempty"`
   114  	Namespace      string             `yaml:"namespace,omitempty"`
   115  	Timeout        string             `yaml:"timeout,omitempty"`
   116  }
   117  
   118  // DeployConfig contains all the configuration needed by the deploy steps
   119  type DeployConfig struct {
   120  	DeployType `yaml:",inline"`
   121  }
   122  
   123  // DeployType contains the specific implementation and parameters needed
   124  // for the deploy step. Only one field should be populated.
   125  type DeployType struct {
   126  	HelmDeploy      *HelmDeploy      `yaml:"helm,omitempty" yamltags:"oneOf=deploy"`
   127  	KubectlDeploy   *KubectlDeploy   `yaml:"kubectl,omitempty" yamltags:"oneOf=deploy"`
   128  	KustomizeDeploy *KustomizeDeploy `yaml:"kustomize,omitempty" yamltags:"oneOf=deploy"`
   129  }
   130  
   131  // KubectlDeploy contains the configuration needed for deploying with `kubectl apply`
   132  type KubectlDeploy struct {
   133  	Manifests       []string     `yaml:"manifests,omitempty"`
   134  	RemoteManifests []string     `yaml:"remoteManifests,omitempty"`
   135  	Flags           KubectlFlags `yaml:"flags,omitempty"`
   136  }
   137  
   138  // KubectlFlags describes additional options flags that are passed on the command
   139  // line to kubectl either on every command (Global), on creations (Apply)
   140  // or deletions (Delete).
   141  type KubectlFlags struct {
   142  	Global []string `yaml:"global,omitempty"`
   143  	Apply  []string `yaml:"apply,omitempty"`
   144  	Delete []string `yaml:"delete,omitempty"`
   145  }
   146  
   147  // HelmDeploy contains the configuration needed for deploying with helm
   148  type HelmDeploy struct {
   149  	Releases []HelmRelease `yaml:"releases,omitempty"`
   150  }
   151  
   152  type KustomizeDeploy struct {
   153  	KustomizePath string       `yaml:"kustomizePath,omitempty"`
   154  	Flags         KubectlFlags `yaml:"flags,omitempty"`
   155  }
   156  
   157  type HelmRelease struct {
   158  	Name              string             `yaml:"name"`
   159  	ChartPath         string             `yaml:"chartPath"`
   160  	ValuesFiles       []string           `yaml:"valuesFiles"`
   161  	Values            map[string]string  `yaml:"values,omitempty"`
   162  	Namespace         string             `yaml:"namespace"`
   163  	Version           string             `yaml:"version"`
   164  	SetValues         map[string]string  `yaml:"setValues"`
   165  	SetValueTemplates map[string]string  `yaml:"setValueTemplates"`
   166  	Wait              bool               `yaml:"wait"`
   167  	RecreatePods      bool               `yaml:"recreatePods"`
   168  	Overrides         util.HelmOverrides `yaml:"overrides"`
   169  	Packaged          *HelmPackaged      `yaml:"packaged"`
   170  	ImageStrategy     HelmImageStrategy  `yaml:"imageStrategy"`
   171  }
   172  
   173  // HelmPackaged represents parameters for packaging helm chart.
   174  type HelmPackaged struct {
   175  	// Version sets the version on the chart to this semver version.
   176  	Version string `yaml:"version"`
   177  
   178  	// AppVersion set the appVersion on the chart to this version
   179  	AppVersion string `yaml:"appVersion"`
   180  }
   181  
   182  type HelmImageStrategy struct {
   183  	HelmImageConfig `yaml:",inline"`
   184  }
   185  
   186  type HelmImageConfig struct {
   187  	HelmFQNConfig        *HelmFQNConfig        `yaml:"fqn" yamltags:"oneOf=helmImageStrategy"`
   188  	HelmConventionConfig *HelmConventionConfig `yaml:"helm" yamltags:"oneOf=helmImageStrategy"`
   189  }
   190  
   191  // HelmFQNConfig represents image config to use the FullyQualifiedImageName as param to set
   192  type HelmFQNConfig struct {
   193  	Property string `yaml:"property"`
   194  }
   195  
   196  // HelmConventionConfig represents image config in the syntax of image.repository and image.tag
   197  type HelmConventionConfig struct {
   198  }
   199  
   200  // Artifact represents items that need to be built, along with the context in which
   201  // they should be built.
   202  type Artifact struct {
   203  	ImageName    string `yaml:"imageName"`
   204  	Workspace    string `yaml:"workspace,omitempty"`
   205  	ArtifactType `yaml:",inline"`
   206  }
   207  
   208  // Profile is additional configuration that overrides default
   209  // configuration when it is activated.
   210  type Profile struct {
   211  	Name   string       `yaml:"name"`
   212  	Build  BuildConfig  `yaml:"build,omitempty"`
   213  	Deploy DeployConfig `yaml:"deploy,omitempty"`
   214  }
   215  
   216  type ArtifactType struct {
   217  	DockerArtifact *DockerArtifact `yaml:"docker,omitempty" yamltags:"oneOf=artifact"`
   218  	BazelArtifact  *BazelArtifact  `yaml:"bazel,omitempty" yamltags:"oneOf=artifact"`
   219  }
   220  
   221  type DockerArtifact struct {
   222  	DockerfilePath string             `yaml:"dockerfilePath,omitempty"`
   223  	BuildArgs      map[string]*string `yaml:"buildArgs,omitempty"`
   224  	CacheFrom      []string           `yaml:"cacheFrom,omitempty"`
   225  	Target         string             `yaml:"target,omitempty"`
   226  }
   227  
   228  type BazelArtifact struct {
   229  	BuildTarget string `yaml:"target"`
   230  }