Skip to content

Commit

Permalink
more package alignments
Browse files Browse the repository at this point in the history
  • Loading branch information
mandelsoft committed Oct 19, 2023
1 parent d3ad2fb commit fa1b95c
Show file tree
Hide file tree
Showing 61 changed files with 153 additions and 141 deletions.
8 changes: 4 additions & 4 deletions cmds/ocm/commands/ocmcmds/common/inputs/inputtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/open-component-model/ocm/pkg/cobrautils/flagsets"
"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/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/contexts/clictx"
"github.com/open-component-model/ocm/pkg/contexts/datacontext"
"github.com/open-component-model/ocm/pkg/errors"
Expand Down Expand Up @@ -87,7 +87,7 @@ type InputResourceInfo struct {
type InputSpec interface {
runtime.VersionedTypedObject
Validate(fldPath *field.Path, ctx Context, inputFilePath string) field.ErrorList
GetBlob(ctx Context, info InputResourceInfo) (accessio.BlobAccess, string, error)
GetBlob(ctx Context, info InputResourceInfo) (blobaccess.BlobAccess, string, error)
GetInputVersion(ctx Context) string
}

Expand Down Expand Up @@ -272,7 +272,7 @@ func (r *UnknownInputSpec) Validate(fldPath *field.Path, ctx Context, inputFileP
return field.ErrorList{field.Invalid(fldPath.Child("type"), r.GetType(), "unknown type")}
}

func (r *UnknownInputSpec) GetBlob(ctx Context, info InputResourceInfo) (accessio.BlobAccess, string, error) {
func (r *UnknownInputSpec) GetBlob(ctx Context, info InputResourceInfo) (blobaccess.BlobAccess, string, error) {
return nil, "", errors.ErrUnknown("input type", r.GetType())
}

Expand Down Expand Up @@ -329,7 +329,7 @@ func (s *GenericInputSpec) Validate(fldPath *field.Path, ctx Context, inputFileP
return s.effective.Validate(fldPath, ctx, inputFilePath)
}

func (s *GenericInputSpec) GetBlob(ctx Context, info InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *GenericInputSpec) GetBlob(ctx Context, info InputResourceInfo) (blobaccess.BlobAccess, string, error) {
if s.effective == nil {
var err error
s.effective, err = s.Evaluate(For(ctx))
Expand Down
6 changes: 3 additions & 3 deletions cmds/ocm/commands/ocmcmds/common/inputs/types/binary/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/runtime"
)

Expand Down Expand Up @@ -39,6 +39,6 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
return nil
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
return s.ProcessBlob(ctx, accessio.DataAccessForBytes([]byte(s.Data)), ctx.FileSystem())
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())
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess/dirtree"
"github.com/open-component-model/ocm/pkg/utils"
)
Expand Down Expand Up @@ -58,7 +58,7 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
return allErrs
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
fs := ctx.FileSystem()
inputInfo, inputPath, err := inputs.FileInfo(ctx, s.Path, info.InputFilePath)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmds/ocm/commands/ocmcmds/common/inputs/types/docker/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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/cmds/ocm/commands/ocmcmds/common/inputs/types/ociimage"
"github.com/open-component-model/ocm/pkg/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/contexts/oci/repositories/artifactset"
"github.com/open-component-model/ocm/pkg/contexts/oci/repositories/docker"
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact"
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) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
ctx.Printf("image %s\n", s.Path)
locator, version, err := docker.ParseGenericRef(s.Path)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ package dockermulti
import (
"fmt"

"github.com/open-component-model/ocm/pkg/contexts/oci/annotations"
. "github.com/open-component-model/ocm/pkg/finalizer"

"github.com/opencontainers/go-digest"
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs"
"github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs/types/ociimage"
"github.com/open-component-model/ocm/pkg/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/contexts/clictx"
"github.com/open-component-model/ocm/pkg/contexts/oci"
"github.com/open-component-model/ocm/pkg/contexts/oci/annotations"
"github.com/open-component-model/ocm/pkg/contexts/oci/artdesc"
"github.com/open-component-model/ocm/pkg/contexts/oci/cpi"
"github.com/open-component-model/ocm/pkg/contexts/oci/repositories/artifactset"
Expand Down Expand Up @@ -99,13 +99,13 @@ func (s *Spec) getVariant(ctx clictx.Context, finalize *Finalizer, variant strin
return art, nil
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
index := artdesc.NewIndexArtifact()
i := 0

index.SetAnnotation(annotations.COMPVERS_ANNOTATION, info.ComponentVersion.String())

feedback := func(blob accessio.BlobAccess, art cpi.ArtifactAccess) error {
feedback := func(blob blobaccess.BlobAccess, art cpi.ArtifactAccess) error {
desc := artdesc.DefaultBlobDescriptor(blob)
if art.IsManifest() {
cfgBlob, err := art.ManifestAccess().GetConfigBlob()
Expand All @@ -130,7 +130,7 @@ func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (acces

blob, err := artifactset.SynthesizeArtifactBlobFor(info.ComponentVersion.GetVersion(), func() (fac artifactset.ArtifactFactory, main bool, err error) {
var art cpi.ArtifactAccess
var blob accessio.BlobAccess
var blob blobaccess.BlobAccess

switch {
case i > len(s.Variants):
Expand Down
4 changes: 2 additions & 2 deletions cmds/ocm/commands/ocmcmds/common/inputs/types/file/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
)

type Spec struct {
Expand All @@ -28,6 +28,6 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
return (&FileProcessSpec{s.MediaFileSpec, nil}).Validate(fldPath, ctx, inputFilePath)
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
return (&FileProcessSpec{s.MediaFileSpec, nil}).GetBlob(ctx, info)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/errors"
"github.com/open-component-model/ocm/pkg/mime"
Expand All @@ -36,7 +35,7 @@ func (s *FileProcessSpec) Validate(fldPath *field.Path, ctx inputs.Context, inpu
return allErrs
}

func (s *FileProcessSpec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *FileProcessSpec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
fs := ctx.FileSystem()
inputInfo, inputPath, err := inputs.FileInfo(ctx, s.Path, info.InputFilePath)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmds/ocm/commands/ocmcmds/common/inputs/types/helm/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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/common"
"github.com/open-component-model/ocm/pkg/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
ocihelm "github.com/open-component-model/ocm/pkg/contexts/oci/ociutils/helm"
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact"
"github.com/open-component-model/ocm/pkg/errors"
Expand Down Expand Up @@ -92,7 +92,7 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
return allErrs
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blob accessio.BlobAccess, hint string, err error) {
func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blob blobaccess.BlobAccess, hint string, err error) {
var chartLoader loader.Loader
if s.HelmRepository == "" {
_, inputPath, err := inputs.FileInfo(ctx, s.Path, info.InputFilePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/contexts/oci"
"github.com/open-component-model/ocm/pkg/contexts/oci/grammar"
"github.com/open-component-model/ocm/pkg/contexts/oci/repositories/artifactset"
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) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
ctx.Printf("image %s\n", s.Path)
ref, err := oci.ParseRef(s.Path)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmds/ocm/commands/ocmcmds/common/inputs/types/spiff/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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/cmds/ocm/commands/ocmcmds/common/inputs/types/file"
"github.com/open-component-model/ocm/pkg/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/errors"
"github.com/open-component-model/ocm/pkg/runtime"
)
Expand Down Expand Up @@ -62,7 +62,7 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
return allErrs
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
return (&file.FileProcessSpec{s.MediaFileSpec, s.process}).GetBlob(ctx, info)
}

Expand Down
6 changes: 3 additions & 3 deletions cmds/ocm/commands/ocmcmds/common/inputs/types/utf8/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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/common/accessio"
"github.com/open-component-model/ocm/pkg/common/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/runtime"
)

Expand Down Expand Up @@ -110,7 +110,7 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s
return nil
}

func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (accessio.BlobAccess, string, error) {
func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) {
data, err := Plain([]byte(s.Text))

if s.Json != nil {
Expand All @@ -125,7 +125,7 @@ func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (acces
if err != nil {
return nil, "", err
}
return s.ProcessBlob(ctx, accessio.DataAccessForBytes(data), ctx.FileSystem())
return s.ProcessBlob(ctx, blobaccess.DataAccessForBytes(data), ctx.FileSystem())
}

func Prepare(raw []byte) (interface{}, error) {
Expand Down
5 changes: 2 additions & 3 deletions cmds/ocm/commands/toicmds/package/bootstrap/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/open-component-model/ocm/cmds/ocm/pkg/utils"
topicbootstrap "github.com/open-component-model/ocm/cmds/ocm/topics/toi/bootstrapping"
"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/accessio/blobaccess"
"github.com/open-component-model/ocm/pkg/contexts/clictx"
"github.com/open-component-model/ocm/pkg/contexts/oci/repositories/ocireg"
Expand Down Expand Up @@ -200,7 +199,7 @@ func (o *Command) Complete(args []string) error {
if err != nil {
return errors.Wrapf(err, "failed reading credentials file %q", o.CredentialsFile)
}
o.Credentials = accessio.DataAccessForBytes(data, o.CredentialsFile)
o.Credentials = blobaccess.DataAccessForBytes(data, o.CredentialsFile)
}
if len(o.ParameterFile) == 0 {
if ok, _ := vfs.FileExists(o.FileSystem(), DEFAULT_PARAMETER_FILE); ok {
Expand All @@ -212,7 +211,7 @@ func (o *Command) Complete(args []string) error {
if err != nil {
return errors.Wrapf(err, "failed reading parameter file %q", o.ParameterFile)
}
o.Parameters = accessio.DataAccessForBytes(data, o.ParameterFile)
o.Parameters = blobaccess.DataAccessForBytes(data, o.ParameterFile)
}
return nil
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/common/accessio/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ type NopCloser = iotools.NopCloser
////////////////////////////////////////////////////////////////////////////////

// Deprecated: use blobaccess.DataAccessForReaderFunction.
func DataAccessForReaderFunction(reader func() (io.ReadCloser, error), origin string) DataAccess {
func DataAccessForReaderFunction(reader func() (io.ReadCloser, error), origin string) blobaccess.DataAccess {
return blobaccess.DataAccessForReaderFunction(reader, origin)
}

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

// Deprecated: use blobaccess.DataAccessForFile.
func DataAccessForFile(fs vfs.FileSystem, path string) DataAccess {
func DataAccessForFile(fs vfs.FileSystem, path string) blobaccess.DataAccess {
return blobaccess.DataAccessForFile(fs, path)
}

Expand Down Expand Up @@ -131,19 +131,19 @@ func BlobAccessForFile(mimeType string, path string, fss ...vfs.FileSystem) blob
}

// Deprecated: use blobaccess.ForFileWithCloser.
func BlobAccessForFileWithCloser(closer io.Closer, mimeType string, path string, fss ...vfs.FileSystem) BlobAccess {
func BlobAccessForFileWithCloser(closer io.Closer, mimeType string, path string, fss ...vfs.FileSystem) blobaccess.BlobAccess {
return blobaccess.ForFileWithCloser(closer, mimeType, path, fss...)
}

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

// Deprecated: use blobaccess.ForTemporaryFile.
func BlobAccessForTemporaryFile(mime string, temp vfs.File, fss ...vfs.FileSystem) BlobAccess {
func BlobAccessForTemporaryFile(mime string, temp vfs.File, fss ...vfs.FileSystem) blobaccess.BlobAccess {
return blobaccess.ForTemporaryFile(mime, temp, fss...)
}

// Deprecated: use blobaccess.ForTemporaryFilePath.
func BlobAccessForTemporaryFilePath(mime string, temp string, fss ...vfs.FileSystem) BlobAccess {
func BlobAccessForTemporaryFilePath(mime string, temp string, fss ...vfs.FileSystem) blobaccess.BlobAccess {
return blobaccess.ForTemporaryFilePath(mime, temp, fss...)
}

Expand Down
Loading

0 comments on commit fa1b95c

Please sign in to comment.