forked from TrueCloudLab/distribution
testutil: rename variables that collided with imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
0e3efe749b
commit
030489ca66
2 changed files with 11 additions and 11 deletions
|
@ -42,7 +42,7 @@ func MakeManifestList(blobstatter distribution.BlobStatter, manifestDigests []di
|
||||||
// MakeSchema1Manifest constructs a schema 1 manifest from a given list of digests and returns
|
// MakeSchema1Manifest constructs a schema 1 manifest from a given list of digests and returns
|
||||||
// the digest of the manifest
|
// the digest of the manifest
|
||||||
func MakeSchema1Manifest(digests []digest.Digest) (distribution.Manifest, error) {
|
func MakeSchema1Manifest(digests []digest.Digest) (distribution.Manifest, error) {
|
||||||
manifest := schema1.Manifest{
|
mfst := schema1.Manifest{
|
||||||
Versioned: manifest.Versioned{
|
Versioned: manifest.Versioned{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
},
|
},
|
||||||
|
@ -50,9 +50,9 @@ func MakeSchema1Manifest(digests []digest.Digest) (distribution.Manifest, error)
|
||||||
Tag: "cares",
|
Tag: "cares",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, digest := range digests {
|
for _, d := range digests {
|
||||||
manifest.FSLayers = append(manifest.FSLayers, schema1.FSLayer{BlobSum: digest})
|
mfst.FSLayers = append(mfst.FSLayers, schema1.FSLayer{BlobSum: d})
|
||||||
manifest.History = append(manifest.History, schema1.History{V1Compatibility: ""})
|
mfst.History = append(mfst.History, schema1.History{V1Compatibility: ""})
|
||||||
}
|
}
|
||||||
|
|
||||||
pk, err := libtrust.GenerateECP256PrivateKey()
|
pk, err := libtrust.GenerateECP256PrivateKey()
|
||||||
|
@ -60,7 +60,7 @@ func MakeSchema1Manifest(digests []digest.Digest) (distribution.Manifest, error)
|
||||||
return nil, fmt.Errorf("unexpected error generating private key: %v", err)
|
return nil, fmt.Errorf("unexpected error generating private key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
signedManifest, err := schema1.Sign(&manifest, pk)
|
signedManifest, err := schema1.Sign(&mfst, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error signing manifest: %v", err)
|
return nil, fmt.Errorf("error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -74,14 +74,14 @@ func MakeSchema2Manifest(repository distribution.Repository, digests []digest.Di
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
blobStore := repository.Blobs(ctx)
|
blobStore := repository.Blobs(ctx)
|
||||||
builder := schema2.NewManifestBuilder(blobStore, schema2.MediaTypeImageConfig, []byte{})
|
builder := schema2.NewManifestBuilder(blobStore, schema2.MediaTypeImageConfig, []byte{})
|
||||||
for _, digest := range digests {
|
for _, d := range digests {
|
||||||
builder.AppendReference(distribution.Descriptor{Digest: digest})
|
builder.AppendReference(distribution.Descriptor{Digest: d})
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest, err := builder.Build(ctx)
|
mfst, err := builder.Build(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unexpected error generating manifest: %v", err)
|
return nil, fmt.Errorf("unexpected error generating manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return manifest, nil
|
return mfst, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ func CreateRandomLayers(n int) (map[digest.Digest]io.ReadSeeker, error) {
|
||||||
// UploadBlobs lets you upload blobs to a repository
|
// UploadBlobs lets you upload blobs to a repository
|
||||||
func UploadBlobs(repository distribution.Repository, layers map[digest.Digest]io.ReadSeeker) error {
|
func UploadBlobs(repository distribution.Repository, layers map[digest.Digest]io.ReadSeeker) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
for digest, rs := range layers {
|
for dgst, rs := range layers {
|
||||||
wr, err := repository.Blobs(ctx).Create(ctx)
|
wr, err := repository.Blobs(ctx).Create(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unexpected error creating upload: %v", err)
|
return fmt.Errorf("unexpected error creating upload: %v", err)
|
||||||
|
@ -106,7 +106,7 @@ func UploadBlobs(repository distribution.Repository, layers map[digest.Digest]io
|
||||||
return fmt.Errorf("unexpected error copying to upload: %v", err)
|
return fmt.Errorf("unexpected error copying to upload: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := wr.Commit(ctx, distribution.Descriptor{Digest: digest}); err != nil {
|
if _, err := wr.Commit(ctx, distribution.Descriptor{Digest: dgst}); err != nil {
|
||||||
return fmt.Errorf("unexpected error committinng upload: %v", err)
|
return fmt.Errorf("unexpected error committinng upload: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue