Skip to content

Commit c48dd78

Browse files
committed
cmd: Copy IntToInt32Array into img package and use it
Since IntToInt32Array was removed from commands package, move it into out own img package. Signed-off-by: Stefan Berger <[email protected]>
1 parent 80abfcd commit c48dd78

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

cmd/ctr/commands/images/decrypt.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/containerd/containerd/cmd/ctr/commands"
2424
"github.com/containerd/imgcrypt/cmd/ctr/commands/flags"
25+
"github.com/containerd/imgcrypt/cmd/ctr/commands/img"
2526
imgenc "github.com/containerd/imgcrypt/images/encryption"
2627
"github.com/containerd/imgcrypt/images/encryption/parsehelpers"
2728

@@ -72,7 +73,7 @@ var decryptCommand = cli.Command{
7273
}
7374
defer cancel()
7475

75-
layers32 := commands.IntToInt32Array(context.IntSlice("layer"))
76+
layers32 := img.IntToInt32Array(context.IntSlice("layer"))
7677

7778
_, descs, err := getImageLayerInfos(client, ctx, local, layers32, context.StringSlice("platform"))
7879
if err != nil {

cmd/ctr/commands/images/encrypt.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/containerd/containerd/cmd/ctr/commands"
2424
"github.com/containerd/imgcrypt/cmd/ctr/commands/flags"
25+
"github.com/containerd/imgcrypt/cmd/ctr/commands/img"
2526
"github.com/containerd/imgcrypt/images/encryption/parsehelpers"
2627

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

88-
layers32 := commands.IntToInt32Array(context.IntSlice("layer"))
89+
layers32 := img.IntToInt32Array(context.IntSlice("layer"))
8990

9091
_, descs, err := getImageLayerInfos(client, ctx, local, layers32, context.StringSlice("platform"))
9192
if err != nil {

cmd/ctr/commands/images/layerinfo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
"github.com/containerd/containerd/cmd/ctr/commands"
2828
"github.com/containerd/containerd/platforms"
29+
"github.com/containerd/imgcrypt/cmd/ctr/commands/img"
2930
"github.com/containerd/imgcrypt/images/encryption/parsehelpers"
3031
"github.com/containers/ocicrypt"
3132

@@ -72,7 +73,7 @@ var layerinfoCommand = cli.Command{
7273
}
7374
defer cancel()
7475

75-
layers32 := commands.IntToInt32Array(context.IntSlice("layer"))
76+
layers32 := img.IntToInt32Array(context.IntSlice("layer"))
7677

7778
LayerInfos, _, err := getImageLayerInfos(client, ctx, local, layers32, context.StringSlice("platform"))
7879
if err != nil {

cmd/ctr/commands/img/utils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,13 @@ func GetImageLayerDescriptors(ctx context.Context, cs content.Store, desc ocispe
7979
}
8080
return lis, nil
8181
}
82+
83+
// IntToInt32Array converts an array of int's to int32's
84+
func IntToInt32Array(in []int) []int32 {
85+
var ret []int32
86+
87+
for _, v := range in {
88+
ret = append(ret, int32(v))
89+
}
90+
return ret
91+
}

0 commit comments

Comments
 (0)