Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Feb 17, 2024
1 parent 114e54a commit d57456b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
3 changes: 1 addition & 2 deletions cmd/crane/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/google/go-containerregistry/pkg/crane"
"github.com/google/go-containerregistry/pkg/logs"
"github.com/google/go-containerregistry/pkg/v1/layout"
"github.com/google/go-containerregistry/pkg/v1/local"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -73,7 +72,7 @@ func New(use, short string, options []crane.Option) *cobra.Command {
}
if uselocal != "" {
p, _ := layout.FromPath(uselocal)
options = append(options, crane.WithPuller(local.NewPuller(p)), crane.WithPusher(local.NewPusher(p)))
options = append(options, crane.WithPuller(layout.NewPuller(p)), crane.WithPusher(layout.NewPusher(p)))
}
if Version != "" {
binary := "crane"
Expand Down
Binary file removed pkg/.DS_Store
Binary file not shown.
5 changes: 2 additions & 3 deletions pkg/v1/local/layer.go → pkg/v1/layout/layer.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package local
package layout

Check failure on line 1 in pkg/v1/layout/layer.go

View workflow job for this annotation

GitHub Actions / Go headers

[Go headers] pkg/v1/layout/layer.go#L1

missing boilerplate:
Raw output
pkg/v1/layout/layer.go:1: missing boilerplate:
// Copyright 2024 Google LLC All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import (
"io"

v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/layout"
"github.com/google/go-containerregistry/pkg/v1/partial"
"github.com/google/go-containerregistry/pkg/v1/types"
)

// remoteImagelayer implements partial.CompressedLayer
type localLayer struct {
path layout.Path
path Path
digest v1.Hash
}

Expand Down
23 changes: 11 additions & 12 deletions pkg/v1/local/puller.go → pkg/v1/layout/puller.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package local
package layout

Check failure on line 1 in pkg/v1/layout/puller.go

View workflow job for this annotation

GitHub Actions / Go headers

[Go headers] pkg/v1/layout/puller.go#L1

missing boilerplate:
Raw output
pkg/v1/layout/puller.go:1: missing boilerplate:
// Copyright 2024 Google LLC All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import (
"context"
"errors"
"fmt"

"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/layout"

"github.com/google/go-containerregistry/pkg/v1/partial"
"github.com/google/go-containerregistry/pkg/v1/remote"
specsv1 "github.com/opencontainers/image-spec/specs-go/v1"
)

type puller struct {
path layout.Path
path Path
}

func NewPuller(path layout.Path) remote.Puller {
func NewPuller(path Path) remote.Puller {
return &puller{
path,
}
Expand Down Expand Up @@ -60,7 +59,7 @@ func (p *puller) Artifact(ctx context.Context, ref name.Reference) (partial.Arti
}
return reg.ImageIndex(desc.Digest)
}
return nil, errors.ErrUnsupported
return nil, fmt.Errorf("TODO: handle non image media types")
}

// Head implements remote.Puller.
Expand All @@ -86,30 +85,30 @@ func (p *puller) Layer(ctx context.Context, ref name.Digest) (v1.Layer, error) {

// List implements remote.Puller.
func (*puller) List(ctx context.Context, repo name.Repository) ([]string, error) {
return nil, errors.ErrUnsupported
return nil, fmt.Errorf("unsupported operation")
}

// Get implements remote.Puller.
func (*puller) Get(ctx context.Context, ref name.Reference) (*remote.Descriptor, error) {
return nil, errors.ErrUnsupported
return nil, fmt.Errorf("unsupported operation")
}

// Lister implements remote.Puller.
func (*puller) Lister(ctx context.Context, repo name.Repository) (*remote.Lister, error) {
return nil, errors.ErrUnsupported
return nil, fmt.Errorf("unsupported operation")
}

// Catalogger implements remote.Puller.
func (*puller) Catalogger(ctx context.Context, reg name.Registry) (*remote.Catalogger, error) {
return nil, errors.ErrUnsupported
return nil, fmt.Errorf("unsupported operation")
}

// Catalog implements remote.Puller.
func (*puller) Catalog(ctx context.Context, reg name.Registry) ([]string, error) {
return nil, errors.ErrUnsupported
return nil, fmt.Errorf("unsupported operation")
}

// Referrers implements remote.Puller.
func (*puller) Referrers(ctx context.Context, d name.Digest, filter map[string]string) (v1.ImageIndex, error) {
return nil, errors.ErrUnsupported
return nil, fmt.Errorf("unsupported operation")
}
10 changes: 3 additions & 7 deletions pkg/v1/local/pusher.go → pkg/v1/layout/pusher.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package local
package layout

Check failure on line 1 in pkg/v1/layout/pusher.go

View workflow job for this annotation

GitHub Actions / Go headers

[Go headers] pkg/v1/layout/pusher.go#L1

missing boilerplate:
Raw output
pkg/v1/layout/pusher.go:1: missing boilerplate:
// Copyright 2024 Google LLC All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import (
"bytes"
"context"
"errors"
"fmt"
"io"
"os"

"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/layout"
"github.com/google/go-containerregistry/pkg/v1/partial"
"github.com/google/go-containerregistry/pkg/v1/remote"
specsv1 "github.com/opencontainers/image-spec/specs-go/v1"
)

type pusher struct {
path layout.Path
path Path
}

// Delete implements remote.Pusher.
Expand Down Expand Up @@ -99,11 +96,10 @@ func (lp *pusher) Upload(ctx context.Context, repo name.Repository, l v1.Layer)
if err != nil {
return err
}
fmt.Fprintln(os.Stderr, digest)
return lp.path.WriteBlob(digest, rc)
}

func NewPusher(path layout.Path) remote.Pusher {
func NewPusher(path Path) remote.Pusher {
return &pusher{
path,
}
Expand Down

0 comments on commit d57456b

Please sign in to comment.