Skip to content

Commit

Permalink
Merge pull request #4880 from testwill/pkg-import
Browse files Browse the repository at this point in the history
chore: pkg imported more than once
  • Loading branch information
openshift-merge-robot authored Jun 27, 2023
2 parents 33b7088 + c34c6d1 commit 6589be3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
9 changes: 4 additions & 5 deletions imagebuildah/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/image/v5/manifest"
is "github.com/containers/image/v5/storage"
storageTransport "github.com/containers/image/v5/storage"
"github.com/containers/image/v5/transports"
"github.com/containers/image/v5/transports/alltransports"
Expand Down Expand Up @@ -424,7 +423,7 @@ func (b *Executor) getImageTypeAndHistoryAndDiffIDs(ctx context.Context, imageID
if ok {
return imageInfo.manifestType, imageInfo.history, imageInfo.diffIDs, imageInfo.err
}
imageRef, err := is.Transport.ParseStoreReference(b.store, "@"+imageID)
imageRef, err := storageTransport.Transport.ParseStoreReference(b.store, "@"+imageID)
if err != nil {
return "", nil, nil, fmt.Errorf("getting image reference %q: %w", imageID, err)
}
Expand Down Expand Up @@ -992,8 +991,8 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
// Add additional tags and print image names recorded in storage
if dest, err := b.resolveNameToImageRef(b.output); err == nil {
switch dest.Transport().Name() {
case is.Transport.Name():
img, err := is.Transport.GetStoreImage(b.store, dest)
case storageTransport.Transport.Name():
img, err := storageTransport.Transport.GetStoreImage(b.store, dest)
if err != nil {
return imageID, ref, fmt.Errorf("locating just-written image %q: %w", transports.ImageName(dest), err)
}
Expand All @@ -1004,7 +1003,7 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
logrus.Debugf("assigned names %v to image %q", img.Names, img.ID)
}
// Report back the caller the tags applied, if any.
img, err = is.Transport.GetStoreImage(b.store, dest)
img, err = storageTransport.Transport.GetStoreImage(b.store, dest)
if err != nil {
return imageID, ref, fmt.Errorf("locating just-written image %q: %w", transports.ImageName(dest), err)
}
Expand Down
5 changes: 2 additions & 3 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/containers/image/v5/types"
"github.com/containers/storage/pkg/lockfile"
"github.com/opencontainers/runtime-spec/specs-go"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -199,8 +198,8 @@ type runMountInfo struct {

// IDMaps are the UIDs, GID, and maps for the run
type IDMaps struct {
uidmap []spec.LinuxIDMapping
gidmap []spec.LinuxIDMapping
uidmap []specs.LinuxIDMapping
gidmap []specs.LinuxIDMapping
rootUID int
rootGID int
processUID int
Expand Down
17 changes: 8 additions & 9 deletions run_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
storageTypes "github.com/containers/storage/types"
"github.com/opencontainers/go-digest"
"github.com/opencontainers/runtime-spec/specs-go"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -118,7 +117,7 @@ func (b *Builder) addResolvConf(rdir string, chownOpts *idtools.IDPair, dnsServe
}

// generateHosts creates a containers hosts file
func (b *Builder) generateHosts(rdir string, chownOpts *idtools.IDPair, imageRoot string, spec *spec.Spec) (string, error) {
func (b *Builder) generateHosts(rdir string, chownOpts *idtools.IDPair, imageRoot string, spec *specs.Spec) (string, error) {
conf, err := config.Default()
if err != nil {
return "", err
Expand Down Expand Up @@ -1468,7 +1467,7 @@ func runSetupBuiltinVolumes(mountLabel, mountPoint, containerDir string, builtin
}

// Destinations which can be cleaned up after every RUN
func cleanableDestinationListFromMounts(mounts []spec.Mount) []string {
func cleanableDestinationListFromMounts(mounts []specs.Mount) []string {
mountDest := []string{}
for _, mount := range mounts {
// Add all destination to mountArtifacts so that they can be cleaned up later
Expand Down Expand Up @@ -1509,7 +1508,7 @@ func checkIfMountDestinationPreExists(root string, dest string) (bool, error) {
// runSetupRunMounts sets up mounts that exist only in this RUN, not in subsequent runs
//
// If this function succeeds, the caller must unlock runMountArtifacts.TargetLocks (when??)
func (b *Builder) runSetupRunMounts(mountPoint string, mounts []string, sources runMountInfo, idMaps IDMaps) ([]spec.Mount, *runMountArtifacts, error) {
func (b *Builder) runSetupRunMounts(mountPoint string, mounts []string, sources runMountInfo, idMaps IDMaps) ([]specs.Mount, *runMountArtifacts, error) {
// If `type` is not set default to TypeBind
mountType := define.TypeBind
mountTargets := make([]string, 0, 10)
Expand All @@ -1527,7 +1526,7 @@ func (b *Builder) runSetupRunMounts(mountPoint string, mounts []string, sources
}
}()
for _, mount := range mounts {
var mountSpec *spec.Mount
var mountSpec *specs.Mount
var err error
var envFile, image string
var agent *sshagent.AgentServer
Expand Down Expand Up @@ -1622,7 +1621,7 @@ func (b *Builder) runSetupRunMounts(mountPoint string, mounts []string, sources
return finalMounts, artifacts, nil
}

func (b *Builder) getBindMount(tokens []string, context *imageTypes.SystemContext, contextDir string, stageMountPoints map[string]internal.StageMountDetails, idMaps IDMaps, workDir string) (*spec.Mount, string, error) {
func (b *Builder) getBindMount(tokens []string, context *imageTypes.SystemContext, contextDir string, stageMountPoints map[string]internal.StageMountDetails, idMaps IDMaps, workDir string) (*specs.Mount, string, error) {
if contextDir == "" {
return nil, "", errors.New("Context Directory for current run invocation is not configured")
}
Expand All @@ -1639,7 +1638,7 @@ func (b *Builder) getBindMount(tokens []string, context *imageTypes.SystemContex
return &volumes[0], image, nil
}

func (b *Builder) getTmpfsMount(tokens []string, idMaps IDMaps) (*spec.Mount, error) {
func (b *Builder) getTmpfsMount(tokens []string, idMaps IDMaps) (*specs.Mount, error) {
var optionMounts []specs.Mount
mount, err := internalParse.GetTmpfsMount(tokens)
if err != nil {
Expand All @@ -1653,7 +1652,7 @@ func (b *Builder) getTmpfsMount(tokens []string, idMaps IDMaps) (*spec.Mount, er
return &volumes[0], nil
}

func (b *Builder) getSecretMount(tokens []string, secrets map[string]define.Secret, idMaps IDMaps, workdir string) (*spec.Mount, string, error) {
func (b *Builder) getSecretMount(tokens []string, secrets map[string]define.Secret, idMaps IDMaps, workdir string) (*specs.Mount, string, error) {
errInvalidSyntax := errors.New("secret should have syntax id=id[,target=path,required=bool,mode=uint,uid=uint,gid=uint")
if len(tokens) == 0 {
return nil, "", errInvalidSyntax
Expand Down Expand Up @@ -1781,7 +1780,7 @@ func (b *Builder) getSecretMount(tokens []string, secrets map[string]define.Secr
}

// getSSHMount parses the --mount type=ssh flag in the Containerfile, checks if there's an ssh source provided, and creates and starts an ssh-agent to be forwarded into the container
func (b *Builder) getSSHMount(tokens []string, count int, sshsources map[string]*sshagent.Source, idMaps IDMaps) (*spec.Mount, *sshagent.AgentServer, error) {
func (b *Builder) getSSHMount(tokens []string, count int, sshsources map[string]*sshagent.Source, idMaps IDMaps) (*specs.Mount, *sshagent.AgentServer, error) {
errInvalidSyntax := errors.New("ssh should have syntax id=id[,target=path,required=bool,mode=uint,uid=uint,gid=uint")

var err error
Expand Down
19 changes: 9 additions & 10 deletions run_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/containers/storage/pkg/unshare"
"github.com/docker/go-units"
"github.com/opencontainers/runtime-spec/specs-go"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -157,7 +156,7 @@ func (b *Builder) Run(command []string, options RunOptions) error {
for _, m := range g.Mounts() {
mounts[m.Destination] = true
}
newMounts := []spec.Mount{}
newMounts := []specs.Mount{}
for _, d := range b.Devices {
// Default permission is read-only.
perm := "ro"
Expand All @@ -166,7 +165,7 @@ func (b *Builder) Run(command []string, options RunOptions) error {
if strings.Contains(string(d.Rule.Permissions), "w") {
perm = "rw"
}
devMnt := spec.Mount{
devMnt := specs.Mount{
Destination: d.Destination,
Type: parse.TypeBind,
Source: d.Source,
Expand All @@ -185,7 +184,7 @@ func (b *Builder) Run(command []string, options RunOptions) error {
g.Config.Mounts = append(newMounts, g.Config.Mounts...)
} else {
for _, d := range b.Devices {
sDev := spec.LinuxDevice{
sDev := specs.LinuxDevice{
Type: string(d.Type),
Path: d.Path,
Major: d.Major,
Expand Down Expand Up @@ -380,8 +379,8 @@ rootless=%d
return err
}

func (b *Builder) setupOCIHooks(config *spec.Spec, hasVolumes bool) (map[string][]spec.Hook, error) {
allHooks := make(map[string][]spec.Hook)
func (b *Builder) setupOCIHooks(config *specs.Spec, hasVolumes bool) (map[string][]specs.Hook, error) {
allHooks := make(map[string][]specs.Hook)
if len(b.CommonBuildOpts.OCIHooksDir) == 0 {
if unshare.IsRootless() {
return nil, nil
Expand Down Expand Up @@ -1107,7 +1106,7 @@ func setupCapabilities(g *generate.Generator, defaultCapabilities, adds, drops [
return setupCapDrop(g, drops...)
}

func addOrReplaceMount(mounts []specs.Mount, mount specs.Mount) []spec.Mount {
func addOrReplaceMount(mounts []specs.Mount, mount specs.Mount) []specs.Mount {
for i := range mounts {
if mounts[i].Destination == mount.Destination {
mounts[i] = mount
Expand All @@ -1120,7 +1119,7 @@ func addOrReplaceMount(mounts []specs.Mount, mount specs.Mount) []spec.Mount {
// setupSpecialMountSpecChanges creates special mounts for depending on the namespaces
// logic taken from podman and adapted for buildah
// https://github.com/containers/podman/blob/4ba71f955a944790edda6e007e6d074009d437a7/pkg/specgen/generate/oci.go#L178
func setupSpecialMountSpecChanges(spec *spec.Spec, shmSize string) ([]specs.Mount, error) {
func setupSpecialMountSpecChanges(spec *specs.Spec, shmSize string) ([]specs.Mount, error) {
mounts := spec.Mounts
isRootless := unshare.IsRootless()
isNewUserns := false
Expand Down Expand Up @@ -1236,7 +1235,7 @@ func setupSpecialMountSpecChanges(spec *spec.Spec, shmSize string) ([]specs.Moun
return mounts, nil
}

func checkIdsGreaterThan5(ids []spec.LinuxIDMapping) bool {
func checkIdsGreaterThan5(ids []specs.LinuxIDMapping) bool {
for _, r := range ids {
if r.ContainerID <= 5 && 5 < r.ContainerID+r.Size {
return true
Expand All @@ -1246,7 +1245,7 @@ func checkIdsGreaterThan5(ids []spec.LinuxIDMapping) bool {
}

// If this function succeeds and returns a non-nil *lockfile.LockFile, the caller must unlock it (when??).
func (b *Builder) getCacheMount(tokens []string, stageMountPoints map[string]internal.StageMountDetails, idMaps IDMaps, workDir string) (*spec.Mount, *lockfile.LockFile, error) {
func (b *Builder) getCacheMount(tokens []string, stageMountPoints map[string]internal.StageMountDetails, idMaps IDMaps, workDir string) (*specs.Mount, *lockfile.LockFile, error) {
var optionMounts []specs.Mount
mount, targetLock, err := internalParse.GetCacheMount(tokens, b.store, b.MountLabel, stageMountPoints, workDir)
if err != nil {
Expand Down

0 comments on commit 6589be3

Please sign in to comment.