Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
GO15VENDOREXPERIMENT=1
export GO15VENDOREXPERIMENT

COMMIT=$(shell git rev-parse HEAD 2> /dev/null || true)

EPOCH_TEST_COMMIT ?= v0.2.0

default: help
Expand All @@ -19,9 +21,9 @@ check-license:
@./.tool/check-license

tools:
go build ./cmd/oci-create-runtime-bundle
go build ./cmd/oci-unpack
go build ./cmd/oci-image-validate
go build -ldflags "-X main.gitCommit=${COMMIT}" ./cmd/oci-create-runtime-bundle
go build -ldflags "-X main.gitCommit=${COMMIT}" ./cmd/oci-unpack
go build -ldflags "-X main.gitCommit=${COMMIT}" ./cmd/oci-image-validate

lint:
@echo "checking lint"
Expand Down
26 changes: 21 additions & 5 deletions cmd/oci-create-runtime-bundle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,28 @@ import (
"os"
"strings"

specs "github.com/opencontainers/image-spec/specs-go"
"github.com/opencontainers/image-tools/image"
"github.com/spf13/cobra"
)

// gitCommit will be the hash that the binary was built from
// and will be populated by the Makefile
var gitCommit = ""

// supported bundle types
var bundleTypes = []string{
image.TypeImageLayout,
image.TypeImage,
}

type bundleCmd struct {
stdout *log.Logger
stderr *log.Logger
typ string // the type to bundle, can be empty string
ref string
root string
stdout *log.Logger
stderr *log.Logger
typ string // the type to bundle, can be empty string
ref string
root string
version bool
}

func main() {
Expand Down Expand Up @@ -81,10 +87,20 @@ func newBundleCmd(stdout, stderr *log.Logger) *cobra.Command {
It is strongly recommended to keep the default value.`,
)

cmd.Flags().BoolVar(
&v.version, "version", false,
`Print version information and exit`,
)
return cmd
}

func (v *bundleCmd) Run(cmd *cobra.Command, args []string) {
if v.version {
v.stdout.Printf("commit: %s", gitCommit)
v.stdout.Printf("spec: %s", specs.Version)
os.Exit(0)

}
if len(args) != 2 {
v.stderr.Print("both src and dest must be provided")
if err := cmd.Usage(); err != nil {
Expand Down
25 changes: 21 additions & 4 deletions cmd/oci-image-validate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ import (
"strings"

"github.com/opencontainers/image-spec/schema"
specs "github.com/opencontainers/image-spec/specs-go"
"github.com/opencontainers/image-tools/image"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)

// gitCommit will be the hash that the binary was built from
// and will be populated by the Makefile
var gitCommit = ""

// supported validation types
var validateTypes = []string{
image.TypeImageLayout,
Expand All @@ -36,10 +41,11 @@ var validateTypes = []string{
}

type validateCmd struct {
stdout *log.Logger
stderr *log.Logger
typ string // the type to validate, can be empty string
refs []string
stdout *log.Logger
stderr *log.Logger
typ string // the type to validate, can be empty string
refs []string
version bool
}

func main() {
Expand Down Expand Up @@ -78,10 +84,21 @@ func newValidateCmd(stdout, stderr *log.Logger) *cobra.Command {
`A set of refs pointing to the manifests to be validated. Each reference must be present in the "refs" subdirectory of the image. Only applicable if type is image or imageLayout.`,
)

cmd.Flags().BoolVar(
&v.version, "version", false,
`Print version information and exit`,
)

return cmd
}

func (v *validateCmd) Run(cmd *cobra.Command, args []string) {
if v.version {
v.stdout.Printf("commit: %s", gitCommit)
v.stdout.Printf("spec: %s", specs.Version)
os.Exit(0)
}

if len(args) < 1 {
v.stderr.Printf("no files specified")
if err := cmd.Usage(); err != nil {
Expand Down
25 changes: 20 additions & 5 deletions cmd/oci-unpack/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,27 @@ import (
"os"
"strings"

specs "github.com/opencontainers/image-spec/specs-go"
"github.com/opencontainers/image-tools/image"
"github.com/spf13/cobra"
)

// gitCommit will be the hash that the binary was built from
// and will be populated by the Makefile
var gitCommit = ""

// supported unpack types
var unpackTypes = []string{
image.TypeImageLayout,
image.TypeImage,
}

type unpackCmd struct {
stdout *log.Logger
stderr *log.Logger
typ string // the type to unpack, can be empty string
ref string
stdout *log.Logger
stderr *log.Logger
typ string // the type to unpack, can be empty string
ref string
version bool
}

func main() {
Expand Down Expand Up @@ -73,11 +79,20 @@ func newUnpackCmd(stdout, stderr *log.Logger) *cobra.Command {
&v.ref, "ref", "v1.0",
`The ref pointing to the manifest to be unpacked. This must be present in the "refs" subdirectory of the image.`,
)

cmd.Flags().BoolVar(
&v.version, "version", false,
`Print version information and exit`,
)
return cmd
}

func (v *unpackCmd) Run(cmd *cobra.Command, args []string) {
if v.version {
v.stdout.Printf("commit: %s", gitCommit)
v.stdout.Printf("spec: %s", specs.Version)
os.Exit(0)
}

if len(args) != 2 {
v.stderr.Print("both src and dest must be provided")
if err := cmd.Usage(); err != nil {
Expand Down