github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/build/cluster/types.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 cluster 18 19 import ( 20 "context" 21 "fmt" 22 "io" 23 "time" 24 25 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/build" 26 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/config" 27 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker" 28 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubectl" 29 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/platform" 30 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" 31 ) 32 33 // Builder builds docker artifacts on Kubernetes. 34 type Builder struct { 35 *latest.ClusterDetails 36 37 cfg Config 38 kubectlcli *kubectl.CLI 39 mode config.RunMode 40 timeout time.Duration 41 artifactStore build.ArtifactStore 42 teardownFunc []func() 43 skipTests bool 44 } 45 46 type Config interface { 47 kubectl.Config 48 docker.Config 49 50 GetKubeContext() string 51 Muted() config.Muted 52 Mode() config.RunMode 53 SkipTests() bool 54 } 55 56 type BuilderContext interface { 57 Config 58 ArtifactStore() build.ArtifactStore 59 } 60 61 // NewBuilder creates a new Builder that builds artifacts on cluster. 62 func NewBuilder(bCtx BuilderContext, buildCfg *latest.ClusterDetails) (*Builder, error) { 63 timeout, err := time.ParseDuration(buildCfg.Timeout) 64 if err != nil { 65 return nil, fmt.Errorf("parsing timeout: %w", err) 66 } 67 68 return &Builder{ 69 ClusterDetails: buildCfg, 70 cfg: bCtx, 71 kubectlcli: kubectl.NewCLI(bCtx, ""), 72 mode: bCtx.Mode(), 73 timeout: timeout, 74 artifactStore: bCtx.ArtifactStore(), 75 skipTests: bCtx.SkipTests(), 76 }, nil 77 } 78 79 func (b *Builder) Prune(ctx context.Context, out io.Writer) error { 80 return nil 81 } 82 83 func (b *Builder) PushImages() bool { return true } 84 85 func (b *Builder) SupportedPlatforms() platform.Matcher { 86 return platform.All 87 }