Skip to content

Commit

Permalink
separate internal and external usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mandelsoft committed Jun 11, 2024
1 parent 4495860 commit 8389139
Show file tree
Hide file tree
Showing 185 changed files with 1,353 additions and 759 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
return s.ProcessBlob(ctx, blobaccess.DataAccessForBytes([]byte(s.Data)), ctx.FileSystem())
return s.ProcessBlob(ctx, blobaccess.DataAccessForData([]byte(s.Data)), ctx.FileSystem())
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (bloba
return nil, "", fmt.Errorf("resource type is dir but a file was provided")
}

access, err := dirtree.BlobAccessForDirTree(inputPath,
access, err := dirtree.BlobAccess(inputPath,
dirtree.WithMimeType(s.MediaType),
dirtree.WithFileSystem(fs),
dirtree.WithCompressWithGzip(s.Compress()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (bloba
if err != nil {
return nil, "", err
}
blob, version, err := dockerdaemon.BlobAccessForImageFromDockerDaemon(s.Path, dockerdaemon.WithVersion(info.ComponentVersion.GetVersion()), dockerdaemon.WithOrigin(info.ComponentVersion))
blob, version, err := dockerdaemon.BlobAccess(s.Path, dockerdaemon.WithVersion(info.ComponentVersion.GetVersion()), dockerdaemon.WithOrigin(info.ComponentVersion))
if err != nil {
return nil, "", err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

. "github.com/mandelsoft/goutils/finalizer"

"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs"
Expand Down Expand Up @@ -92,7 +91,7 @@ func (s *Spec) getVariant(ctx clictx.Context, finalize *Finalizer, variant strin
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
blob, err := dockermulti.BlobAccessForMultiImageFromDockerDaemon(
blob, err := dockermulti.BlobAccess(
dockermulti.WithContext(ctx),
dockermulti.WithPrinter(ctx.Printer()),
dockermulti.WithVariants(s.Variants...),
Expand Down
2 changes: 1 addition & 1 deletion cmds/ocm/commands/ocmcmds/common/inputs/types/helm/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blob
override = false
}

blob, name, vers, err := helm.BlobAccessForHelmChart(path,
blob, name, vers, err := helm.BlobAccess(path,
helm.WithContext(ctx),
helm.WithFileSystem(ctx.FileSystem()),
helm.WithPrinter(ctx.Printer()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (bloba
return nil, "", err
}
}
access, err := mavenblob.BlobAccessForMavenCoords(repo, &s.Coordinates,
access, err := mavenblob.BlobAccessForCoords(repo, &s.Coordinates,
mavenblob.WithCredentialContext(ctx),
mavenblob.WithLoggingContext(ctx),
mavenblob.WithCachingFileSystem(vfsattr.Get(ctx)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs"
"github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs/cpi"
"github.com/open-component-model/ocm/pkg/blobaccess"
ociartifact2 "github.com/open-component-model/ocm/pkg/blobaccess/ociartifact"
ociartifactblob "github.com/open-component-model/ocm/pkg/blobaccess/ociartifact"
"github.com/open-component-model/ocm/pkg/contexts/oci/grammar"
"github.com/open-component-model/ocm/pkg/contexts/oci/repositories/docker"
"github.com/open-component-model/ocm/pkg/contexts/oci/transfer/filters"
Expand Down Expand Up @@ -47,7 +47,7 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
return allErrs
}

func (s *Spec) CreateFilter() ociartifact2.Option {
func (s *Spec) CreateFilter() ociartifactblob.Option {
var filter []filters.Filter

for _, v := range s.Platforms {
Expand All @@ -57,18 +57,18 @@ func (s *Spec) CreateFilter() ociartifact2.Option {
}
}
if len(filter) > 0 {
return ociartifact2.WithFilter(filters.Or(filter...))
return ociartifactblob.WithFilter(filters.Or(filter...))
}
return nil
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
filter := s.CreateFilter()
blob, version, err := ociartifact2.BlobAccessForOCIArtifact(s.Path,
blob, version, err := ociartifactblob.BlobAccess(s.Path,
filter,
ociartifact2.WithContext(ctx),
ociartifact2.WithPrinter(ctx.Printer()),
ociartifact2.WithVersion(info.ComponentVersion.GetVersion()),
ociartifactblob.WithContext(ctx),
ociartifactblob.WithPrinter(ctx.Printer()),
ociartifactblob.WithVersion(info.ComponentVersion.GetVersion()),
)
if err != nil {
return nil, "", err
Expand Down
2 changes: 1 addition & 1 deletion cmds/ocm/commands/ocmcmds/common/inputs/types/utf8/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (bloba
if err != nil {
return nil, "", err
}
return s.ProcessBlob(ctx, blobaccess.DataAccessForBytes(data), ctx.FileSystem())
return s.ProcessBlob(ctx, blobaccess.DataAccessForData(data), ctx.FileSystem())
}

func Prepare(raw []byte) (interface{}, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmds/ocm/commands/ocmcmds/common/inputs/types/wget/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
access, err := wget.BlobAccessForWget(s.URL,
access, err := wget.BlobAccess(s.URL,
wget.WithCredentialContext(ctx),
wget.WithLoggingContext(ctx),
wget.WithMimeType(s.MimeType),
Expand Down
2 changes: 1 addition & 1 deletion cmds/ocm/commands/ocmcmds/sources/add/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/open-component-model/ocm/cmds/ocm/testhelper"

"github.com/open-component-model/ocm/pkg/blobaccess"

"github.com/open-component-model/ocm/pkg/common"
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/localblob"
"github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc"
Expand Down
4 changes: 2 additions & 2 deletions cmds/ocm/commands/toicmds/package/bootstrap/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (o *Command) Complete(args []string) error {
if err != nil {
return errors.Wrapf(err, "failed reading credentials file %q", o.CredentialsFile)
}
o.Credentials = blobaccess.DataAccessForBytes(data, o.CredentialsFile)
o.Credentials = blobaccess.DataAccessForData(data, o.CredentialsFile)
}
if len(o.ParameterFile) == 0 {
if ok, _ := vfs.FileExists(o.FileSystem(), DEFAULT_PARAMETER_FILE); ok {
Expand All @@ -212,7 +212,7 @@ func (o *Command) Complete(args []string) error {
if err != nil {
return errors.Wrapf(err, "failed reading parameter file %q", o.ParameterFile)
}
o.Parameters = blobaccess.DataAccessForBytes(data, o.ParameterFile)
o.Parameters = blobaccess.DataAccessForData(data, o.ParameterFile)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/creds.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ consumer ids always feature the attribute `type`, describing the kind of
context.

For example, to describe the request for credentials for
an [OCI registry](../../pkg/contexts/oci/identity/identity.go) and repository,
an [OCI registry](../../pkg/contexts/credentials/builtin/oci/identity/identity.go) and repository,
the type value is `oci.CONSUMER_TYPE`. Additionally, the following
attributes are used to fully describe the usage context.

Expand Down
2 changes: 1 addition & 1 deletion examples/lib/ctf/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/finalizer"
"github.com/mandelsoft/vfs/pkg/memoryfs"

"github.com/open-component-model/ocm/pkg/blobaccess"

"github.com/open-component-model/ocm/pkg/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessobj"
"github.com/open-component-model/ocm/pkg/contexts/ocm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/finalizer"

"github.com/open-component-model/ocm/pkg/blobaccess"

"github.com/open-component-model/ocm/pkg/common"
"github.com/open-component-model/ocm/pkg/contexts/ocm"
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact"
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/tour/03-working-with-credentials/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/finalizer"

"github.com/open-component-model/ocm/pkg/blobaccess"

"github.com/open-component-model/ocm/pkg/common"
"github.com/open-component-model/ocm/pkg/contexts/credentials"
"github.com/open-component-model/ocm/pkg/contexts/ocm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/finalizer"

"github.com/open-component-model/ocm/pkg/blobaccess"

"github.com/open-component-model/ocm/pkg/common"
"github.com/open-component-model/ocm/pkg/contexts/ocm"
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact"
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/tour/06-signing-component-versions/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

"github.com/mandelsoft/goutils/errors"
"github.com/mandelsoft/goutils/finalizer"
"github.com/open-component-model/ocm/pkg/blobaccess"

"github.com/open-component-model/ocm/examples/lib/helper"
"github.com/open-component-model/ocm/pkg/blobaccess"
"github.com/open-component-model/ocm/pkg/common"
"github.com/open-component-model/ocm/pkg/contexts/ocm"
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact"
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/transfer1/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"github.com/mandelsoft/goutils/finalizer"
"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/vfs"
"github.com/open-component-model/ocm/pkg/blobaccess"

"github.com/mandelsoft/goutils/errors"
"github.com/open-component-model/ocm/examples/lib/helper"
"github.com/open-component-model/ocm/pkg/blobaccess"
"github.com/open-component-model/ocm/pkg/common"
"github.com/open-component-model/ocm/pkg/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessobj"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package standard
package blobaccess

import (
"bytes"
Expand All @@ -12,10 +12,6 @@ import (
mimetypes "github.com/open-component-model/ocm/pkg/mime"
)

type _nopCloser = iotools.NopCloser

////////////////////////////////////////////////////////////////////////////////

type bytesAccess struct {
_nopCloser
data []byte
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/vfs"

"github.com/open-component-model/ocm/pkg/blobaccess"
"github.com/open-component-model/ocm/pkg/blobaccess/blobaccess"
"github.com/open-component-model/ocm/pkg/blobaccess/bpi"
"github.com/open-component-model/ocm/pkg/blobaccess/file"
"github.com/open-component-model/ocm/pkg/mime"
)

Expand Down Expand Up @@ -43,7 +44,7 @@ var _ = Describe("blob access ref counting", func() {
temp := Must(os.CreateTemp("", "testfile*"))
path := temp.Name()
temp.Close()
blob := blobaccess.ForTemporaryFilePath(mime.MIME_TEXT, path, osfs.OsFs)
blob := file.BlobAccessForTemporaryFilePath(mime.MIME_TEXT, path)

Expect(vfs.FileExists(osfs.OsFs, path)).To(BeTrue())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/mandelsoft/vfs/pkg/vfs"

"github.com/open-component-model/ocm/pkg/blobaccess/file"
"github.com/open-component-model/ocm/pkg/utils"
)

Expand All @@ -17,15 +18,15 @@ func ForCachedBlobAccess(blob BlobAccess, fss ...vfs.FileSystem) (BlobAccess, er
}
defer r.Close()

file, err := vfs.TempFile(fs, "", "cachedBlob*")
f, err := vfs.TempFile(fs, "", "cachedBlob*")
if err != nil {
return nil, err
}
_, err = io.Copy(file, r)
_, err = io.Copy(f, r)
if err != nil {
return nil, err
}
file.Close()
f.Close()

return ForTemporaryFilePath(blob.MimeType(), file.Name(), fs), nil
return file.BlobAccessForTemporaryFilePath(blob.MimeType(), f.Name(), file.WithFileSystem(fs)), nil
}
Loading

0 comments on commit 8389139

Please sign in to comment.