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
5 changes: 3 additions & 2 deletions pkg/cli/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func cmdSVG() *cobra.Command {
var dir string
var dir, pipelineDir string
var showDependents bool
d := &cobra.Command{
Use: "dot",
Expand All @@ -27,7 +27,7 @@ Generate .dot output and pipe it to dot to generate a PNG
wolfictl dot | dot -Tpng > graph.png
`,
RunE: func(cmd *cobra.Command, args []string) error {
pkgs, err := dag.NewPackages(os.DirFS(dir), dir)
pkgs, err := dag.NewPackages(os.DirFS(dir), dir, pipelineDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -72,6 +72,7 @@ Generate .dot output and pipe it to dot to generate a PNG
},
}
d.Flags().StringVarP(&dir, "dir", "d", ".", "directory to search for melange configs")
d.Flags().StringVar(&pipelineDir, "pipeline-dir", "", "directory used to extend defined built-in pipelines")
d.Flags().BoolVarP(&showDependents, "show-dependents", "D", false, "show packages that depend on these packages, instead of these packages' dependencies")
return d
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/cli/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
)

func cmdMake() *cobra.Command {
var dir, arch string
var dir, pipelineDir, arch string
var dryrun bool
text := &cobra.Command{
Use: "make",
Short: "Run make for all targets in order",
RunE: func(cmd *cobra.Command, args []string) error {
arch := types.ParseArchitecture(arch).ToAPK()

pkgs, err := dag.NewPackages(os.DirFS(dir), dir)
pkgs, err := dag.NewPackages(os.DirFS(dir), dir, pipelineDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -59,6 +59,7 @@ func cmdMake() *cobra.Command {
},
}
text.Flags().StringVarP(&dir, "dir", "d", ".", "directory to search for melange configs")
text.Flags().StringVar(&pipelineDir, "pipeline-dir", "", "directory used to extend defined built-in pipelines")
text.Flags().StringVarP(&arch, "arch", "a", "x86_64", "architecture to build for")
text.Flags().BoolVar(&dryrun, "dryrun", false, "if true, only print `make` commands")
return text
Expand Down
5 changes: 3 additions & 2 deletions pkg/cli/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func gcloudProjectID(ctx context.Context) (string, error) {
}

func cmdPod() *cobra.Command {
var dir, arch, project, bundleRepo, ns, cpu, ram, sa, sdkimg, gcloudImage, cachedig, bucket, srcBucket, publicKeyBucket, signingKeyName, melangeBuildOpts string
var dir, pipelineDir, arch, project, bundleRepo, ns, cpu, ram, sa, sdkimg, gcloudImage, cachedig, bucket, srcBucket, publicKeyBucket, signingKeyName, melangeBuildOpts string

var create, watch, secretKey bool
var pendingTimeout time.Duration
Expand Down Expand Up @@ -74,7 +74,7 @@ func cmdPod() *cobra.Command {

targets := []string{"all"}
if len(args) > 0 {
pkgs, err := dag.NewPackages(os.DirFS(dir), dir)
pkgs, err := dag.NewPackages(os.DirFS(dir), dir, pipelineDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -355,6 +355,7 @@ gcloud --quiet storage cp \
},
}
pod.Flags().StringVarP(&dir, "dir", "d", ".", "directory to search for melange configs")
pod.Flags().StringVar(&pipelineDir, "pipeline-dir", "", "directory used to extend defined built-in pipelines")
pod.Flags().StringVarP(&arch, "arch", "a", "x86_64", "architecture to build for")
pod.Flags().StringVar(&bundleRepo, "bundle-repo", "", "OCI repository to push the bundle to; if unset, gcr.io/$PROJECT/dag")
pod.Flags().StringVar(&project, "project", "", "GCP project; if unset, detects project configured by gcloud")
Expand Down
5 changes: 3 additions & 2 deletions pkg/cli/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (
)

func cmdText() *cobra.Command {
var dir, arch, t string
var dir, pipelineDir, arch, t string
var showDependents bool
text := &cobra.Command{
Use: "text",
Short: "Print a sorted list of downstream dependent packages",
RunE: func(cmd *cobra.Command, args []string) error {
arch := types.ParseArchitecture(arch).ToAPK()

pkgs, err := dag.NewPackages(os.DirFS(dir), dir)
pkgs, err := dag.NewPackages(os.DirFS(dir), dir, pipelineDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -66,6 +66,7 @@ func cmdText() *cobra.Command {
},
}
text.Flags().StringVarP(&dir, "dir", "d", ".", "directory to search for melange configs")
text.Flags().StringVar(&pipelineDir, "pipeline-dir", "", "directory used to extend defined built-in pipelines")
text.Flags().StringVarP(&arch, "arch", "a", "x86_64", "architecture to build for")
text.Flags().BoolVarP(&showDependents, "show-dependents", "D", false, "show packages that depend on these packages, instead of these packages' dependencies")
text.Flags().StringVarP(&t, "type", "t", string(typeTarget), fmt.Sprintf("What type of text to emit; values can be one of: %v", textTypes))
Expand Down
14 changes: 7 additions & 7 deletions pkg/dag/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestNewGraph(t *testing.T) {
testDir = "testdata/basic"
)
t.Run("allowed dangling", func(t *testing.T) {
pkgs, err := NewPackages(os.DirFS(testDir), testDir)
pkgs, err := NewPackages(os.DirFS(testDir), testDir, "")
require.NoError(t, err)
graph, err := NewGraph(pkgs, WithAllowUnresolved())
require.NoError(t, err)
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestNewGraph(t *testing.T) {
}
})
t.Run("has expected tree", func(t *testing.T) {
pkgs, err := NewPackages(os.DirFS(testDir), testDir)
pkgs, err := NewPackages(os.DirFS(testDir), testDir, "")
require.NoError(t, err)
graph, err := NewGraph(pkgs, WithRepos(packageRepo), WithKeys(key))
require.NoError(t, err)
Expand Down Expand Up @@ -89,13 +89,13 @@ func TestNewGraph(t *testing.T) {
t.Run("complex", func(t *testing.T) {
var testDir = "testdata/complex"
t.Run("allowed dangling", func(t *testing.T) {
pkgs, err := NewPackages(os.DirFS(testDir), testDir)
pkgs, err := NewPackages(os.DirFS(testDir), testDir, "")
require.NoError(t, err)
_, err = NewGraph(pkgs, WithAllowUnresolved())
require.NoError(t, err)
})
t.Run("external dependencies only", func(t *testing.T) {
pkgs, err := NewPackages(os.DirFS(testDir), testDir)
pkgs, err := NewPackages(os.DirFS(testDir), testDir, "")
require.NoError(t, err)
graph, err := NewGraph(pkgs, WithRepos(packageRepo), WithKeys(key))
require.NoError(t, err)
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestNewGraph(t *testing.T) {
}
})
t.Run("internal and external dependencies", func(t *testing.T) {
pkgs, err := NewPackages(os.DirFS(testDir), testDir)
pkgs, err := NewPackages(os.DirFS(testDir), testDir, "")
require.NoError(t, err)
graph, err := NewGraph(pkgs, WithRepos(packageRepo), WithKeys(key))
require.NoError(t, err)
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestNewGraph(t *testing.T) {
})

t.Run("internal dependencies numbered", func(t *testing.T) {
pkgs, err := NewPackages(os.DirFS(testDir), testDir)
pkgs, err := NewPackages(os.DirFS(testDir), testDir, "")
require.NoError(t, err)
graph, err := NewGraph(pkgs, WithRepos(packageRepo), WithKeys(key))
require.NoError(t, err)
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestNewGraph(t *testing.T) {
"d": {"a:1.3.5-r1@local"},
}
)
pkgs, err := NewPackages(os.DirFS(testDir), testDir)
pkgs, err := NewPackages(os.DirFS(testDir), testDir, "")
require.NoError(t, err)
graph, err := NewGraph(pkgs, WithRepos(cyclePackageRepo), WithKeys(cycleKey))
require.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion pkg/dag/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (p *Packages) addProvides(c *Configuration, provides []string) error {
//
// The repetition of the path is necessary because of how the upstream parser in melange
// requires the full path to the directory to be passed in.
func NewPackages(fsys fs.FS, dirPath string) (*Packages, error) {
func NewPackages(fsys fs.FS, dirPath, pipelineDir string) (*Packages, error) {
pkgs := &Packages{
configs: make(map[string][]*Configuration),
packages: make(map[string][]*Configuration),
Expand Down Expand Up @@ -195,6 +195,7 @@ func NewPackages(fsys fs.FS, dirPath string) (*Packages, error) {
// .environment.contents.packages so the next block can include those as build deps.
pctx := &build.PipelineContext{
Context: &build.Context{
PipelineDir: pipelineDir,
Configuration: *c.Configuration,
},
Package: &c.Package,
Expand Down
2 changes: 1 addition & 1 deletion pkg/dag/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestNewPackages(t *testing.T) {
// for now, just a simple test that the loaded info is correct
testdir := "testdata/complex"
pkgs, err := NewPackages(os.DirFS(testdir), testdir)
pkgs, err := NewPackages(os.DirFS(testdir), testdir, "")
require.NoError(t, err)

// should have named packages that match what is in the files and *not* the filenames
Expand Down