Skip to content

Commit

Permalink
build(deps): use github.com/sylabs/sif/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Hughes committed Aug 13, 2021
1 parent e6988a2 commit 5e132fc
Show file tree
Hide file tree
Showing 20 changed files with 366 additions and 490 deletions.
4 changes: 2 additions & 2 deletions cmd/internal/cli/inspect.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2020, Sylabs Inc. All rights reserved.
// Copyright (c) 2018-2021, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand All @@ -20,7 +20,7 @@ import (
"strings"

"github.com/spf13/cobra"
"github.com/sylabs/sif/pkg/sif"
"github.com/sylabs/sif/v2/pkg/sif"
"github.com/sylabs/singularity/docs"
"github.com/sylabs/singularity/internal/pkg/util/env"
"github.com/sylabs/singularity/pkg/cmdline"
Expand Down
40 changes: 14 additions & 26 deletions cmd/internal/cli/pgp.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2020, Control Command Inc. All rights reserved.
// Copyright (c) 2020, Sylabs Inc. All rights reserved.
// Copyright (c) 2020-2021, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the LICENSE.md file
// distributed with the sources of this project regarding your rights to use or distribute this
// software.
Expand All @@ -17,8 +17,8 @@ import (
"github.com/sylabs/singularity/internal/pkg/buildcfg"

"github.com/fatih/color"
"github.com/sylabs/sif/pkg/integrity"
"github.com/sylabs/sif/pkg/sif"
"github.com/sylabs/sif/v2/pkg/integrity"
"github.com/sylabs/sif/v2/pkg/sif"
"github.com/sylabs/singularity/internal/app/singularity"
"github.com/sylabs/singularity/internal/pkg/util/interactive"
"github.com/sylabs/singularity/pkg/sylog"
Expand Down Expand Up @@ -175,28 +175,22 @@ func outputVerify(f *sif.FileImage, r integrity.VerifyResult) bool {
fmt.Printf("%-4s|%-8s|%-8s|%s\n", "ID", "GROUP", "LINK", "TYPE")
fmt.Print("------------------------------------------------\n")
}
for _, id := range r.Verified() {
od, _, err := f.GetFromDescrID(id)
if err != nil {
sylog.Errorf("failed to get descriptor: %v", err)
return false
}

for _, od := range r.Verified() {
group := "NONE"
if gid := od.Groupid; gid != sif.DescrUnusedGroup {
group = fmt.Sprintf("%d", gid&^sif.DescrGroupMask)
if gid := od.GroupID(); gid != 0 {
group = fmt.Sprintf("%d", gid)
}

link := "NONE"
if l := od.Link; l != sif.DescrUnusedLink {
if l&sif.DescrGroupMask == sif.DescrGroupMask {
link = fmt.Sprintf("%d (G)", l&^sif.DescrGroupMask)
if l, isGroup := od.LinkedID(); l != 0 {
if isGroup {
link = fmt.Sprintf("%d (G)", l)
} else {
link = fmt.Sprintf("%d", l)
}
}

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

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

// For each verified object, append an entry to the list.
for _, id := range r.Verified() {
od, _, err := f.GetFromDescrID(id)
if err != nil {
sylog.Errorf("failed to get descriptor: %v", err)
continue
}

for _, od := range r.Verified() {
ke := keyEntity{
Partition: od.Datatype.String(),
Partition: od.DataType().String(),
Name: name,
Fingerprint: fp,
KeyLocal: keyLocal,
Expand All @@ -266,14 +254,14 @@ func getJSONCallback(kl *keyList) singularity.VerifyCallback {

var integrityError *integrity.ObjectIntegrityError
if errors.As(r.Error(), &integrityError) {
od, _, err := f.GetFromDescrID(integrityError.ID)
od, err := f.GetDescriptor(sif.WithID(integrityError.ID))
if err != nil {
sylog.Errorf("failed to get descriptor: %v", err)
return false
}

ke := keyEntity{
Partition: od.Datatype.String(),
Partition: od.DataType().String(),
Name: name,
Fingerprint: fp,
KeyLocal: keyLocal,
Expand Down
22 changes: 15 additions & 7 deletions cmd/internal/cli/siftool.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
// Copyright (c) 2019, Sylabs Inc. All rights reserved.
// Copyright (c) 2019-2021, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.

package cli

import (
"github.com/sylabs/sif/pkg/siftool"
"github.com/spf13/cobra"
"github.com/sylabs/sif/v2/pkg/siftool"
"github.com/sylabs/singularity/docs"
"github.com/sylabs/singularity/pkg/cmdline"
)

// SiftoolCmd is easily set since the sif repo allows the cobra.Command struct to be
// easily accessed with Siftool(), we do not need to do anything but call that function.
var SiftoolCmd = siftool.Siftool()

func init() {
addCmdInit(func(cmdManager *cmdline.CommandManager) {
cmdManager.RegisterCmd(SiftoolCmd)
cmd := &cobra.Command{
Use: docs.SIFUse,
Aliases: []string{docs.SIFAlias},
Short: docs.SIFShort,
Long: docs.SIFLong,
Example: docs.SIFExample,
DisableFlagsInUseLine: true,
}
siftool.AddCommands(cmd)

cmdManager.RegisterCmd(cmd)
})
}
18 changes: 17 additions & 1 deletion docs/content.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2020, Sylabs Inc. All rights reserved.
// Copyright (c) 2017-2021, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -1062,3 +1062,19 @@ Enterprise Performance Computing (EPC)`
To create a single EXT3 writable overlay image:
$ singularity overlay create --size 1024 /tmp/my_overlay.img`
)

// Documentation for sif/siftool command.
const (
SIFUse string = `sif`
SIFAlias string = `siftool`
SIFShort string = `Manipulate Singularity Image Format (SIF) images`
SIFLong string = `
A set of commands are provided to display elements such as the SIF global
header, the data object descriptors and to dump data objects. It is also
possible to modify a SIF file via this tool via the add/del commands.`
SIFExample string = `
All sif commands have their own help output:
$ singularity help sif list
$ singularity sif list --help`
)
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ require (
github.com/pelletier/go-toml v1.9.3
github.com/pkg/errors v0.9.1
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/satori/go.uuid v1.2.1-0.20180404165556-75cca531ea76
github.com/seccomp/containers-golang v0.6.0
github.com/seccomp/libseccomp-golang v0.9.1
github.com/spf13/cobra v1.2.1
Expand All @@ -49,15 +48,15 @@ require (
github.com/sylabs/scs-build-client v0.1.6
github.com/sylabs/scs-key-client v0.6.2
github.com/sylabs/scs-library-client v1.0.5
github.com/sylabs/sif v1.5.1
github.com/sylabs/sif/v2 v2.0.0-beta.4
github.com/urfave/cli v1.22.5 // indirect
github.com/vbauerster/mpb/v4 v4.12.2
github.com/vbauerster/mpb/v6 v6.0.4
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 // indirect
github.com/yvasiyarov/gorelic v0.0.6 // indirect
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20160601141957-9c099fbc30e9 // indirect
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
gopkg.in/yaml.v2 v2.4.0
Expand Down
Loading

0 comments on commit 5e132fc

Please sign in to comment.