/
types.go
118 lines (96 loc) · 3.8 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
Copyright 2019 The Skaffold Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package gcb
import (
"context"
"io"
"time"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/jib"
runcontext "github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/context"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/pkg/errors"
)
const (
// StatusUnknown "STATUS_UNKNOWN" - Status of the build is unknown.
StatusUnknown = "STATUS_UNKNOWN"
// StatusQueued "QUEUED" - Build is queued; work has not yet begun.
StatusQueued = "QUEUED"
// StatusWorking "WORKING" - Build is being executed.
StatusWorking = "WORKING"
// StatusSuccess "SUCCESS" - Build finished successfully.
StatusSuccess = "SUCCESS"
// StatusFailure "FAILURE" - Build failed to complete successfully.
StatusFailure = "FAILURE"
// StatusInternalError "INTERNAL_ERROR" - Build failed due to an internal cause.
StatusInternalError = "INTERNAL_ERROR"
// StatusTimeout "TIMEOUT" - Build took longer than was allowed.
StatusTimeout = "TIMEOUT"
// StatusCancelled "CANCELLED" - Build was canceled by a user.
StatusCancelled = "CANCELLED"
// RetryDelay is the time to wait in between polling the status of the cloud build
RetryDelay = 1 * time.Second
)
// Builder builds artifacts with Google Cloud Build.
type Builder struct {
*latest.GoogleCloudBuild
skipTests bool
insecureRegistries map[string]bool
}
// NewBuilder creates a new Builder that builds artifacts with Google Cloud Build.
func NewBuilder(runCtx *runcontext.RunContext) *Builder {
return &Builder{
GoogleCloudBuild: runCtx.Cfg.Build.GoogleCloudBuild,
skipTests: runCtx.Opts.SkipTests,
insecureRegistries: runCtx.InsecureRegistries,
}
}
// Labels are labels specific to Google Cloud Build.
func (b *Builder) Labels() map[string]string {
return map[string]string{
constants.Labels.Builder: "google-cloud-build",
}
}
// DependenciesForArtifact returns the dependencies for this artifact
func (b *Builder) DependenciesForArtifact(ctx context.Context, a *latest.Artifact) ([]string, error) {
var paths []string
var err error
if a.DockerArtifact != nil {
paths, err = docker.GetDependencies(ctx, a.Workspace, a.DockerArtifact.DockerfilePath, a.DockerArtifact.BuildArgs, b.insecureRegistries)
if err != nil {
return nil, errors.Wrapf(err, "getting dependencies for %s", a.ImageName)
}
}
if a.JibMavenArtifact != nil {
paths, err = jib.GetDependenciesMaven(ctx, a.Workspace, a.JibMavenArtifact)
if err != nil {
return nil, errors.Wrapf(err, "getting dependencies for %s", a.ImageName)
}
}
if a.JibGradleArtifact != nil {
paths, err = jib.GetDependenciesGradle(ctx, a.Workspace, a.JibGradleArtifact)
if err != nil {
return nil, errors.Wrapf(err, "getting dependencies for %s", a.ImageName)
}
}
return util.AbsolutePaths(a.Workspace, paths), nil
}
func (b *Builder) Prune(ctx context.Context, out io.Writer) error {
return nil // noop
}
func (b *Builder) SyncMap(ctx context.Context, artifact *latest.Artifact) (map[string][]string, error) {
return nil, build.ErrSyncMapNotSupported{}
}