Skip to content

Commit 23f05ef

Browse files
authored
Merge pull request #301 from tri-adam/sif-v2-3.8
Upgrade to SIF v2 (release-3.8)
2 parents 63938fc + 68ea258 commit 23f05ef

File tree

27 files changed

+427
-542
lines changed

27 files changed

+427
-542
lines changed

cmd/internal/cli/inspect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018-2020, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2018-2021, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE.md file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
@@ -20,7 +20,7 @@ import (
2020
"strings"
2121

2222
"github.com/spf13/cobra"
23-
"github.com/sylabs/sif/pkg/sif"
23+
"github.com/sylabs/sif/v2/pkg/sif"
2424
"github.com/sylabs/singularity/docs"
2525
"github.com/sylabs/singularity/internal/pkg/util/env"
2626
"github.com/sylabs/singularity/pkg/cmdline"

cmd/internal/cli/pgp.go

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2020, Control Command Inc. All rights reserved.
2-
// Copyright (c) 2020, Sylabs Inc. All rights reserved.
2+
// Copyright (c) 2020-2021, Sylabs Inc. All rights reserved.
33
// This software is licensed under a 3-clause BSD license. Please consult the LICENSE.md file
44
// distributed with the sources of this project regarding your rights to use or distribute this
55
// software.
@@ -16,15 +16,15 @@ import (
1616

1717
"github.com/sylabs/singularity/internal/pkg/buildcfg"
1818

19+
"github.com/ProtonMail/go-crypto/openpgp"
20+
"github.com/ProtonMail/go-crypto/openpgp/packet"
1921
"github.com/fatih/color"
20-
"github.com/sylabs/sif/pkg/integrity"
21-
"github.com/sylabs/sif/pkg/sif"
22+
"github.com/sylabs/sif/v2/pkg/integrity"
23+
"github.com/sylabs/sif/v2/pkg/sif"
2224
"github.com/sylabs/singularity/internal/app/singularity"
2325
"github.com/sylabs/singularity/internal/pkg/util/interactive"
2426
"github.com/sylabs/singularity/pkg/sylog"
2527
"github.com/sylabs/singularity/pkg/sypgp"
26-
"golang.org/x/crypto/openpgp"
27-
"golang.org/x/crypto/openpgp/packet"
2828
)
2929

3030
var (
@@ -175,28 +175,22 @@ func outputVerify(f *sif.FileImage, r integrity.VerifyResult) bool {
175175
fmt.Printf("%-4s|%-8s|%-8s|%s\n", "ID", "GROUP", "LINK", "TYPE")
176176
fmt.Print("------------------------------------------------\n")
177177
}
178-
for _, id := range r.Verified() {
179-
od, _, err := f.GetFromDescrID(id)
180-
if err != nil {
181-
sylog.Errorf("failed to get descriptor: %v", err)
182-
return false
183-
}
184-
178+
for _, od := range r.Verified() {
185179
group := "NONE"
186-
if gid := od.Groupid; gid != sif.DescrUnusedGroup {
187-
group = fmt.Sprintf("%d", gid&^sif.DescrGroupMask)
180+
if gid := od.GroupID(); gid != 0 {
181+
group = fmt.Sprintf("%d", gid)
188182
}
189183

190184
link := "NONE"
191-
if l := od.Link; l != sif.DescrUnusedLink {
192-
if l&sif.DescrGroupMask == sif.DescrGroupMask {
193-
link = fmt.Sprintf("%d (G)", l&^sif.DescrGroupMask)
185+
if l, isGroup := od.LinkedID(); l != 0 {
186+
if isGroup {
187+
link = fmt.Sprintf("%d (G)", l)
194188
} else {
195189
link = fmt.Sprintf("%d", l)
196190
}
197191
}
198192

199-
fmt.Printf("%-4d|%-8s|%-8s|%s\n", id, group, link, od.Datatype)
193+
fmt.Printf("%-4d|%-8s|%-8s|%s\n", od.ID(), group, link, od.DataType())
200194
}
201195

202196
if err := r.Error(); err != nil {
@@ -246,15 +240,9 @@ func getJSONCallback(kl *keyList) singularity.VerifyCallback {
246240
}
247241

248242
// For each verified object, append an entry to the list.
249-
for _, id := range r.Verified() {
250-
od, _, err := f.GetFromDescrID(id)
251-
if err != nil {
252-
sylog.Errorf("failed to get descriptor: %v", err)
253-
continue
254-
}
255-
243+
for _, od := range r.Verified() {
256244
ke := keyEntity{
257-
Partition: od.Datatype.String(),
245+
Partition: od.DataType().String(),
258246
Name: name,
259247
Fingerprint: fp,
260248
KeyLocal: keyLocal,
@@ -266,14 +254,14 @@ func getJSONCallback(kl *keyList) singularity.VerifyCallback {
266254

267255
var integrityError *integrity.ObjectIntegrityError
268256
if errors.As(r.Error(), &integrityError) {
269-
od, _, err := f.GetFromDescrID(integrityError.ID)
257+
od, err := f.GetDescriptor(sif.WithID(integrityError.ID))
270258
if err != nil {
271259
sylog.Errorf("failed to get descriptor: %v", err)
272260
return false
273261
}
274262

275263
ke := keyEntity{
276-
Partition: od.Datatype.String(),
264+
Partition: od.DataType().String(),
277265
Name: name,
278266
Fingerprint: fp,
279267
KeyLocal: keyLocal,

cmd/internal/cli/siftool.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
// Copyright (c) 2019, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2019-2021, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE.md file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
55

66
package cli
77

88
import (
9-
"github.com/sylabs/sif/pkg/siftool"
9+
"github.com/spf13/cobra"
10+
"github.com/sylabs/sif/v2/pkg/siftool"
11+
"github.com/sylabs/singularity/docs"
1012
"github.com/sylabs/singularity/pkg/cmdline"
1113
)
1214

13-
// SiftoolCmd is easily set since the sif repo allows the cobra.Command struct to be
14-
// easily accessed with Siftool(), we do not need to do anything but call that function.
15-
var SiftoolCmd = siftool.Siftool()
16-
1715
func init() {
1816
addCmdInit(func(cmdManager *cmdline.CommandManager) {
19-
cmdManager.RegisterCmd(SiftoolCmd)
17+
cmd := &cobra.Command{
18+
Use: docs.SIFUse,
19+
Aliases: []string{docs.SIFAlias},
20+
Short: docs.SIFShort,
21+
Long: docs.SIFLong,
22+
Example: docs.SIFExample,
23+
DisableFlagsInUseLine: true,
24+
}
25+
siftool.AddCommands(cmd)
26+
27+
cmdManager.RegisterCmd(cmd)
2028
})
2129
}

docs/content.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2020, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2017-2021, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE.md file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
@@ -1062,3 +1062,19 @@ Enterprise Performance Computing (EPC)`
10621062
To create a single EXT3 writable overlay image:
10631063
$ singularity overlay create --size 1024 /tmp/my_overlay.img`
10641064
)
1065+
1066+
// Documentation for sif/siftool command.
1067+
const (
1068+
SIFUse string = `sif`
1069+
SIFAlias string = `siftool`
1070+
SIFShort string = `Manipulate Singularity Image Format (SIF) images`
1071+
SIFLong string = `
1072+
A set of commands are provided to display elements such as the SIF global
1073+
header, the data object descriptors and to dump data objects. It is also
1074+
possible to modify a SIF file via this tool via the add/del commands.`
1075+
SIFExample string = `
1076+
All sif commands have their own help output:
1077+
1078+
$ singularity help sif list
1079+
$ singularity sif list --help`
1080+
)

go.mod

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.13
55
require (
66
github.com/AdamKorcz/go-fuzz-headers v0.0.0-20210319161527-f761c2329661 // indirect
77
github.com/Netflix/go-expect v0.0.0-20190729225929-0e00d9168667
8+
github.com/ProtonMail/go-crypto v0.0.0-20210707164159-52430bf6b52c
89
github.com/adigunhammedolalekan/registry-auth v0.0.0-20200730122110-8cde180a3a60
910
github.com/alexflint/go-filemutex v0.0.0-20171028004239-d358565f3c3f // indirect
1011
github.com/apex/log v1.9.0
@@ -38,7 +39,6 @@ require (
3839
github.com/pelletier/go-toml v1.9.3
3940
github.com/pkg/errors v0.9.1
4041
github.com/russross/blackfriday/v2 v2.1.0 // indirect
41-
github.com/satori/go.uuid v1.2.1-0.20180404165556-75cca531ea76
4242
github.com/seccomp/containers-golang v0.6.0
4343
github.com/seccomp/libseccomp-golang v0.9.1
4444
github.com/spf13/cobra v1.2.1
@@ -47,15 +47,14 @@ require (
4747
github.com/sylabs/scs-build-client v0.2.1
4848
github.com/sylabs/scs-key-client v0.6.2
4949
github.com/sylabs/scs-library-client v1.0.5
50-
github.com/sylabs/sif v1.6.0
50+
github.com/sylabs/sif/v2 v2.0.0
5151
github.com/urfave/cli v1.22.5 // indirect
5252
github.com/vbauerster/mpb/v4 v4.12.2
5353
github.com/vbauerster/mpb/v6 v6.0.4
5454
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
5555
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect
5656
github.com/yvasiyarov/gorelic v0.0.6 // indirect
5757
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20160601141957-9c099fbc30e9 // indirect
58-
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
5958
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
6059
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55
6160
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
@@ -65,5 +64,3 @@ require (
6564
oras.land/oras-go v0.4.0
6665
rsc.io/letsencrypt v0.0.3 // indirect
6766
)
68-
69-
replace golang.org/x/crypto => github.com/sylabs/golang-x-crypto v0.0.0-20181006204705-4bce89e8e9a9

0 commit comments

Comments
 (0)