github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/build/build.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 build 18 19 import ( 20 "context" 21 "io" 22 23 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph" 24 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/platform" 25 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest" 26 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/tag" 27 ) 28 29 // Builder is an interface to the Build API of Skaffold. 30 // It must build and make the resulting image accessible to the cluster. 31 // This could include pushing to a authorized repository or loading the nodes with the image. 32 // If artifacts is supplied, the builder should only rebuild those artifacts. 33 type Builder interface { 34 Build(ctx context.Context, out io.Writer, tags tag.ImageTags, platforms platform.Resolver, artifacts []*latest.Artifact) ([]graph.Artifact, error) 35 36 // Prune removes images built with Skaffold 37 Prune(context.Context, io.Writer) error 38 } 39 40 // PipelineBuilder is an interface for a specific Skaffold config pipeline build type. 41 // Current implementations are the `local`, `cluster` and `gcb` 42 type PipelineBuilder interface { 43 44 // PreBuild executes any one-time setup required prior to starting any build on this builder 45 PreBuild(ctx context.Context, out io.Writer) error 46 47 // Build returns the `ArtifactBuilder` based on this build pipeline type 48 Build(ctx context.Context, out io.Writer, artifact *latest.Artifact) ArtifactBuilder 49 50 // PostBuild executes any one-time teardown required after all builds on this builder are complete 51 PostBuild(ctx context.Context, out io.Writer) error 52 53 // Concurrency specifies the max number of builds that can run at any one time. If concurrency is 0, then all builds can run in parallel. 54 Concurrency() *int 55 56 // Prune removes images built in this pipeline 57 Prune(context.Context, io.Writer) error 58 59 // PushImages specifies if the built image needs to be explicitly pushed to an image registry. 60 PushImages() bool 61 62 // SupportedPlatforms returns the platforms supported for building the image by this build pipeline type. 63 SupportedPlatforms() platform.Matcher 64 } 65 66 type ErrSyncMapNotSupported struct{} 67 68 func (ErrSyncMapNotSupported) Error() string { 69 return "SyncMap is not supported by this builder" 70 } 71 72 type ErrCustomBuildNoDockerfile struct{} 73 74 func (ErrCustomBuildNoDockerfile) Error() string { 75 return "inferred sync with custom build requires explicitly declared Dockerfile dependency" 76 }