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

Commit 8d8b0d4

Browse files
authored
feat: update attest v0.3.0 (#47)
* feat: update attest to v0.3.0
1 parent a507c4b commit 8d8b0d4

20 files changed

+597
-349
lines changed

cmd/metadata.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/docker/attest/pkg/mirror"
11+
"github.com/docker/attest/pkg/oci"
1112
"github.com/docker/attest/pkg/tuf"
1213
"github.com/docker/go-tuf-mirror/internal/util"
1314
"github.com/google/go-containerregistry/pkg/name"
@@ -77,11 +78,11 @@ func (o *metadataOptions) run(cmd *cobra.Command, args []string) error {
7778
}
7879

7980
fmt.Fprintf(cmd.OutOrStdout(), "Mirroring TUF metadata %s to %s\n", o.source, o.destination)
80-
root, err := tuf.GetEmbeddedTufRoot(o.rootOptions.tufRoot)
81+
root, err := tuf.GetEmbeddedRoot(o.rootOptions.tufRoot)
8182
if err != nil {
8283
return fmt.Errorf("failed to get root bytes: %w", err)
8384
}
84-
m, err := mirror.NewTufMirror(root.Data, tufPath, o.source, o.targets, tuf.NewVersionChecker())
85+
m, err := mirror.NewTUFMirror(root.Data, tufPath, o.source, o.targets, tuf.NewDefaultVersionChecker())
8586
if err != nil {
8687
return fmt.Errorf("failed to create TUF mirror: %w", err)
8788
}
@@ -95,7 +96,7 @@ func (o *metadataOptions) run(cmd *cobra.Command, args []string) error {
9596
}
9697

9798
// create delegated metadata manifests
98-
var delegated []*mirror.MirrorImage
99+
var delegated []*mirror.Image
99100
if o.rootOptions.full {
100101
delegated, err = m.GetDelegatedMetadataMirrors()
101102
if err != nil {
@@ -107,22 +108,22 @@ func (o *metadataOptions) run(cmd *cobra.Command, args []string) error {
107108
switch {
108109
case strings.HasPrefix(o.destination, OCIPrefix):
109110
path := strings.TrimPrefix(o.destination, OCIPrefix)
110-
err = mirror.SaveImageAsOCILayout(image, path)
111+
err = oci.SaveImageAsOCILayout(image, path)
111112
if err != nil {
112113
return fmt.Errorf("failed to save metadata as OCI layout: %w", err)
113114
}
114115
fmt.Fprintf(cmd.OutOrStdout(), "Metadata manifest layout saved to %s\n", path)
115116
for _, d := range delegated {
116117
path := filepath.Join(path, d.Tag)
117-
err = mirror.SaveImageAsOCILayout(d.Image, path)
118+
err = oci.SaveImageAsOCILayout(d.Image, path)
118119
if err != nil {
119120
return fmt.Errorf("failed to save delegated metadata as OCI layout: %w", err)
120121
}
121122
fmt.Fprintf(cmd.OutOrStdout(), "Delegated metadata manifest layout saved to %s\n", path)
122123
}
123124
case strings.HasPrefix(o.destination, RegistryPrefix):
124125
imageName := strings.TrimPrefix(o.destination, RegistryPrefix)
125-
err = mirror.PushImageToRegistry(image, imageName)
126+
err = oci.PushImageToRegistry(image, imageName)
126127
if err != nil {
127128
return fmt.Errorf("failed to push metadata manifest: %w", err)
128129
}
@@ -133,7 +134,7 @@ func (o *metadataOptions) run(cmd *cobra.Command, args []string) error {
133134
return fmt.Errorf("failed to parse image name: %w", err)
134135
}
135136
imageName := fmt.Sprintf("%s:%s", ref.Context().Name(), d.Tag)
136-
err = mirror.PushImageToRegistry(d.Image, imageName)
137+
err = oci.PushImageToRegistry(d.Image, imageName)
137138
if err != nil {
138139
return fmt.Errorf("failed to push delegated metadata manifest: %w", err)
139140
}

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
type rootOptions struct {
2020
tufPath string
2121
tufRoot string
22-
mirror *mirror.TufMirror
22+
mirror *mirror.TUFMirror
2323
full bool
2424
}
2525

cmd/targets.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/docker/attest/pkg/mirror"
11+
"github.com/docker/attest/pkg/oci"
1112
"github.com/docker/attest/pkg/tuf"
1213
"github.com/docker/go-tuf-mirror/internal/util"
1314
"github.com/google/go-containerregistry/pkg/name"
@@ -92,27 +93,27 @@ func (o *targetsOptions) run(cmd *cobra.Command, args []string) error {
9293
} else {
9394
tufPath = strings.TrimSpace(o.rootOptions.tufPath)
9495
}
95-
root, err := tuf.GetEmbeddedTufRoot(o.rootOptions.tufRoot)
96+
root, err := tuf.GetEmbeddedRoot(o.rootOptions.tufRoot)
9697
if err != nil {
9798
return fmt.Errorf("failed to get root bytes: %w", err)
9899
}
99-
m, err = mirror.NewTufMirror(root.Data, tufPath, o.metadata, o.source, tuf.NewVersionChecker())
100+
m, err = mirror.NewTUFMirror(root.Data, tufPath, o.metadata, o.source, tuf.NewDefaultVersionChecker())
100101
if err != nil {
101102
return fmt.Errorf("failed to create TUF mirror: %w", err)
102103
}
103104
} else {
104105
// set remote targets url for existing mirror
105-
m.TufClient.SetRemoteTargetsURL(o.source)
106+
m.TUFClient.SetRemoteTargetsURL(o.source)
106107
}
107108

108109
// create target manifests
109-
targets, err := m.GetTufTargetMirrors()
110+
targets, err := m.GetTUFTargetMirrors()
110111
if err != nil {
111112
return fmt.Errorf("failed to create target mirrors: %w", err)
112113
}
113114

114115
// create delegated target manifests
115-
var delegated []*mirror.MirrorIndex
116+
var delegated []*mirror.Index
116117
if o.rootOptions.full {
117118
delegated, err = m.GetDelegatedTargetMirrors()
118119
if err != nil {
@@ -126,15 +127,15 @@ func (o *targetsOptions) run(cmd *cobra.Command, args []string) error {
126127
outputPath := strings.TrimPrefix(o.destination, OCIPrefix)
127128
for _, t := range targets {
128129
path := filepath.Join(outputPath, t.Tag)
129-
err = mirror.SaveImageAsOCILayout(t.Image, path)
130+
err = oci.SaveImageAsOCILayout(t.Image, path)
130131
if err != nil {
131132
return fmt.Errorf("failed to save target as OCI layout: %w", err)
132133
}
133134
fmt.Fprintf(cmd.OutOrStdout(), "Target manifest layout saved to %s\n", path)
134135
}
135136
for _, d := range delegated {
136137
path := filepath.Join(outputPath, d.Tag)
137-
err = mirror.SaveIndexAsOCILayout(d.Index, path)
138+
err = oci.SaveIndexAsOCILayout(d.Index, path)
138139
if err != nil {
139140
return fmt.Errorf("failed to save delegated target index as OCI layout: %w", err)
140141
}
@@ -144,15 +145,15 @@ func (o *targetsOptions) run(cmd *cobra.Command, args []string) error {
144145
repo := strings.TrimPrefix(o.destination, RegistryPrefix)
145146
for _, t := range targets {
146147
imageName := fmt.Sprintf("%s:%s", repo, t.Tag)
147-
err = mirror.PushImageToRegistry(t.Image, imageName)
148+
err = oci.PushImageToRegistry(t.Image, imageName)
148149
if err != nil {
149150
return fmt.Errorf("failed to push target manifest: %w", err)
150151
}
151152
fmt.Fprintf(cmd.OutOrStdout(), "Target manifest pushed to %s\n", imageName)
152153
}
153154
for _, d := range delegated {
154155
imageName := fmt.Sprintf("%s:%s", repo, d.Tag)
155-
err = mirror.PushIndexToRegistry(d.Index, imageName)
156+
err = oci.PushIndexToRegistry(d.Index, imageName)
156157
if err != nil {
157158
return fmt.Errorf("failed to push delegated target index manifest: %w", err)
158159
}

go.mod

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
module github.com/docker/go-tuf-mirror
22

3-
go 1.22.2
3+
go 1.22.5
44

55
require (
6-
github.com/docker/attest v0.1.8
7-
github.com/google/go-containerregistry v0.20.0
6+
github.com/docker/attest v0.3.0
7+
github.com/google/go-containerregistry v0.20.1
88
github.com/spf13/cobra v1.8.1
99
github.com/stretchr/testify v1.9.0
1010
)
1111

12-
// fork of a fork (in case it goes away) with changes to support ArtifactType (https://github.com/google/go-containerregistry/pull/1931)
13-
replace github.com/google/go-containerregistry v0.20.0 => github.com/kipz/go-containerregistry v0.0.0-20240423201245-bf57eace21f2
12+
// fork with changes to support ArtifactType (https://github.com/google/go-containerregistry/pull/1931)
13+
replace github.com/google/go-containerregistry => github.com/docker/go-containerregistry v0.0.0-20240808132857-c8bfc44af7c8
1414

1515
require (
1616
cloud.google.com/go v0.115.0 // indirect
17-
cloud.google.com/go/auth v0.7.0 // indirect
18-
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
19-
cloud.google.com/go/compute/metadata v0.4.0 // indirect
20-
cloud.google.com/go/iam v1.1.10 // indirect
21-
cloud.google.com/go/kms v1.18.2 // indirect
22-
cloud.google.com/go/longrunning v0.5.9 // indirect
17+
cloud.google.com/go/auth v0.7.3 // indirect
18+
cloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect
19+
cloud.google.com/go/compute/metadata v0.5.0 // indirect
20+
cloud.google.com/go/iam v1.1.12 // indirect
21+
cloud.google.com/go/kms v1.18.4 // indirect
22+
cloud.google.com/go/longrunning v0.5.11 // indirect
2323
github.com/Masterminds/semver/v3 v3.2.1 // indirect
24-
github.com/Microsoft/hcsshim v0.12.3 // indirect
2524
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
2625
github.com/aws/aws-sdk-go-v2 v1.30.3 // indirect
27-
github.com/aws/aws-sdk-go-v2/config v1.27.26 // indirect
28-
github.com/aws/aws-sdk-go-v2/credentials v1.17.26 // indirect
26+
github.com/aws/aws-sdk-go-v2/config v1.27.27 // indirect
27+
github.com/aws/aws-sdk-go-v2/credentials v1.17.27 // indirect
2928
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 // indirect
3029
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect
3130
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect
@@ -34,14 +33,13 @@ require (
3433
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.24.1 // indirect
3534
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect
3635
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect
37-
github.com/aws/aws-sdk-go-v2/service/kms v1.34.1 // indirect
38-
github.com/aws/aws-sdk-go-v2/service/sso v1.22.3 // indirect
36+
github.com/aws/aws-sdk-go-v2/service/kms v1.35.3 // indirect
37+
github.com/aws/aws-sdk-go-v2/service/sso v1.22.4 // indirect
3938
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect
4039
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 // indirect
4140
github.com/aws/smithy-go v1.20.3 // indirect
4241
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20231024185945-8841054dbdb8 // indirect
4342
github.com/blang/semver v3.5.1+incompatible // indirect
44-
github.com/containerd/containerd v1.7.19 // indirect
4543
github.com/containerd/log v0.1.0 // indirect
4644
github.com/containerd/platforms v0.2.1 // indirect
4745
github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect
@@ -50,15 +48,14 @@ require (
5048
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect
5149
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
5250
github.com/distribution/reference v0.6.0 // indirect
53-
github.com/docker/cli v26.1.3+incompatible // indirect
51+
github.com/docker/cli v27.1.1+incompatible // indirect
5452
github.com/docker/distribution v2.8.3+incompatible // indirect
55-
github.com/docker/docker v27.0.3+incompatible // indirect
5653
github.com/docker/docker-credential-helpers v0.8.1 // indirect
5754
github.com/dustin/go-humanize v1.0.1 // indirect
5855
github.com/felixge/httpsnoop v1.0.4 // indirect
5956
github.com/fsnotify/fsnotify v1.7.0 // indirect
6057
github.com/go-chi/chi v4.1.2+incompatible // indirect
61-
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
58+
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
6259
github.com/go-logr/logr v1.4.2 // indirect
6360
github.com/go-logr/stdr v1.2.2 // indirect
6461
github.com/go-openapi/analysis v0.23.0 // indirect
@@ -72,15 +69,14 @@ require (
7269
github.com/go-openapi/swag v0.23.0 // indirect
7370
github.com/go-openapi/validate v0.24.0 // indirect
7471
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
75-
github.com/golang/protobuf v1.5.4 // indirect
7672
github.com/golang/snappy v0.0.4 // indirect
77-
github.com/google/certificate-transparency-go v1.1.8 // indirect
78-
github.com/google/s2a-go v0.1.7 // indirect
73+
github.com/google/certificate-transparency-go v1.2.1 // indirect
74+
github.com/google/s2a-go v0.1.8 // indirect
7975
github.com/google/uuid v1.6.0 // indirect
8076
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
81-
github.com/googleapis/gax-go/v2 v2.12.5 // indirect
77+
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
8278
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
83-
github.com/hashicorp/go-retryablehttp v0.7.6 // indirect
79+
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
8480
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
8581
github.com/in-toto/in-toto-golang v0.9.0 // indirect
8682
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -108,49 +104,50 @@ require (
108104
github.com/sassoftware/relic v7.2.1+incompatible // indirect
109105
github.com/secure-systems-lab/go-securesystemslib v0.8.0 // indirect
110106
github.com/shibumi/go-pathspec v1.3.0 // indirect
111-
github.com/sigstore/cosign/v2 v2.2.4 // indirect
107+
github.com/sigstore/cosign/v2 v2.4.0 // indirect
108+
github.com/sigstore/protobuf-specs v0.3.2 // indirect
112109
github.com/sigstore/rekor v1.3.6 // indirect
113-
github.com/sigstore/sigstore v1.8.6 // indirect
114-
github.com/sigstore/sigstore/pkg/signature/kms/aws v1.8.6 // indirect
115-
github.com/sigstore/sigstore/pkg/signature/kms/gcp v1.8.6 // indirect
110+
github.com/sigstore/sigstore v1.8.8 // indirect
111+
github.com/sigstore/sigstore/pkg/signature/kms/aws v1.8.8 // indirect
112+
github.com/sigstore/sigstore/pkg/signature/kms/gcp v1.8.8 // indirect
116113
github.com/sigstore/timestamp-authority v1.2.2 // indirect
117114
github.com/sirupsen/logrus v1.9.3 // indirect
118115
github.com/sourcegraph/conc v0.3.0 // indirect
119116
github.com/spf13/afero v1.11.0 // indirect
120117
github.com/spf13/cast v1.6.0 // indirect
121118
github.com/spf13/pflag v1.0.5 // indirect
122-
github.com/spf13/viper v1.18.2 // indirect
119+
github.com/spf13/viper v1.19.0 // indirect
123120
github.com/subosito/gotenv v1.6.0 // indirect
124121
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
125122
github.com/theupdateframework/go-tuf v0.7.0 // indirect
126-
github.com/theupdateframework/go-tuf/v2 v2.0.0-20240504210453-5a634eb214ae // indirect
123+
github.com/theupdateframework/go-tuf/v2 v2.0.0 // indirect
127124
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
128125
github.com/transparency-dev/merkle v0.0.2 // indirect
129126
github.com/vbatts/tar-split v0.11.5 // indirect
130127
go.mongodb.org/mongo-driver v1.15.0 // indirect
131128
go.opencensus.io v0.24.0 // indirect
132129
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect
133-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
134-
go.opentelemetry.io/otel v1.27.0 // indirect
135-
go.opentelemetry.io/otel/metric v1.27.0 // indirect
136-
go.opentelemetry.io/otel/trace v1.27.0 // indirect
130+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
131+
go.opentelemetry.io/otel v1.28.0 // indirect
132+
go.opentelemetry.io/otel/metric v1.28.0 // indirect
133+
go.opentelemetry.io/otel/trace v1.28.0 // indirect
137134
go.uber.org/multierr v1.11.0 // indirect
138135
go.uber.org/zap v1.27.0 // indirect
139136
golang.org/x/crypto v0.25.0 // indirect
140137
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
141-
golang.org/x/mod v0.17.0 // indirect
138+
golang.org/x/mod v0.19.0 // indirect
142139
golang.org/x/net v0.27.0 // indirect
143-
golang.org/x/oauth2 v0.21.0 // indirect
144-
golang.org/x/sync v0.7.0 // indirect
140+
golang.org/x/oauth2 v0.22.0 // indirect
141+
golang.org/x/sync v0.8.0 // indirect
145142
golang.org/x/sys v0.22.0 // indirect
146143
golang.org/x/term v0.22.0 // indirect
147144
golang.org/x/text v0.16.0 // indirect
148-
golang.org/x/time v0.5.0 // indirect
149-
google.golang.org/api v0.188.0 // indirect
150-
google.golang.org/genproto v0.0.0-20240708141625-4ad9e859172b // indirect
151-
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
152-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240708141625-4ad9e859172b // indirect
153-
google.golang.org/grpc v1.64.1 // indirect
145+
golang.org/x/time v0.6.0 // indirect
146+
google.golang.org/api v0.191.0 // indirect
147+
google.golang.org/genproto v0.0.0-20240730163845-b1a4ccb954bf // indirect
148+
google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f // indirect
149+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect
150+
google.golang.org/grpc v1.65.0 // indirect
154151
google.golang.org/protobuf v1.34.2 // indirect
155152
gopkg.in/ini.v1 v1.67.0 // indirect
156153
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)