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