github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/inspect/types.go (about) 1 /* 2 Copyright 2021 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 inspect 18 19 import ( 20 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/parser" 21 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" 22 ) 23 24 // Options holds flag values for the various `skaffold inspect` commands 25 type Options struct { 26 // Filename is the `skaffold.yaml` file path 27 Filename string 28 // RepoCacheDir is the directory for the remote git repository cache 29 RepoCacheDir string 30 // OutFormat is the output format. One of: json 31 OutFormat string 32 // Modules is the module filter for specific commands 33 Modules []string 34 // Profiles is the slice of profile names to activate. 35 Profiles []string 36 // Profile is a target profile to create or edit 37 Profile string 38 // PropagateProfiles specifies if profiles specified by the '--profile' flag should be searched across config dependencies. Otherwise only profiles defined directly in the target 'skaffold.yaml' file are activated. 39 PropagateProfiles bool 40 // Strict specifies the error-tolerance for specific commands 41 Strict bool 42 43 ModulesOptions 44 ProfilesOptions 45 BuildEnvOptions 46 } 47 48 // ModulesOptions holds flag values for various `skaffold inspect modules` commands 49 type ModulesOptions struct { 50 // IncludeAll specifies if unnamed modules should be included in the output list 51 IncludeAll bool 52 } 53 54 // ProfilesOptions holds flag values for various `skaffold inspect profiles` commands 55 type ProfilesOptions struct { 56 // BuildEnv is the build-env filter for command output. One of: local, googleCloudBuild, cluster. 57 BuildEnv BuildEnv 58 } 59 60 // BuildEnvOptions holds flag values for various `skaffold inspect build-env` commands 61 type BuildEnvOptions struct { 62 // Push specifies if images should be pushed to a registry. 63 Push *bool 64 // TryImportMissing specifies whether to attempt to import artifacts from Docker (either a local or remote registry) if not in the cache 65 TryImportMissing *bool 66 // UseDockerCLI specifies to use `docker` command-line interface instead of Docker Engine APIs 67 UseDockerCLI *bool 68 // UseBuildkit specifies to use Buildkit to build Docker images 69 UseBuildkit *bool 70 // ProjectID is the GCP project ID 71 ProjectID string 72 // DiskSizeGb is the disk size of the VM that runs the build 73 DiskSizeGb int64 74 // MachineType is the type of VM that runs the build 75 MachineType string 76 // Timeout is the build timeout (in seconds) 77 Timeout string 78 // Concurrency is the number of artifacts to build concurrently. 0 means "no-limit" 79 Concurrency int 80 // PullSecretPath is the path to the Google Cloud service account secret key file. 81 PullSecretPath string 82 // PullSecretName is the name of the Kubernetes secret for pulling base images 83 // and pushing the final image. 84 PullSecretName string 85 // PullSecretMountPath is the path the pull secret will be mounted at within the running container. 86 PullSecretMountPath string 87 // Namespace is the Kubernetes namespace. 88 Namespace string 89 // DockerConfigPath is the path to the docker `config.json`. 90 DockerConfigPath string 91 // DockerConfigSecretName is the Kubernetes secret that contains the `config.json` Docker configuration. 92 DockerConfigSecretName string 93 // ServiceAccount describes the Kubernetes service account to use for the pod. 94 ServiceAccount string 95 // RunAsUser defines the UID to request for running the container. 96 RunAsUser int64 97 // RandomPullSecret adds a random UUID postfix to the default name of the pull secret to facilitate parallel builds, e.g. kaniko-secretdocker-cfgfd154022-c761-416f-8eb3-cf8258450b85. 98 RandomPullSecret bool 99 // RandomDockerConfigSecret adds a random UUID postfix to the default name of the docker secret to facilitate parallel builds, e.g. docker-cfgfd154022-c761-416f-8eb3-cf8258450b85. 100 RandomDockerConfigSecret bool 101 // Logging specifies the logging mode. 102 Logging string 103 // LogStreamingOption specifies the behavior when writing build logs to Google Cloud Storage. 104 LogStreamingOption string 105 // WorkerPool configures a pool of workers to run the build. 106 WorkerPool string 107 } 108 109 type BuildEnv string 110 111 var ( 112 GetConfigSet = parser.GetConfigSet 113 BuildEnvs = struct { 114 Unspecified BuildEnv 115 Local BuildEnv 116 GoogleCloudBuild BuildEnv 117 Cluster BuildEnv 118 }{ 119 Local: "local", GoogleCloudBuild: "googleCloudBuild", Cluster: "cluster", 120 } 121 ) 122 123 func GetBuildEnv(t *latest.BuildType) BuildEnv { 124 switch { 125 case t.Cluster != nil: 126 return BuildEnvs.Cluster 127 case t.GoogleCloudBuild != nil: 128 return BuildEnvs.GoogleCloudBuild 129 default: 130 return BuildEnvs.Local 131 } 132 }