Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
minor go-binding improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Schrodi committed Jun 23, 2021
1 parent bfc639e commit 59a9736
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
14 changes: 7 additions & 7 deletions bindings-go/apis/v2/accesstypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type OCIRegistryAccess struct {
}

// NewOCIRegistryAccess creates a new OCIRegistryAccess accessor
func NewOCIRegistryAccess(ref string) TypedObjectAccessor {
func NewOCIRegistryAccess(ref string) *OCIRegistryAccess {
return &OCIRegistryAccess{
ObjectType: ObjectType{
Type: OCIRegistryType,
Expand All @@ -61,7 +61,7 @@ type RelativeOciAccess struct {
}

// NewRelativeOciAccess creates a new RelativeOciAccess accessor
func NewRelativeOciAccess(ref string) TypedObjectAccessor {
func NewRelativeOciAccess(ref string) *RelativeOciAccess {
return &RelativeOciAccess{
ObjectType: ObjectType{
Type: RelativeOciReferenceType,
Expand Down Expand Up @@ -95,7 +95,7 @@ type OCIBlobAccess struct {
}

// NewOCIBlobAccess creates a new OCIBlob accessor
func NewOCIBlobAccess(ref, mediaType, digest string, size int64) TypedObjectAccessor {
func NewOCIBlobAccess(ref, mediaType, digest string, size int64) *OCIBlobAccess {
return &OCIBlobAccess{
ObjectType: ObjectType{
Type: OCIBlobType,
Expand All @@ -115,7 +115,7 @@ func (_ *OCIBlobAccess) GetType() string {
const LocalOCIBlobType = "localOciBlob"

// NewLocalOCIBlobAccess creates a new LocalOCIBlob accessor
func NewLocalOCIBlobAccess(digest string) TypedObjectAccessor {
func NewLocalOCIBlobAccess(digest string) *LocalOCIBlobAccess {
return &LocalOCIBlobAccess{
ObjectType: ObjectType{
Type: LocalOCIBlobType,
Expand All @@ -139,7 +139,7 @@ func (_ *LocalOCIBlobAccess) GetType() string {
const LocalFilesystemBlobType = "localFilesystemBlob"

// NewLocalFilesystemBlobAccess creates a new localFilesystemBlob accessor.
func NewLocalFilesystemBlobAccess(path string, mediaType string) TypedObjectAccessor {
func NewLocalFilesystemBlobAccess(path string, mediaType string) *LocalFilesystemBlobAccess {
return &LocalFilesystemBlobAccess{
ObjectType: ObjectType{
Type: LocalFilesystemBlobType,
Expand Down Expand Up @@ -175,7 +175,7 @@ type Web struct {
}

// NewWebAccess creates a new Web accessor
func NewWebAccess(url string) TypedObjectAccessor {
func NewWebAccess(url string) *Web {
return &Web{
ObjectType: ObjectType{
Type: OCIBlobType,
Expand Down Expand Up @@ -205,7 +205,7 @@ type GitHubAccess struct {
}

// NewGitHubAccess creates a new Web accessor
func NewGitHubAccess(url, ref, commit string) TypedObjectAccessor {
func NewGitHubAccess(url, ref, commit string) *GitHubAccess {
return &GitHubAccess{
ObjectType: ObjectType{
Type: GitHubAccessType,
Expand Down
2 changes: 1 addition & 1 deletion bindings-go/apis/v2/repositorytypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type OCIRegistryRepository struct {
}

// NewOCIRegistryRepository creates a new OCIRegistryRepository accessor
func NewOCIRegistryRepository(baseURL string, mapping ComponentNameMapping) Repository {
func NewOCIRegistryRepository(baseURL string, mapping ComponentNameMapping) *OCIRegistryRepository {
if len(mapping) == 0 {
mapping = OCIRegistryURLPathMapping
}
Expand Down
4 changes: 2 additions & 2 deletions bindings-go/ctf/componentarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (ca *ComponentArchive) ensureBlobsPath() error {
return nil
}

// WriteTar tars the current components descriptor and its artifacts.
// WriteTarGzip tars the current components descriptor and its artifacts.
func (ca *ComponentArchive) WriteTarGzip(writer io.Writer) error {
gw := gzip.NewWriter(writer)
if err := ca.WriteTar(gw); err != nil {
Expand Down Expand Up @@ -458,7 +458,7 @@ func (ca *ComponentArchiveBlobResolver) resolve(_ context.Context, res v2.Resour
return nil, nil, UnsupportedResolveType
}
localFSAccess := &v2.LocalFilesystemBlobAccess{}
if err := v2.NewCodec(nil, nil, nil).Decode(res.Access.Raw, localFSAccess); err != nil {
if err := res.Access.DecodeInto(localFSAccess); err != nil {
return nil, nil, fmt.Errorf("unable to decode access to type '%s': %w", res.Access.GetType(), err)
}
blobpath := BlobPath(localFSAccess.Filename)
Expand Down
1 change: 0 additions & 1 deletion bindings-go/oci/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ func (b *ManifestBuilder) addLocalBlobs(ctx context.Context) ([]ocispecv1.Descri
blobDescriptors := make([]ocispecv1.Descriptor, 0)

for i, res := range b.archive.ComponentDescriptor.Resources {

var blob bytes.Buffer
info, err := b.archive.Resolve(ctx, res, &blob)
if err != nil {
Expand Down

0 comments on commit 59a9736

Please sign in to comment.