Skip to content

Commit 5bd8451

Browse files
authored
Update image-copy-gcp example (#237)
Modify the `image-copy-gcp` example to account for the fact that registry push events do not contain the literal repository name any more. We use the `repo_id` in the event body to lookup the repository name in the Chainguard API. The name of the organization is passed into the terraform by the user. I've also ported over some other improvements from the image-copy-ecr example: 1. Copy the tag referred to in the event, rather than just copying latest every time. 2. Ignore failed pushes, events without tags and non-manifest pushes. 3. Store the image-copy container image in the repository that the terraform creates. This stops us from leaving the image hanging around in GAR when the terraform is destroyed. Signed-off-by: Rob Best <rob.best@chainguard.dev>
1 parent 39d3430 commit 5bd8451

File tree

6 files changed

+352
-312
lines changed

6 files changed

+352
-312
lines changed

image-copy-gcp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ module "image-copy" {
2121
# - The Service Account that authorizes pushes to Google Artifact Registry.
2222
project_id = "<project-id>"
2323
24-
# The Chainguard IAM group from which we expect to receive events.
24+
# The name of the Chainguard IAM group from which we expect to receive events.
2525
# This is used to authenticate that the Chainguard events are intended
2626
# for you, and not another user.
2727
# Images pushed to repos under this group will be mirrored to Artifact Registry.
28-
group = "<group-id>"
28+
group_name = "<group-name>"
2929
3030
# This is the location in Artifact Registry where images will be mirrored.
3131
# For example: pushes to cgr.dev/<group>/foo will be mirrored to

image-copy-gcp/go.mod

Lines changed: 72 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,95 @@
11
module github.com/chainguard-dev/platform-examples/image-copy-gcp
22

3-
go 1.21
4-
5-
toolchain go1.21.0
3+
go 1.23.4
64

75
replace github.com/chainguard-dev/platform-examples => ../
86

97
require (
10-
chainguard.dev/sdk v0.1.1
11-
cloud.google.com/go/compute/metadata v0.2.3
8+
chainguard.dev/sdk v0.1.31
9+
cloud.google.com/go/compute/metadata v0.6.0
1210
github.com/cloudevents/sdk-go/v2 v2.15.2
13-
github.com/google/go-containerregistry v0.16.1
11+
github.com/google/go-containerregistry v0.20.3
1412
github.com/kelseyhightower/envconfig v1.4.0
15-
google.golang.org/api v0.149.0
13+
google.golang.org/api v0.222.0
1614
)
1715

1816
require (
19-
chainguard.dev/go-grpc-kit v0.17.2 // indirect
20-
cloud.google.com/go/compute v1.23.2 // indirect
17+
chainguard.dev/apko v0.23.0 // indirect
18+
chainguard.dev/go-grpc-kit v0.17.7 // indirect
19+
cloud.google.com/go/auth v0.14.1 // indirect
20+
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
21+
dario.cat/mergo v1.0.1 // indirect
22+
github.com/Microsoft/go-winio v0.6.2 // indirect
23+
github.com/ProtonMail/go-crypto v1.1.3 // indirect
2124
github.com/beorn7/perks v1.0.1 // indirect
22-
github.com/blendle/zapdriver v1.3.1 // indirect
23-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
24-
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
25-
github.com/coreos/go-oidc/v3 v3.7.0 // indirect
26-
github.com/docker/cli v24.0.0+incompatible // indirect
27-
github.com/docker/distribution v2.8.2+incompatible // indirect
28-
github.com/docker/docker v25.0.6+incompatible // indirect
29-
github.com/docker/docker-credential-helpers v0.7.0 // indirect
30-
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
31-
github.com/go-logr/logr v1.3.0 // indirect
25+
github.com/bits-and-blooms/bitset v1.15.0 // indirect
26+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
27+
github.com/chainguard-dev/clog v1.6.1 // indirect
28+
github.com/cloudflare/circl v1.5.0 // indirect
29+
github.com/containerd/stargz-snapshotter/estargz v0.16.3 // indirect
30+
github.com/coreos/go-oidc/v3 v3.12.0 // indirect
31+
github.com/cyphar/filepath-securejoin v0.3.6 // indirect
32+
github.com/docker/cli v27.5.1+incompatible // indirect
33+
github.com/docker/distribution v2.8.3+incompatible // indirect
34+
github.com/docker/docker-credential-helpers v0.8.2 // indirect
35+
github.com/emirpasic/gods v1.18.1 // indirect
36+
github.com/felixge/httpsnoop v1.0.4 // indirect
37+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
38+
github.com/go-git/go-billy/v5 v5.6.1 // indirect
39+
github.com/go-git/go-git/v5 v5.13.1 // indirect
40+
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
41+
github.com/go-logr/logr v1.4.2 // indirect
3242
github.com/go-logr/stdr v1.2.2 // indirect
33-
github.com/gogo/protobuf v1.3.2 // indirect
34-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
35-
github.com/golang/protobuf v1.5.3 // indirect
36-
github.com/google/gofuzz v1.2.0 // indirect
37-
github.com/google/s2a-go v0.1.7 // indirect
38-
github.com/google/uuid v1.4.0 // indirect
39-
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
43+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
44+
github.com/google/go-cmp v0.6.0 // indirect
45+
github.com/google/s2a-go v0.1.9 // indirect
46+
github.com/google/uuid v1.6.0 // indirect
47+
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
48+
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
4049
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
4150
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.1-0.20210315223345-82c243799c99 // indirect
42-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
51+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect
52+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
4353
github.com/json-iterator/go v1.1.12 // indirect
44-
github.com/klauspost/compress v1.16.5 // indirect
45-
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
54+
github.com/kevinburke/ssh_config v1.2.0 // indirect
55+
github.com/klauspost/compress v1.18.0 // indirect
4656
github.com/mitchellh/go-homedir v1.1.0 // indirect
4757
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4858
github.com/modern-go/reflect2 v1.0.2 // indirect
59+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
60+
github.com/onsi/gomega v1.35.1 // indirect
4961
github.com/opencontainers/go-digest v1.0.0 // indirect
50-
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
62+
github.com/opencontainers/image-spec v1.1.0 // indirect
63+
github.com/pjbgf/sha1cd v0.3.0 // indirect
5164
github.com/pkg/errors v0.9.1 // indirect
52-
github.com/prometheus/client_golang v1.17.0 // indirect
53-
github.com/prometheus/client_model v0.5.0 // indirect
54-
github.com/prometheus/common v0.45.0 // indirect
55-
github.com/prometheus/procfs v0.12.0 // indirect
56-
github.com/sirupsen/logrus v1.9.1 // indirect
57-
github.com/vbatts/tar-split v0.11.3 // indirect
58-
go.opencensus.io v0.24.0 // indirect
59-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.0 // indirect
60-
go.opentelemetry.io/otel v1.20.0 // indirect
61-
go.opentelemetry.io/otel/metric v1.20.0 // indirect
62-
go.opentelemetry.io/otel/trace v1.20.0 // indirect
65+
github.com/prometheus/client_golang v1.21.0 // indirect
66+
github.com/prometheus/client_model v0.6.1 // indirect
67+
github.com/prometheus/common v0.62.0 // indirect
68+
github.com/prometheus/procfs v0.15.1 // indirect
69+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
70+
github.com/sirupsen/logrus v1.9.3 // indirect
71+
github.com/skeema/knownhosts v1.3.0 // indirect
72+
github.com/vbatts/tar-split v0.12.1 // indirect
73+
github.com/xanzy/ssh-agent v0.3.3 // indirect
74+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
75+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
76+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
77+
go.opentelemetry.io/otel v1.34.0 // indirect
78+
go.opentelemetry.io/otel/metric v1.34.0 // indirect
79+
go.opentelemetry.io/otel/trace v1.34.0 // indirect
6380
go.uber.org/multierr v1.11.0 // indirect
64-
go.uber.org/zap v1.26.0 // indirect
65-
golang.org/x/crypto v0.21.0 // indirect
66-
golang.org/x/net v0.23.0 // indirect
67-
golang.org/x/oauth2 v0.14.0 // indirect
68-
golang.org/x/sync v0.4.0 // indirect
69-
golang.org/x/sys v0.18.0 // indirect
70-
golang.org/x/text v0.14.0 // indirect
71-
google.golang.org/appengine v1.6.8 // indirect
72-
google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect
73-
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
74-
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
75-
google.golang.org/grpc v1.59.0 // indirect
76-
google.golang.org/protobuf v1.33.0 // indirect
77-
gopkg.in/inf.v0 v0.9.1 // indirect
78-
gopkg.in/yaml.v2 v2.4.0 // indirect
79-
k8s.io/api v0.28.4 // indirect
80-
k8s.io/apimachinery v0.28.4 // indirect
81-
k8s.io/klog/v2 v2.100.1 // indirect
82-
k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect
83-
knative.dev/pkg v0.0.0-20231101193506-b09d4f2a2845 // indirect
84-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
85-
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
81+
go.uber.org/zap v1.27.0 // indirect
82+
golang.org/x/crypto v0.33.0 // indirect
83+
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
84+
golang.org/x/net v0.35.0 // indirect
85+
golang.org/x/oauth2 v0.26.0 // indirect
86+
golang.org/x/sync v0.11.0 // indirect
87+
golang.org/x/sys v0.30.0 // indirect
88+
golang.org/x/text v0.22.0 // indirect
89+
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
90+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
91+
google.golang.org/grpc v1.70.0 // indirect
92+
google.golang.org/protobuf v1.36.5 // indirect
93+
gopkg.in/warnings.v0 v0.1.2 // indirect
94+
gopkg.in/yaml.v3 v3.0.1 // indirect
8695
)

0 commit comments

Comments
 (0)