Skip to content

Commit

Permalink
cmd: Copy IntToInt32Array into img package and use it
Browse files Browse the repository at this point in the history
Since IntToInt32Array was removed from commands package, move it into
out own img package.

Signed-off-by: Stefan Berger <[email protected]>
  • Loading branch information
stefanberger committed Aug 15, 2023
1 parent 80abfcd commit c48dd78
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/ctr/commands/images/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/imgcrypt/cmd/ctr/commands/flags"
"github.com/containerd/imgcrypt/cmd/ctr/commands/img"
imgenc "github.com/containerd/imgcrypt/images/encryption"
"github.com/containerd/imgcrypt/images/encryption/parsehelpers"

Expand Down Expand Up @@ -72,7 +73,7 @@ var decryptCommand = cli.Command{
}
defer cancel()

layers32 := commands.IntToInt32Array(context.IntSlice("layer"))
layers32 := img.IntToInt32Array(context.IntSlice("layer"))

_, descs, err := getImageLayerInfos(client, ctx, local, layers32, context.StringSlice("platform"))
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cmd/ctr/commands/images/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/imgcrypt/cmd/ctr/commands/flags"
"github.com/containerd/imgcrypt/cmd/ctr/commands/img"
"github.com/containerd/imgcrypt/images/encryption/parsehelpers"

"github.com/urfave/cli"
Expand Down Expand Up @@ -85,7 +86,7 @@ var encryptCommand = cli.Command{
return errors.New("no recipients given -- nothing to do")
}

layers32 := commands.IntToInt32Array(context.IntSlice("layer"))
layers32 := img.IntToInt32Array(context.IntSlice("layer"))

_, descs, err := getImageLayerInfos(client, ctx, local, layers32, context.StringSlice("platform"))
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cmd/ctr/commands/images/layerinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/platforms"
"github.com/containerd/imgcrypt/cmd/ctr/commands/img"
"github.com/containerd/imgcrypt/images/encryption/parsehelpers"
"github.com/containers/ocicrypt"

Expand Down Expand Up @@ -72,7 +73,7 @@ var layerinfoCommand = cli.Command{
}
defer cancel()

layers32 := commands.IntToInt32Array(context.IntSlice("layer"))
layers32 := img.IntToInt32Array(context.IntSlice("layer"))

LayerInfos, _, err := getImageLayerInfos(client, ctx, local, layers32, context.StringSlice("platform"))
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions cmd/ctr/commands/img/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,13 @@ func GetImageLayerDescriptors(ctx context.Context, cs content.Store, desc ocispe
}
return lis, nil
}

// IntToInt32Array converts an array of int's to int32's
func IntToInt32Array(in []int) []int32 {
var ret []int32

for _, v := range in {
ret = append(ret, int32(v))
}
return ret
}

0 comments on commit c48dd78

Please sign in to comment.