Skip to content

Commit

Permalink
Merge pull request #289 from EmmEff/fix-command-line-example
Browse files Browse the repository at this point in the history
Fix command-line example
  • Loading branch information
tri-adam authored May 3, 2023
2 parents 6ef1266 + 5933700 commit 13b9a24
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
26 changes: 13 additions & 13 deletions pkg/siftool/add.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2022, Sylabs Inc. All rights reserved.
// Copyright (c) 2019-2023, Sylabs Inc. All rights reserved.
// Copyright (c) 2017, SingularityWare, LLC. All rights reserved.
// Copyright (c) 2017, Yannick Cote <yhcote@gmail.com> All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
Expand Down Expand Up @@ -38,11 +38,11 @@ var (
func getAddExamples(rootPath string) string {
examples := []string{
rootPath +
" add image.sif recipe.def -datatype 1",
" add image.sif recipe.def --datatype 1",
rootPath +
" add image.sif rootfs.squashfs --datatype 4 --parttype 1 --partfs 1 ----partarch 2",
" add image.sif rootfs.squashfs --datatype 4 --parttype 1 --partfs 1 --partarch 2",
rootPath +
" add image.sif signature.bin -datatype 5 --signentity 433FE984155206BD962725E20E8713472A879943 --signhash 1",
" add image.sif signature.bin --datatype 5 --signentity 433FE984155206BD962725E20E8713472A879943 --signhash 1",
}
return strings.Join(examples, "\n")
}
Expand All @@ -54,34 +54,34 @@ func addFlags(fs *pflag.FlagSet) {
1-Deffile, 2-EnvVar, 3-Labels,
4-Partition, 5-Signature, 6-GenericJSON,
7-Generic, 8-CryptoMessage, 9-SBOM`)
partType = fs.Int32("parttype", 0, `the type of partition (with -datatype 4-Partition)
partType = fs.Int32("parttype", 0, `the type of partition (with --datatype 4-Partition)
[NEEDED, no default]:
1-System, 2-PrimSys, 3-Data,
4-Overlay`)
partFS = fs.Int32("partfs", 0, `the filesystem used (with -datatype 4-Partition)
partFS = fs.Int32("partfs", 0, `the filesystem used (with --datatype 4-Partition)
[NEEDED, no default]:
1-Squash, 2-Ext3, 3-ImmuObj,
4-Raw`)
partArch = fs.Int32("partarch", 0, `the main architecture used (with -datatype 4-Partition)
partArch = fs.Int32("partarch", 0, `the main architecture used (with --datatype 4-Partition)
[NEEDED, no default]:
1-386, 2-amd64, 3-arm,
4-arm64, 5-ppc64, 6-ppc64le,
7-mips, 8-mipsle, 9-mips64,
10-mips64le, 11-s390x, 12-riscv64`)
signHash = fs.Int32("signhash", 0, `the signature hash used (with -datatype 5-Signature)
signHash = fs.Int32("signhash", 0, `the signature hash used (with --datatype 5-Signature)
[NEEDED, no default]:
1-SHA256, 2-SHA384, 3-SHA512,
4-BLAKE2s_256, 5-BLAKE2b_256`)
signEntity = fs.String("signentity", "", `the entity that signs (with -datatype 5-Signature)
signEntity = fs.String("signentity", "", `the entity that signs (with --datatype 5-Signature)
[NEEDED, no default]:
example: 433FE984155206BD962725E20E8713472A879943`)
sbomFormat = fs.String("sbomformat", "", `the SBOM format (with -datatype 9-sbom):
sbomFormat = fs.String("sbomformat", "", `the SBOM format (with --datatype 9-sbom):
cyclonedx-json, cyclonedx-xml, github-json,
spdx-json, spdx-rdf, spdx-tag-value,
spdx-yaml, syft-json`)
groupID = fs.Uint32("groupid", 0, "set groupid [default: 0]")
linkID = fs.Uint32("link", 0, "set link pointer [default: 0]")
alignment = fs.Int("alignment", 0, "set alignment [default: 4096 with -datatype 4-Partition, 0 otherwise]")
alignment = fs.Int("alignment", 0, "set alignment [default: 4096 with --datatype 4-Partition, 0 otherwise]")
name = fs.String("filename", "", "set logical filename/handle [default: input filename]")
}

Expand Down Expand Up @@ -189,9 +189,9 @@ func getSBOMFormat() (sif.SBOMFormat, error) {
}

var (
errPartitionArgs = errors.New("with partition datatype, -partfs, -parttype and -partarch must be passed")
errPartitionArgs = errors.New("with partition datatype, --partfs, --parttype and --partarch must be passed")
errInvalidFingerprintLength = errors.New("invalid signing entity fingerprint length")
errSBOMArgs = errors.New("with SBOM datatype, -sbomformat must be passed")
errSBOMArgs = errors.New("with SBOM datatype, --sbomformat must be passed")
)

func getOptions(dt sif.DataType, fs *pflag.FlagSet) ([]sif.DescriptorInputOpt, error) {
Expand Down
20 changes: 10 additions & 10 deletions pkg/siftool/testdata/TestAddCommands/Add/out.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Usage:
siftool add <sif_path> <object_path> [flags]

Examples:
siftool add image.sif recipe.def -datatype 1
siftool add image.sif rootfs.squashfs --datatype 4 --parttype 1 --partfs 1 ----partarch 2
siftool add image.sif signature.bin -datatype 5 --signentity 433FE984155206BD962725E20E8713472A879943 --signhash 1
siftool add image.sif recipe.def --datatype 1
siftool add image.sif rootfs.squashfs --datatype 4 --parttype 1 --partfs 1 --partarch 2
siftool add image.sif signature.bin --datatype 5 --signentity 433FE984155206BD962725E20E8713472A879943 --signhash 1

Flags:
--alignment int set alignment [default: 4096 with -datatype 4-Partition, 0 otherwise]
--alignment int set alignment [default: 4096 with --datatype 4-Partition, 0 otherwise]
--datatype int the type of data to add
[NEEDED, no default]:
1-Deffile, 2-EnvVar, 3-Labels,
Expand All @@ -19,28 +19,28 @@ Flags:
--groupid uint32 set groupid [default: 0]
-h, --help help for add
--link uint32 set link pointer [default: 0]
--partarch int32 the main architecture used (with -datatype 4-Partition)
--partarch int32 the main architecture used (with --datatype 4-Partition)
[NEEDED, no default]:
1-386, 2-amd64, 3-arm,
4-arm64, 5-ppc64, 6-ppc64le,
7-mips, 8-mipsle, 9-mips64,
10-mips64le, 11-s390x, 12-riscv64
--partfs int32 the filesystem used (with -datatype 4-Partition)
--partfs int32 the filesystem used (with --datatype 4-Partition)
[NEEDED, no default]:
1-Squash, 2-Ext3, 3-ImmuObj,
4-Raw
--parttype int32 the type of partition (with -datatype 4-Partition)
--parttype int32 the type of partition (with --datatype 4-Partition)
[NEEDED, no default]:
1-System, 2-PrimSys, 3-Data,
4-Overlay
--sbomformat string the SBOM format (with -datatype 9-sbom):
--sbomformat string the SBOM format (with --datatype 9-sbom):
cyclonedx-json, cyclonedx-xml, github-json,
spdx-json, spdx-rdf, spdx-tag-value,
spdx-yaml, syft-json
--signentity string the entity that signs (with -datatype 5-Signature)
--signentity string the entity that signs (with --datatype 5-Signature)
[NEEDED, no default]:
example: 433FE984155206BD962725E20E8713472A879943
--signhash int32 the signature hash used (with -datatype 5-Signature)
--signhash int32 the signature hash used (with --datatype 5-Signature)
[NEEDED, no default]:
1-SHA256, 2-SHA384, 3-SHA512,
4-BLAKE2s_256, 5-BLAKE2b_256

0 comments on commit 13b9a24

Please sign in to comment.