-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- moves top-level tests into integration directory
- Loading branch information
Showing
57 changed files
with
5,387 additions
and
85 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
* @paketo-buildpacks/tooling-maintainers | ||
|
||
/internal/ihop @paketo-buildpacks/stacks-maintainers | ||
/commands/create_stack.go @paketo-buildpacks/stacks-maintainers | ||
/integration/create_stack_test.go @paketo-buildpacks/stacks-maintainers | ||
/integration/testdata/example-stack @paketo-buildpacks/stacks-maintainers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"runtime" | ||
"time" | ||
|
||
"github.com/paketo-buildpacks/jam/internal/ihop" | ||
"github.com/paketo-buildpacks/packit/v2/scribe" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(createStack()) | ||
} | ||
|
||
type createStackFlags struct { | ||
config string | ||
buildOutput string | ||
runOutput string | ||
secrets []string | ||
} | ||
|
||
func createStack() *cobra.Command { | ||
flags := &createStackFlags{} | ||
cmd := &cobra.Command{ | ||
Use: "create-stack", | ||
Short: "create-stack", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return createStackRun(*flags) | ||
}, | ||
} | ||
cmd.Flags().StringVar(&flags.config, "config", "", "path to a stack descriptor file (required)") | ||
cmd.Flags().StringVar(&flags.buildOutput, "build-output", "", "path to output the build image OCI archive (required)") | ||
cmd.Flags().StringVar(&flags.runOutput, "run-output", "", "path to output the run image OCI archive (required)") | ||
cmd.Flags().StringSliceVar(&flags.secrets, "secret", nil, "secret to be passed to your Dockerfile") | ||
|
||
err := cmd.MarkFlagRequired("config") | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Unable to mark config flag as required") | ||
} | ||
|
||
err = cmd.MarkFlagRequired("build-output") | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Unable to mark build-output flag as required") | ||
} | ||
|
||
err = cmd.MarkFlagRequired("run-output") | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Unable to mark run-output flag as required") | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
func createStackRun(flags createStackFlags) error { | ||
definition, err := ihop.NewDefinitionFromFile(flags.config, flags.secrets...) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, definition.IncludeExperimentalSBOM = os.LookupEnv("EXPERIMENTAL_ATTACH_RUN_IMAGE_SBOM") | ||
|
||
scratch, err := os.MkdirTemp("", "") | ||
if err != nil { | ||
return err | ||
} | ||
defer os.RemoveAll(scratch) | ||
|
||
client, err := ihop.NewClient(scratch) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
builder := ihop.NewBuilder(client, ihop.Cataloger{}, runtime.NumCPU()) | ||
logger := scribe.NewLogger(os.Stdout) | ||
creator := ihop.NewCreator(client, builder, ihop.UserLayerCreator{}, ihop.SBOMLayerCreator{}, time.Now, logger) | ||
|
||
stack, err := creator.Execute(definition) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
logger.Process("Exporting build image to %s", flags.buildOutput) | ||
err = client.Export(flags.buildOutput, stack.Build...) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
logger.Process("Exporting run image to %s", flags.runOutput) | ||
err = client.Export(flags.runOutput, stack.Run...) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
logger.Process("Cleaning up intermediate image artifacts") | ||
err = client.Cleanup(stack.Build...) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = client.Cleanup(stack.Run...) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,127 @@ | ||
module github.com/paketo-buildpacks/jam | ||
|
||
go 1.16 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/BurntSushi/toml v1.1.0 | ||
github.com/Masterminds/semver/v3 v3.1.1 | ||
github.com/anchore/syft v0.44.1 | ||
github.com/buildpacks/pack v0.26.0 | ||
github.com/docker/cli v20.10.14+incompatible | ||
github.com/docker/distribution v2.8.1+incompatible | ||
github.com/docker/docker v20.10.14+incompatible | ||
github.com/google/go-containerregistry v0.8.1-0.20220209165246-a44adc326839 | ||
github.com/moby/buildkit v0.9.3 | ||
github.com/onsi/gomega v1.19.0 | ||
github.com/paketo-buildpacks/packit/v2 v2.3.0 | ||
github.com/pelletier/go-toml v1.9.5 | ||
github.com/sclevine/spec v1.4.0 | ||
github.com/spf13/cobra v1.4.0 | ||
) | ||
|
||
require ( | ||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect | ||
github.com/CycloneDX/cyclonedx-go v0.5.0 // indirect | ||
github.com/Microsoft/go-winio v0.5.2 // indirect | ||
github.com/Microsoft/hcsshim v0.9.2 // indirect | ||
github.com/acobaugh/osrelease v0.1.0 // indirect | ||
github.com/anchore/go-macholibre v0.0.0-20220308212642-53e6d0aaf6fb // indirect | ||
github.com/anchore/go-rpmdb v0.0.0-20210914181456-a9c52348da63 // indirect | ||
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b // indirect | ||
github.com/anchore/packageurl-go v0.1.1-0.20220314153042-1bcd40e5206b // indirect | ||
github.com/anchore/stereoscope v0.0.0-20220406160859-c03a18a6b270 // indirect | ||
github.com/andybalholm/brotli v1.0.4 // indirect | ||
github.com/apex/log v1.9.0 // indirect | ||
github.com/bmatcuk/doublestar/v4 v4.0.2 // indirect | ||
github.com/buildpacks/imgutil v0.0.0-20220425182719-2edb52457eb0 // indirect | ||
github.com/buildpacks/lifecycle v0.14.0 // indirect | ||
github.com/containerd/cgroups v1.0.3 // indirect | ||
github.com/containerd/console v1.0.3 // indirect | ||
github.com/containerd/containerd v1.6.3 // indirect | ||
github.com/containerd/continuity v0.2.2 // indirect | ||
github.com/containerd/stargz-snapshotter/estargz v0.11.4 // indirect | ||
github.com/containerd/typeurl v1.0.2 // indirect | ||
github.com/docker/docker-credential-helpers v0.6.4 // indirect | ||
github.com/docker/go-connections v0.4.0 // indirect | ||
github.com/docker/go-units v0.4.0 // indirect | ||
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect | ||
github.com/dustin/go-humanize v1.0.0 // indirect | ||
github.com/facebookincubator/nvdtools v0.1.4 // indirect | ||
github.com/gabriel-vasile/mimetype v1.4.0 // indirect | ||
github.com/go-logr/logr v1.2.2 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/go-restruct/restruct v1.2.0-alpha // indirect | ||
github.com/gofrs/flock v0.8.1 // indirect | ||
github.com/gogo/googleapis v1.4.0 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/google/go-cmp v0.5.8 // indirect | ||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect | ||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect | ||
github.com/hashicorp/errwrap v1.1.0 // indirect | ||
github.com/hashicorp/go-multierror v1.1.1 // indirect | ||
github.com/heroku/color v0.0.6 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.0 // indirect | ||
github.com/jinzhu/copier v0.3.2 // indirect | ||
github.com/klauspost/compress v1.15.2 // indirect | ||
github.com/klauspost/pgzip v1.2.5 // indirect | ||
github.com/mattn/go-colorable v0.1.12 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
github.com/mattn/go-runewidth v0.0.13 // indirect | ||
github.com/mholt/archiver/v3 v3.5.1 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 // indirect | ||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect | ||
github.com/mitchellh/ioprogress v0.0.0-20180201004757-6a23b12fa88e // indirect | ||
github.com/mitchellh/mapstructure v1.4.3 // indirect | ||
github.com/moby/sys/mount v0.3.2 // indirect | ||
github.com/moby/sys/mountinfo v0.6.1 // indirect | ||
github.com/moby/sys/symlink v0.2.0 // indirect | ||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect | ||
github.com/morikuni/aec v1.0.0 // indirect | ||
github.com/nwaples/rardecode v1.1.0 // indirect | ||
github.com/olekukonko/tablewriter v0.0.5 // indirect | ||
github.com/opencontainers/go-digest v1.0.0 // indirect | ||
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect | ||
github.com/opencontainers/runc v1.1.1 // indirect | ||
github.com/pierrec/lz4/v4 v4.1.2 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
github.com/scylladb/go-set v1.0.3-0.20200225121959-cc7b2070d91e // indirect | ||
github.com/sirupsen/logrus v1.8.1 // indirect | ||
github.com/spdx/tools-golang v0.2.0 // indirect | ||
github.com/spf13/afero v1.8.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/tonistiigi/fsutil v0.0.0-20210609172227-d72af97c0eaf // indirect | ||
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea // indirect | ||
github.com/tonistiigi/vt100 v0.0.0-20210615222946-8066bb97264f // indirect | ||
github.com/ulikunitz/xz v0.5.10 // indirect | ||
github.com/vbatts/tar-split v0.11.2 // indirect | ||
github.com/vifraa/gopom v0.1.0 // indirect | ||
github.com/wagoodman/go-partybus v0.0.0-20210627031916-db1f5573bbc5 // indirect | ||
github.com/wagoodman/go-progress v0.0.0-20200731105512-1020f39e6240 // indirect | ||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect | ||
go.opencensus.io v0.23.0 // indirect | ||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0 // indirect | ||
go.opentelemetry.io/otel v1.3.0 // indirect | ||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0 // indirect | ||
go.opentelemetry.io/otel/sdk v1.3.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.3.0 // indirect | ||
go.opentelemetry.io/proto/otlp v0.12.0 // indirect | ||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect | ||
golang.org/x/mod v0.5.1 // indirect | ||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect | ||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect | ||
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect | ||
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect | ||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | ||
google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731 // indirect | ||
google.golang.org/grpc v1.46.0 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
) |
Oops, something went wrong.