Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit f207685

Browse files
authored
🎁 Overridable images (#28)
* This makes the images overridable * Fixing lint issues * Update deps
1 parent c443dfb commit f207685

File tree

19 files changed

+786
-176
lines changed

19 files changed

+786
-176
lines changed

.golangci.yml

-7
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,3 @@ issues:
3636
- path: _test\.go
3737
linters:
3838
- wrapcheck
39-
40-
linters-settings:
41-
gci:
42-
# TODO: remove after golangci/golangci-lint#2588 is fixed
43-
sections:
44-
- standard
45-
- default

config/buildvars.go

-37
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,3 @@ package config
22

33
// BuildVariables will be passed to a Golang's ldflags for variable injection.
44
type BuildVariables map[string]Resolver
5-
6-
// BuildVariablesBuilder for a build variables.
7-
type BuildVariablesBuilder interface {
8-
// Add a key/value pair.
9-
Add(key string, resolver Resolver) BuildVariablesBuilder
10-
// ConditionallyAdd a key/value pair if cnd is true.
11-
ConditionallyAdd(cnd func() bool, key string, resolver Resolver) BuildVariablesBuilder
12-
// Build a build variables instance.
13-
Build() BuildVariables
14-
}
15-
16-
// NewBuildVariablesBuilder creates a new BuildVariablesBuilder.
17-
func NewBuildVariablesBuilder() BuildVariablesBuilder {
18-
return &defaultBuilder{
19-
bv: make(BuildVariables),
20-
}
21-
}
22-
23-
type defaultBuilder struct {
24-
bv BuildVariables
25-
}
26-
27-
func (d defaultBuilder) Add(key string, resolver Resolver) BuildVariablesBuilder {
28-
d.bv[key] = resolver
29-
return d
30-
}
31-
32-
func (d defaultBuilder) ConditionallyAdd(cnd func() bool, key string, resolver Resolver) BuildVariablesBuilder {
33-
if cnd() {
34-
return d.Add(key, resolver)
35-
}
36-
return d
37-
}
38-
39-
func (d defaultBuilder) Build() BuildVariables {
40-
return d.bv
41-
}

config/buildvars/assembler.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package buildvars
2+
3+
import "github.com/wavesoftware/go-magetasks/config"
4+
5+
// Operation performs some operation on Builder and return modified one.
6+
type Operation func(Builder) Builder
7+
8+
type Operator interface {
9+
Operation() Operation
10+
}
11+
12+
// Assemble will assemble a set of operations into the build variables.
13+
func Assemble(operators []Operator) config.BuildVariables {
14+
b := Builder{}
15+
for _, operator := range operators {
16+
b = operator.Operation()(b)
17+
}
18+
return b.Build()
19+
}

config/buildvars/builder.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package buildvars
2+
3+
import "github.com/wavesoftware/go-magetasks/config"
4+
5+
// Builder for a build variables.
6+
type Builder struct {
7+
bv config.BuildVariables
8+
}
9+
10+
// Add a key/value pair.
11+
func (b Builder) Add(key string, resolver config.Resolver) Builder {
12+
b.ensureBuildVariables()
13+
b.bv[key] = resolver
14+
return b
15+
}
16+
17+
// ConditionallyAdd a key/value pair if cnd is true.
18+
func (b Builder) ConditionallyAdd(cnd func() bool, key string, resolver config.Resolver) Builder {
19+
if cnd() {
20+
return b.Add(key, resolver)
21+
}
22+
return b
23+
}
24+
25+
// Build a build variables instance.
26+
func (b Builder) Build() config.BuildVariables {
27+
b.ensureBuildVariables()
28+
return b.bv
29+
}
30+
31+
func (b *Builder) ensureBuildVariables() {
32+
if b.bv == nil {
33+
b.bv = make(config.BuildVariables)
34+
}
35+
}

go.mod

+55-26
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/blang/semver/v4 v4.0.0
77
github.com/fatih/color v1.13.0
88
github.com/google/go-containerregistry v0.8.1-0.20220209165246-a44adc326839
9-
github.com/google/ko v0.9.4-0.20220216203347-3fc720f912ac
9+
github.com/google/ko v0.10.0
1010
github.com/hashicorp/go-multierror v1.1.1
1111
github.com/joho/godotenv v1.4.0
1212
github.com/magefile/mage v1.12.1
@@ -16,19 +16,25 @@ require (
1616
)
1717

1818
require (
19-
cloud.google.com/go v0.99.0 // indirect
20-
github.com/Azure/azure-sdk-for-go v55.8.0+incompatible // indirect
19+
cloud.google.com/go v0.100.2 // indirect
20+
cloud.google.com/go/compute v1.3.0 // indirect
21+
cloud.google.com/go/iam v0.2.0 // indirect
22+
cloud.google.com/go/storage v1.21.0 // indirect
23+
github.com/Azure/azure-sdk-for-go v61.5.0+incompatible // indirect
2124
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
22-
github.com/Azure/go-autorest/autorest v0.11.19 // indirect
23-
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
24-
github.com/Azure/go-autorest/autorest/azure/auth v0.5.8 // indirect
25-
github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 // indirect
25+
github.com/Azure/go-autorest/autorest v0.11.24 // indirect
26+
github.com/Azure/go-autorest/autorest/adal v0.9.18 // indirect
27+
github.com/Azure/go-autorest/autorest/azure/auth v0.5.11 // indirect
28+
github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 // indirect
2629
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
2730
github.com/Azure/go-autorest/logger v0.2.1 // indirect
2831
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
29-
github.com/BurntSushi/toml v0.4.1 // indirect
30-
github.com/Microsoft/go-winio v0.5.1 // indirect
32+
github.com/BurntSushi/toml v1.0.0 // indirect
33+
github.com/Microsoft/go-winio v0.5.2 // indirect
34+
github.com/PuerkitoBio/purell v1.1.1 // indirect
35+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
3136
github.com/alessio/shellescape v1.4.1 // indirect
37+
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
3238
github.com/aws/aws-sdk-go-v2 v1.13.0 // indirect
3339
github.com/aws/aws-sdk-go-v2/config v1.13.1 // indirect
3440
github.com/aws/aws-sdk-go-v2/credentials v1.8.0 // indirect
@@ -44,69 +50,92 @@ require (
4450
github.com/aws/smithy-go v1.10.0 // indirect
4551
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220216180153-3d7835abdf40 // indirect
4652
github.com/chrismellard/docker-credential-acr-env v0.0.0-20220119192733-fe33c00cee21 // indirect
47-
github.com/containerd/containerd v1.5.9 // indirect
53+
github.com/containerd/containerd v1.6.0 // indirect
4854
github.com/containerd/stargz-snapshotter/estargz v0.11.0 // indirect
4955
github.com/dimchansky/utfbom v1.1.1 // indirect
5056
github.com/docker/cli v20.10.12+incompatible // indirect
51-
github.com/docker/distribution v2.7.1+incompatible // indirect
57+
github.com/docker/distribution v2.8.0+incompatible // indirect
5258
github.com/docker/docker v20.10.12+incompatible // indirect
5359
github.com/docker/docker-credential-helpers v0.6.4 // indirect
5460
github.com/docker/go-connections v0.4.0 // indirect
5561
github.com/docker/go-units v0.4.0 // indirect
5662
github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960 // indirect
57-
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
58-
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
63+
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
5964
github.com/fsnotify/fsnotify v1.5.1 // indirect
60-
github.com/go-logr/logr v1.2.0 // indirect
65+
github.com/go-logr/logr v1.2.2 // indirect
66+
github.com/go-openapi/analysis v0.21.2 // indirect
67+
github.com/go-openapi/errors v0.20.2 // indirect
68+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
69+
github.com/go-openapi/jsonreference v0.19.6 // indirect
70+
github.com/go-openapi/loads v0.21.1 // indirect
71+
github.com/go-openapi/runtime v0.23.0 // indirect
72+
github.com/go-openapi/spec v0.20.4 // indirect
73+
github.com/go-openapi/strfmt v0.21.2 // indirect
74+
github.com/go-openapi/swag v0.21.1 // indirect
75+
github.com/go-openapi/validate v0.20.3 // indirect
76+
github.com/go-stack/stack v1.8.1 // indirect
6177
github.com/gogo/protobuf v1.3.2 // indirect
78+
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
79+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
6280
github.com/golang/protobuf v1.5.2 // indirect
81+
github.com/golang/snappy v0.0.4 // indirect
6382
github.com/google/go-cmp v0.5.7 // indirect
83+
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
6484
github.com/hashicorp/errwrap v1.1.0 // indirect
6585
github.com/hashicorp/hcl v1.0.0 // indirect
6686
github.com/inconshreveable/mousetrap v1.0.0 // indirect
6787
github.com/jmespath/go-jmespath v0.4.0 // indirect
68-
github.com/klauspost/compress v1.14.2 // indirect
88+
github.com/josharian/intern v1.0.0 // indirect
89+
github.com/klauspost/compress v1.14.3 // indirect
6990
github.com/magiconair/properties v1.8.5 // indirect
91+
github.com/mailru/easyjson v0.7.7 // indirect
7092
github.com/mattmoor/dep-notify v0.0.0-20190205035814-a45dec370a17 // indirect
7193
github.com/mattn/go-colorable v0.1.12 // indirect
7294
github.com/mattn/go-isatty v0.0.14 // indirect
7395
github.com/mitchellh/go-homedir v1.1.0 // indirect
7496
github.com/mitchellh/mapstructure v1.4.3 // indirect
97+
github.com/oklog/ulid v1.3.1 // indirect
7598
github.com/opencontainers/go-digest v1.0.0 // indirect
7699
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect
77100
github.com/pelletier/go-toml v1.9.4 // indirect
78101
github.com/pkg/errors v0.9.1 // indirect
79-
github.com/sigstore/cosign v1.3.2-0.20211120003522-90e2dcfe7b92 // indirect
80-
github.com/sigstore/sigstore v1.0.2-0.20211115214857-534e133ebf9d // indirect
102+
github.com/secure-systems-lab/go-securesystemslib v0.3.0 // indirect
103+
github.com/sigstore/cosign v1.5.1 // indirect
104+
github.com/sigstore/rekor v0.5.0 // indirect
105+
github.com/sigstore/sigstore v1.1.1-0.20220130134424-bae9b66b8442 // indirect
81106
github.com/sirupsen/logrus v1.8.1 // indirect
82-
github.com/spf13/afero v1.6.0 // indirect
107+
github.com/spf13/afero v1.8.1 // indirect
83108
github.com/spf13/cast v1.4.1 // indirect
84109
github.com/spf13/cobra v1.3.0 // indirect
85110
github.com/spf13/jwalterweatherman v1.1.0 // indirect
86111
github.com/spf13/pflag v1.0.5 // indirect
87112
github.com/spf13/viper v1.10.1 // indirect
88113
github.com/subosito/gotenv v1.2.0 // indirect
89-
github.com/theupdateframework/go-tuf v0.0.0-20210722233521-90e262754396 // indirect
114+
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
115+
github.com/theupdateframework/go-tuf v0.0.0-20220211205608-f0c3294f63b9 // indirect
90116
github.com/vbatts/tar-split v0.11.2 // indirect
91-
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
92-
golang.org/x/net v0.0.0-20220127074510-2fabfed7e28f // indirect
117+
go.mongodb.org/mongo-driver v1.8.3 // indirect
118+
go.opencensus.io v0.23.0 // indirect
119+
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
120+
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
93121
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
94122
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
95123
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
96124
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
97125
golang.org/x/text v0.3.7 // indirect
98126
golang.org/x/tools v0.1.9 // indirect
99127
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
128+
google.golang.org/api v0.69.0 // indirect
100129
google.golang.org/appengine v1.6.7 // indirect
101-
google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350 // indirect
130+
google.golang.org/genproto v0.0.0-20220217155828-d576998c0009 // indirect
102131
google.golang.org/grpc v1.44.0 // indirect
103132
google.golang.org/protobuf v1.27.1 // indirect
104-
gopkg.in/ini.v1 v1.66.2 // indirect
133+
gopkg.in/ini.v1 v1.66.4 // indirect
105134
gopkg.in/yaml.v2 v2.4.0 // indirect
106135
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
107-
k8s.io/apimachinery v0.23.3 // indirect
108-
k8s.io/klog/v2 v2.30.0 // indirect
109-
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
136+
k8s.io/apimachinery v0.23.4 // indirect
137+
k8s.io/klog/v2 v2.40.1 // indirect
138+
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
110139
sigs.k8s.io/kind v0.11.1 // indirect
111140
sigs.k8s.io/yaml v1.3.0 // indirect
112141
)

0 commit comments

Comments
 (0)