Commit Graph

5 Commits

Author SHA1 Message Date
Kir Kolyshkin 521e67f70d pkg/manifests: Serialize: fix gocritic warnings
Like this one:

	pkg/manifests/manifests.go:449:4: importShadow: shadow of imported from 'github.com/containers/image/v5/manifest' package 'manifest' (gocritic)
				manifest, err := json.Marshal(&l.oci)
				^

First, this is not always a "manifest" (sometimes it's OCI image index).
Second, using two variables (manifest and manifestBytes) is not needed.
Finally, rename manifest to res (stands for result).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 17:34:01 -07:00
Kir Kolyshkin bb024dc364 pkg/manifests: fix gocritic paramTypeCombine waring
This one:

	pkg/manifests/manifests.go:75:1: paramTypeCombine: func(manifestDigest digest.Digest, manifestSize int64, manifestType, osName, architecture, osVersion string, osFeatures []string, variant string, features []string, annotations []string) error could be replaced with func(manifestDigest digest.Digest, manifestSize int64, manifestType, osName, architecture, osVersion string, osFeatures []string, variant string, features, annotations []string) error (gocritic)
	func (l *list) AddInstance(manifestDigest digest.Digest, manifestSize int64, manifestType, osName, architecture, osVersion string, osFeatures []string, variant string, features []string, annotations []string) error {
	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 17:01:22 -07:00
Kir Kolyshkin b951b72412 Gofumpt the code
gofumpt is a stricter version of gofmt, basically making the code more
readable, and fixing the gocritic's octalLiterar warnings like this one:

	pkg/util/util_supported.go:26:17: octalLiteral: use new octal literal style, 0o722 (gocritic)
		return (perm & 0722) == 0700
			       ^

Generated by gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 16:50:11 -07:00
Nalin Dahyabhai 00d7471ea0 manifests: set MediaType in OCI manifests and indexes
In image-spec 1.0.2, the MediaType field is now available in OCI
manifest types, so set it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-11-29 17:46:47 -05:00
Valentin Rothberg 32a28aee73 new libimage package
The new `libimage` package is an attempt to consolidate the code for
managing container images and performing operations on them such as
pulling, pushing, saving, searching, local lookups, removing etc.

Over time, Buildah, CRI-O and Podman diverged with respect to managing
container images resulting in a high amount of code duplication
rendering the tools harder to maintain (e.g., bug fixes) and harder to
extend (e.g., adding new features) than necessary.

The desire to share all that code in a common library grew and this is
an attempt to address the it.

The changes as they are now pass Buildah CI [1].  Once merged into
Buildah, I expect follow up changes when migrating Podman over to
`libimage`.

Miscellaneous changes:

* Copy `podman/pkg/signal` to `pkg/signal`.

* Copy `buildah/manifests` to `image/manifests`. Note that the unit
  tests require root privileges. Skip()'s are added when running
  rootless.  Currently excluded from linting.

* Copy `buildah/pkg/manifests` to `pkg/manifests`.  Currently excluded
  from linting.

* Copy `buildah/pkg/supplemented` to `pkg/supplemented`.  Currently
  excluded from linting.

[1] github.com/containers/buildah/pull/3148

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-04-21 11:17:47 +02:00