github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/schema/v1beta1/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 v1beta1
    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/v1beta1"
    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  	Test     TestConfig   `yaml:"test,omitempty"`
    37  	Deploy   DeployConfig `yaml:"deploy,omitempty"`
    38  	Profiles []Profile    `yaml:"profiles,omitempty"`
    39  }
    40  
    41  func (c *SkaffoldConfig) GetVersion() string {
    42  	return c.APIVersion
    43  }
    44  
    45  // BuildConfig contains all the configuration for the build steps
    46  type BuildConfig struct {
    47  	Artifacts []*Artifact `yaml:"artifacts,omitempty"`
    48  	TagPolicy TagPolicy   `yaml:"tagPolicy,omitempty"`
    49  	BuildType `yaml:",inline"`
    50  }
    51  
    52  // TagPolicy contains all the configuration for the tagging step
    53  type TagPolicy struct {
    54  	GitTagger         *GitTagger         `yaml:"gitCommit,omitempty" yamltags:"oneOf=tag"`
    55  	ShaTagger         *ShaTagger         `yaml:"sha256,omitempty" yamltags:"oneOf=tag"`
    56  	EnvTemplateTagger *EnvTemplateTagger `yaml:"envTemplate,omitempty" yamltags:"oneOf=tag"`
    57  	DateTimeTagger    *DateTimeTagger    `yaml:"dateTime,omitempty" yamltags:"oneOf=tag"`
    58  }
    59  
    60  // ShaTagger contains the configuration for the SHA tagger.
    61  type ShaTagger struct{}
    62  
    63  // GitTagger contains the configuration for the git tagger.
    64  type GitTagger struct{}
    65  
    66  // EnvTemplateTagger contains the configuration for the envTemplate tagger.
    67  type EnvTemplateTagger struct {
    68  	Template string `yaml:"template,omitempty"`
    69  }
    70  
    71  // DateTimeTagger contains the configuration for the DateTime tagger.
    72  type DateTimeTagger struct {
    73  	Format   string `yaml:"format,omitempty"`
    74  	TimeZone string `yaml:"timezone,omitempty"`
    75  }
    76  
    77  // BuildType contains the specific implementation and parameters needed
    78  // for the build step. Only one field should be populated.
    79  type BuildType struct {
    80  	LocalBuild       *LocalBuild       `yaml:"local,omitempty" yamltags:"oneOf=build"`
    81  	GoogleCloudBuild *GoogleCloudBuild `yaml:"googleCloudBuild,omitempty" yamltags:"oneOf=build"`
    82  	KanikoBuild      *KanikoBuild      `yaml:"kaniko,omitempty" yamltags:"oneOf=build"`
    83  }
    84  
    85  // LocalBuild contains the fields needed to do a build on the local docker daemon
    86  // and optionally push to a repository.
    87  type LocalBuild struct {
    88  	Push         *bool `yaml:"push,omitempty"`
    89  	UseDockerCLI bool  `yaml:"useDockerCLI,omitempty"`
    90  	UseBuildkit  bool  `yaml:"useBuildkit,omitempty"`
    91  }
    92  
    93  // GoogleCloudBuild contains the fields needed to do a remote build on
    94  // Google Cloud Build.
    95  type GoogleCloudBuild struct {
    96  	ProjectID   string `yaml:"projectId,omitempty"`
    97  	DiskSizeGb  int64  `yaml:"diskSizeGb,omitempty"`
    98  	MachineType string `yaml:"machineType,omitempty"`
    99  	Timeout     string `yaml:"timeout,omitempty"`
   100  	DockerImage string `yaml:"dockerImage,omitempty"`
   101  }
   102  
   103  // LocalDir represents the local directory kaniko build context
   104  type LocalDir struct {
   105  }
   106  
   107  // KanikoBuildContext contains the different fields available to specify
   108  // a kaniko build context
   109  type KanikoBuildContext struct {
   110  	GCSBucket string    `yaml:"gcsBucket,omitempty" yamltags:"oneOf=buildContext"`
   111  	LocalDir  *LocalDir `yaml:"localDir,omitempty" yamltags:"oneOf=buildContext"`
   112  }
   113  
   114  // KanikoCache contains fields related to kaniko caching
   115  type KanikoCache struct {
   116  	Repo string `yaml:"repo,omitempty"`
   117  }
   118  
   119  // KanikoBuild contains the fields needed to do a on-cluster build using
   120  // the kaniko image
   121  type KanikoBuild struct {
   122  	BuildContext   *KanikoBuildContext `yaml:"buildContext,omitempty"`
   123  	Cache          *KanikoCache        `yaml:"cache,omitempty"`
   124  	PullSecret     string              `yaml:"pullSecret,omitempty"`
   125  	PullSecretName string              `yaml:"pullSecretName,omitempty"`
   126  	Namespace      string              `yaml:"namespace,omitempty"`
   127  	Timeout        string              `yaml:"timeout,omitempty"`
   128  	Image          string              `yaml:"image,omitempty"`
   129  }
   130  
   131  type TestConfig []*TestCase
   132  
   133  // TestCase is a struct containing all the specified test
   134  // configuration for an image.
   135  type TestCase struct {
   136  	ImageName      string   `yaml:"image"`
   137  	StructureTests []string `yaml:"structureTests,omitempty"`
   138  }
   139  
   140  // DeployConfig contains all the configuration needed by the deploy steps
   141  type DeployConfig struct {
   142  	DeployType `yaml:",inline"`
   143  }
   144  
   145  // DeployType contains the specific implementation and parameters needed
   146  // for the deploy step. Only one field should be populated.
   147  type DeployType struct {
   148  	HelmDeploy      *HelmDeploy      `yaml:"helm,omitempty" yamltags:"oneOf=deploy"`
   149  	KubectlDeploy   *KubectlDeploy   `yaml:"kubectl,omitempty" yamltags:"oneOf=deploy"`
   150  	KustomizeDeploy *KustomizeDeploy `yaml:"kustomize,omitempty" yamltags:"oneOf=deploy"`
   151  }
   152  
   153  // KubectlDeploy contains the configuration needed for deploying with `kubectl apply`
   154  type KubectlDeploy struct {
   155  	Manifests       []string     `yaml:"manifests,omitempty"`
   156  	RemoteManifests []string     `yaml:"remoteManifests,omitempty"`
   157  	Flags           KubectlFlags `yaml:"flags,omitempty"`
   158  }
   159  
   160  // KubectlFlags describes additional options flags that are passed on the command
   161  // line to kubectl either on every command (Global), on creations (Apply)
   162  // or deletions (Delete).
   163  type KubectlFlags struct {
   164  	Global []string `yaml:"global,omitempty"`
   165  	Apply  []string `yaml:"apply,omitempty"`
   166  	Delete []string `yaml:"delete,omitempty"`
   167  }
   168  
   169  // HelmDeploy contains the configuration needed for deploying with helm
   170  type HelmDeploy struct {
   171  	Releases []HelmRelease `yaml:"releases,omitempty"`
   172  }
   173  
   174  // KustomizeDeploy contains the configuration needed for deploying with kustomize.
   175  type KustomizeDeploy struct {
   176  	KustomizePath string       `yaml:"path,omitempty"`
   177  	Flags         KubectlFlags `yaml:"flags,omitempty"`
   178  }
   179  
   180  type HelmRelease struct {
   181  	Name              string             `yaml:"name,omitempty"`
   182  	ChartPath         string             `yaml:"chartPath,omitempty"`
   183  	ValuesFiles       []string           `yaml:"valuesFiles,omitempty"`
   184  	Values            map[string]string  `yaml:"values,omitempty,omitempty"`
   185  	Namespace         string             `yaml:"namespace,omitempty"`
   186  	Version           string             `yaml:"version,omitempty"`
   187  	SetValues         map[string]string  `yaml:"setValues,omitempty"`
   188  	SetValueTemplates map[string]string  `yaml:"setValueTemplates,omitempty"`
   189  	Wait              bool               `yaml:"wait,omitempty"`
   190  	RecreatePods      bool               `yaml:"recreatePods,omitempty"`
   191  	Overrides         util.HelmOverrides `yaml:"overrides,omitempty"`
   192  	Packaged          *HelmPackaged      `yaml:"packaged,omitempty"`
   193  	ImageStrategy     HelmImageStrategy  `yaml:"imageStrategy,omitempty"`
   194  }
   195  
   196  // HelmPackaged represents parameters for packaging helm chart.
   197  type HelmPackaged struct {
   198  	// Version sets the version on the chart to this semver version.
   199  	Version string `yaml:"version,omitempty"`
   200  
   201  	// AppVersion set the appVersion on the chart to this version
   202  	AppVersion string `yaml:"appVersion,omitempty"`
   203  }
   204  
   205  type HelmImageStrategy struct {
   206  	HelmImageConfig `yaml:",inline"`
   207  }
   208  
   209  type HelmImageConfig struct {
   210  	HelmFQNConfig        *HelmFQNConfig        `yaml:"fqn,omitempty" yamltags:"oneOf=helmImageStrategy"`
   211  	HelmConventionConfig *HelmConventionConfig `yaml:"helm,omitempty" yamltags:"oneOf=helmImageStrategy"`
   212  }
   213  
   214  // HelmFQNConfig represents image config to use the FullyQualifiedImageName as param to set
   215  type HelmFQNConfig struct {
   216  	Property string `yaml:"property,omitempty"`
   217  }
   218  
   219  // HelmConventionConfig represents image config in the syntax of image.repository and image.tag
   220  type HelmConventionConfig struct {
   221  }
   222  
   223  // Artifact represents items that need to be built, along with the context in which
   224  // they should be built.
   225  type Artifact struct {
   226  	ImageName    string            `yaml:"image,omitempty"`
   227  	Workspace    string            `yaml:"context,omitempty"`
   228  	Sync         map[string]string `yaml:"sync,omitempty"`
   229  	ArtifactType `yaml:",inline"`
   230  }
   231  
   232  // Profile is additional configuration that overrides default
   233  // configuration when it is activated.
   234  type Profile struct {
   235  	Name   string       `yaml:"name,omitempty"`
   236  	Build  BuildConfig  `yaml:"build,omitempty"`
   237  	Test   TestConfig   `yaml:"test,omitempty"`
   238  	Deploy DeployConfig `yaml:"deploy,omitempty"`
   239  }
   240  
   241  type ArtifactType struct {
   242  	DockerArtifact    *DockerArtifact    `yaml:"docker,omitempty" yamltags:"oneOf=artifact"`
   243  	BazelArtifact     *BazelArtifact     `yaml:"bazel,omitempty" yamltags:"oneOf=artifact"`
   244  	JibMavenArtifact  *JibMavenArtifact  `yaml:"jibMaven,omitempty" yamltags:"oneOf=artifact"`
   245  	JibGradleArtifact *JibGradleArtifact `yaml:"jibGradle,omitempty" yamltags:"oneOf=artifact"`
   246  }
   247  
   248  // DockerArtifact describes an artifact built from a Dockerfile,
   249  // usually using `docker build`.
   250  type DockerArtifact struct {
   251  	DockerfilePath string             `yaml:"dockerfile,omitempty"`
   252  	BuildArgs      map[string]*string `yaml:"buildArgs,omitempty"`
   253  	CacheFrom      []string           `yaml:"cacheFrom,omitempty"`
   254  	Target         string             `yaml:"target,omitempty"`
   255  }
   256  
   257  // BazelArtifact describes an artifact built with Bazel.
   258  type BazelArtifact struct {
   259  	BuildTarget string   `yaml:"target,omitempty"`
   260  	BuildArgs   []string `yaml:"args,omitempty"`
   261  }
   262  
   263  type JibMavenArtifact struct {
   264  	// Only multi-module
   265  	Module  string `yaml:"module,omitempty"`
   266  	Profile string `yaml:"profile,omitempty"`
   267  }
   268  
   269  type JibGradleArtifact struct {
   270  	// Only multi-module
   271  	Project string `yaml:"project,omitempty"`
   272  }