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

Commit

Permalink
🎁 Overridable images (#28)
Browse files Browse the repository at this point in the history
* This makes the images overridable

* Fixing lint issues

* Update deps
  • Loading branch information
cardil authored Feb 18, 2022
1 parent c443dfb commit f207685
Show file tree
Hide file tree
Showing 19 changed files with 786 additions and 176 deletions.
7 changes: 0 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,3 @@ issues:
- path: _test\.go
linters:
- wrapcheck

linters-settings:
gci:
# TODO: remove after golangci/golangci-lint#2588 is fixed
sections:
- standard
- default
37 changes: 0 additions & 37 deletions config/buildvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,3 @@ package config

// BuildVariables will be passed to a Golang's ldflags for variable injection.
type BuildVariables map[string]Resolver

// BuildVariablesBuilder for a build variables.
type BuildVariablesBuilder interface {
// Add a key/value pair.
Add(key string, resolver Resolver) BuildVariablesBuilder
// ConditionallyAdd a key/value pair if cnd is true.
ConditionallyAdd(cnd func() bool, key string, resolver Resolver) BuildVariablesBuilder
// Build a build variables instance.
Build() BuildVariables
}

// NewBuildVariablesBuilder creates a new BuildVariablesBuilder.
func NewBuildVariablesBuilder() BuildVariablesBuilder {
return &defaultBuilder{
bv: make(BuildVariables),
}
}

type defaultBuilder struct {
bv BuildVariables
}

func (d defaultBuilder) Add(key string, resolver Resolver) BuildVariablesBuilder {
d.bv[key] = resolver
return d
}

func (d defaultBuilder) ConditionallyAdd(cnd func() bool, key string, resolver Resolver) BuildVariablesBuilder {
if cnd() {
return d.Add(key, resolver)
}
return d
}

func (d defaultBuilder) Build() BuildVariables {
return d.bv
}
19 changes: 19 additions & 0 deletions config/buildvars/assembler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package buildvars

import "github.com/wavesoftware/go-magetasks/config"

// Operation performs some operation on Builder and return modified one.
type Operation func(Builder) Builder

type Operator interface {
Operation() Operation
}

// Assemble will assemble a set of operations into the build variables.
func Assemble(operators []Operator) config.BuildVariables {
b := Builder{}
for _, operator := range operators {
b = operator.Operation()(b)
}
return b.Build()
}
35 changes: 35 additions & 0 deletions config/buildvars/builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package buildvars

import "github.com/wavesoftware/go-magetasks/config"

// Builder for a build variables.
type Builder struct {
bv config.BuildVariables
}

// Add a key/value pair.
func (b Builder) Add(key string, resolver config.Resolver) Builder {
b.ensureBuildVariables()
b.bv[key] = resolver
return b
}

// ConditionallyAdd a key/value pair if cnd is true.
func (b Builder) ConditionallyAdd(cnd func() bool, key string, resolver config.Resolver) Builder {
if cnd() {
return b.Add(key, resolver)
}
return b
}

// Build a build variables instance.
func (b Builder) Build() config.BuildVariables {
b.ensureBuildVariables()
return b.bv
}

func (b *Builder) ensureBuildVariables() {
if b.bv == nil {
b.bv = make(config.BuildVariables)
}
}
81 changes: 55 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/blang/semver/v4 v4.0.0
github.com/fatih/color v1.13.0
github.com/google/go-containerregistry v0.8.1-0.20220209165246-a44adc326839
github.com/google/ko v0.9.4-0.20220216203347-3fc720f912ac
github.com/google/ko v0.10.0
github.com/hashicorp/go-multierror v1.1.1
github.com/joho/godotenv v1.4.0
github.com/magefile/mage v1.12.1
Expand All @@ -16,19 +16,25 @@ require (
)

require (
cloud.google.com/go v0.99.0 // indirect
github.com/Azure/azure-sdk-for-go v55.8.0+incompatible // indirect
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/compute v1.3.0 // indirect
cloud.google.com/go/iam v0.2.0 // indirect
cloud.google.com/go/storage v1.21.0 // indirect
github.com/Azure/azure-sdk-for-go v61.5.0+incompatible // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.19 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.5.8 // indirect
github.com/Azure/go-autorest/autorest/azure/cli v0.4.2 // indirect
github.com/Azure/go-autorest/autorest v0.11.24 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.18 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.5.11 // indirect
github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/BurntSushi/toml v0.4.1 // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/BurntSushi/toml v1.0.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aws/aws-sdk-go-v2 v1.13.0 // indirect
github.com/aws/aws-sdk-go-v2/config v1.13.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.8.0 // indirect
Expand All @@ -44,69 +50,92 @@ require (
github.com/aws/smithy-go v1.10.0 // indirect
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220216180153-3d7835abdf40 // indirect
github.com/chrismellard/docker-credential-acr-env v0.0.0-20220119192733-fe33c00cee21 // indirect
github.com/containerd/containerd v1.5.9 // indirect
github.com/containerd/containerd v1.6.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.11.0 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/docker/cli v20.10.12+incompatible // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/distribution v2.8.0+incompatible // indirect
github.com/docker/docker v20.10.12+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960 // indirect
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-logr/logr v1.2.2 // indirect
github.com/go-openapi/analysis v0.21.2 // indirect
github.com/go-openapi/errors v0.20.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/loads v0.21.1 // indirect
github.com/go-openapi/runtime v0.23.0 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/strfmt v0.21.2 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-openapi/validate v0.20.3 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.14.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.14.3 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattmoor/dep-notify v0.0.0-20190205035814-a45dec370a17 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sigstore/cosign v1.3.2-0.20211120003522-90e2dcfe7b92 // indirect
github.com/sigstore/sigstore v1.0.2-0.20211115214857-534e133ebf9d // indirect
github.com/secure-systems-lab/go-securesystemslib v0.3.0 // indirect
github.com/sigstore/cosign v1.5.1 // indirect
github.com/sigstore/rekor v0.5.0 // indirect
github.com/sigstore/sigstore v1.1.1-0.20220130134424-bae9b66b8442 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/afero v1.8.1 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cobra v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.10.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/theupdateframework/go-tuf v0.0.0-20210722233521-90e262754396 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/theupdateframework/go-tuf v0.0.0-20220211205608-f0c3294f63b9 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
golang.org/x/net v0.0.0-20220127074510-2fabfed7e28f // indirect
go.mongodb.org/mongo-driver v1.8.3 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.9 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/api v0.69.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350 // indirect
google.golang.org/genproto v0.0.0-20220217155828-d576998c0009 // indirect
google.golang.org/grpc v1.44.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apimachinery v0.23.3 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
k8s.io/apimachinery v0.23.4 // indirect
k8s.io/klog/v2 v2.40.1 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/kind v0.11.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit f207685

Please sign in to comment.