Skip to content

Commit 9e41487

Browse files
authored
Support compose depends_on with condition: service_completed_successfully (#24)
* Support compose `depends_on` with `condition: service_completed_successfully` * Add --event-diffs, -v to show event diffs as they come in from k8s. Very useful for debugging k8s internals. * go.mod: update after `mod tidy` * CI: test-job: skip go/load-cache, this seems to load old/incorrect versions * Bump to libs docker v25.0.4, go-dockerclient v1.10.2, crypto v0.21.0 * CI: go mod download before tests * CI: debug tests + old version of fsouza/go-dockerclient * CI: before tests: - go/mod-download
1 parent 623f0a8 commit 9e41487

File tree

13 files changed

+229
-109
lines changed

13 files changed

+229
-109
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ jobs:
183183
steps:
184184
- checkout
185185
- go/load-cache
186+
- go/mod-download # prep for go/test
186187
- run:
187188
name: "get goveralls"
188189
command: |
189190
set -ux
190191
go get github.com/mattn/goveralls
191192
go install github.com/mattn/goveralls
192-
go get golang.org/x/crypto/ssh/terminal@v0.0.0-20210921155107-089bfa567519
193193
# https://circleci.com/developer/orbs/orb/circleci/go
194194
- go/test: # Runs 'go test ./...' but includes extensive parameterization for finer tuning.
195195
covermode: atomic
@@ -202,6 +202,7 @@ jobs:
202202
command: |
203203
set -ux
204204
$GOPATH/bin/goveralls -coverprofile=coverage.txt -service=circle-ci
205+
- go/save-cache
205206
- store_test_results:
206207
path: ./
207208

cmd/up.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ func newUpCli() *cobra.Command {
3030
Long: "creates pods and services in an order that respects depends_on in the docker compose file",
3131
RunE: upCommand,
3232
}
33-
upCmd.PersistentFlags().BoolP("detach", "d", false, "Detached mode: Run containers in the background")
33+
upCmd.PersistentFlags().BoolP("detach", "d", false, "Run in "+util.AnsiColorWrap("d", "4", "0")+"etached mode: runs containers in the background")
34+
upCmd.PersistentFlags().BoolP("event-diffs", "v", false, "Show e"+util.AnsiColorWrap("v", "4", "0")+"ent diffs as they come in from k8s. Very useful for debugging k8s internals.")
3435
upCmd.PersistentFlags().StringP("registry-user", "", registryUserFromEnv,
3536
fmt.Sprintf("The docker registry user to authenticate as. The default is common for Openshift clusters. (env %s)", registryUserEnvVarName))
3637
upCmd.PersistentFlags().StringP("registry-pass", "", registryPassFromEnv,
3738
fmt.Sprintf("The docker registry password to authenticate with. When unset, will use the Bearer Token from Kube config as is common for Openshift clusters. (env %s)", registryPassEnvVarName))
3839
upCmd.PersistentFlags().BoolP("run-as-user", "", false, "When set, the runAsUser/runAsGroup will be set for each pod based on the "+
3940
"user of the pod's image and the \"user\" key of the pod's docker-compose service")
40-
upCmd.PersistentFlags().BoolP("skip-host-aliases", "a", false, "Skip adding all services ClusterIP in Pod host aliases (useful when in-cluster name resolving is sufficient)")
41-
upCmd.PersistentFlags().BoolP("skip-push", "p", false, "Skip pushing images to registry: assumes they were previously pushed (helps get around connection problems to registry)")
42-
upCmd.PersistentFlags().Int64P("tail-lines", "t", 10, "Pod history log lines to show when starting to tail logs.")
41+
upCmd.PersistentFlags().BoolP("skip-host-aliases", "a", false, "Skip adding all services ClusterIP in Pod host "+util.AnsiColorWrap("a", "4", "0")+"liases (useful when in-cluster name resolving is sufficient)")
42+
upCmd.PersistentFlags().BoolP("skip-push", "p", false, "Skip "+util.AnsiColorWrap("p", "4", "0")+"ushing images to registry: assumes they were previously pushed (helps get around connection problems to registry)")
43+
upCmd.PersistentFlags().Int64P("tail-lines", "t", 10, "Pod history log lines to show when starting to "+util.AnsiColorWrap("t", "4", "0")+"ail logs.")
4344
return upCmd
4445
}
4546

@@ -51,6 +52,7 @@ func upCommand(cmd *cobra.Command, args []string) error {
5152
opts := &up.Options{}
5253
opts.Context = context.Background()
5354
opts.Detach, _ = cmd.Flags().GetBool("detach")
55+
opts.EventDiffs, _ = cmd.Flags().GetBool("event-diffs")
5456
opts.RunAsUser, _ = cmd.Flags().GetBool("run-as-user")
5557
opts.SkipPush, _ = cmd.Flags().GetBool("skip-push")
5658
opts.SkipHostAliases, _ = cmd.Flags().GetBool("skip-host-aliases")

go.mod

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
module github.com/kube-compose/kube-compose
22

3+
// Make sure all refs to `kube-compose/kube-compose/*` are resolved locally
34
replace github.com/kube-compose/kube-compose => ./
45

56
go 1.21
67

78
require (
9+
github.com/docker/cli v25.0.4+incompatible
810
github.com/docker/distribution v2.8.3+incompatible
9-
github.com/docker/docker v24.0.7+incompatible
10-
github.com/fsouza/go-dockerclient v1.10.1
11+
github.com/docker/docker v25.0.4+incompatible
12+
github.com/fsouza/go-dockerclient v1.10.2
13+
github.com/google/go-cmp v0.6.0
1114
github.com/hashicorp/go-version v1.6.0
1215
github.com/ivanpirog/coloredcobra v1.0.1
1316
github.com/opencontainers/go-digest v1.0.0
@@ -17,7 +20,7 @@ require (
1720
github.com/spf13/cobra v1.8.0
1821
github.com/spf13/pflag v1.0.5
1922
github.com/uber-go/mapdecode v1.0.0
20-
golang.org/x/crypto v0.17.0
23+
golang.org/x/crypto v0.21.0
2124
gopkg.in/yaml.v2 v2.4.0
2225
k8s.io/api v0.29.0
2326
k8s.io/apimachinery v0.29.0
@@ -28,13 +31,16 @@ require (
2831
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
2932
github.com/Microsoft/go-winio v0.6.1 // indirect
3033
github.com/containerd/containerd v1.6.26 // indirect
34+
github.com/containerd/log v0.1.0 // indirect
3135
github.com/davecgh/go-spew v1.1.1 // indirect
3236
github.com/distribution/reference v0.5.0 // indirect
3337
github.com/docker/go-connections v0.4.0 // indirect
3438
github.com/docker/go-units v0.5.0 // indirect
3539
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
3640
github.com/fatih/color v1.13.0 // indirect
37-
github.com/go-logr/logr v1.3.0 // indirect
41+
github.com/felixge/httpsnoop v1.0.4 // indirect
42+
github.com/go-logr/logr v1.4.1 // indirect
43+
github.com/go-logr/stdr v1.2.2 // indirect
3844
github.com/go-openapi/jsonpointer v0.19.6 // indirect
3945
github.com/go-openapi/jsonreference v0.20.2 // indirect
4046
github.com/go-openapi/swag v0.22.3 // indirect
@@ -43,7 +49,7 @@ require (
4349
github.com/golang/protobuf v1.5.3 // indirect
4450
github.com/google/gnostic-models v0.6.8 // indirect
4551
github.com/google/gofuzz v1.2.0 // indirect
46-
github.com/google/uuid v1.3.0 // indirect
52+
github.com/google/uuid v1.6.0 // indirect
4753
github.com/imdario/mergo v0.3.12 // indirect
4854
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4955
github.com/josharian/intern v1.0.0 // indirect
@@ -54,23 +60,31 @@ require (
5460
github.com/mattn/go-isatty v0.0.14 // indirect
5561
github.com/moby/patternmatcher v0.6.0 // indirect
5662
github.com/moby/sys/sequential v0.5.0 // indirect
63+
github.com/moby/sys/user v0.1.0 // indirect
5764
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
5865
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5966
github.com/modern-go/reflect2 v1.0.2 // indirect
6067
github.com/morikuni/aec v1.0.0 // indirect
6168
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
62-
github.com/opencontainers/runc v1.1.5 // indirect
69+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
70+
go.opentelemetry.io/otel v1.24.0 // indirect
71+
go.opentelemetry.io/otel/metric v1.24.0 // indirect
72+
go.opentelemetry.io/otel/trace v1.24.0 // indirect
6373
go.uber.org/multierr v1.11.0 // indirect
6474
golang.org/x/mod v0.12.0 // indirect
65-
golang.org/x/net v0.17.0 // indirect
66-
golang.org/x/oauth2 v0.10.0 // indirect
67-
golang.org/x/sys v0.15.0 // indirect
68-
golang.org/x/term v0.15.0 // indirect
75+
golang.org/x/net v0.21.0 // indirect
76+
golang.org/x/oauth2 v0.16.0 // indirect
77+
golang.org/x/sync v0.6.0 // indirect
78+
golang.org/x/sys v0.18.0 // indirect
79+
golang.org/x/term v0.18.0 // indirect
6980
golang.org/x/text v0.14.0 // indirect
7081
golang.org/x/time v0.3.0 // indirect
7182
golang.org/x/tools v0.12.0 // indirect
72-
google.golang.org/appengine v1.6.7 // indirect
73-
google.golang.org/protobuf v1.31.0 // indirect
83+
google.golang.org/appengine v1.6.8 // indirect
84+
google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect
85+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect
86+
google.golang.org/grpc v1.62.1 // indirect
87+
google.golang.org/protobuf v1.33.0 // indirect
7488
gopkg.in/inf.v0 v0.9.1 // indirect
7589
gopkg.in/yaml.v3 v3.0.1 // indirect
7690
k8s.io/klog/v2 v2.110.1 // indirect

0 commit comments

Comments
 (0)