Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #514 #519

Merged
merged 2 commits into from
Feb 26, 2021
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
3 changes: 2 additions & 1 deletion pkg/jsonnet/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ type Opts struct {

// Clone returns a deep copy of Opts
func (o Opts) Clone() Opts {
var extCode, tlaCode InjectedCode
extCode, tlaCode := InjectedCode{}, InjectedCode{}

for k, v := range o.ExtCode {
extCode[k] = v
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/tanka/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

// FindOpts are optional arguments for FindEnvs
type FindOpts struct {
JsonnetOpts
Selector labels.Selector
}

Expand All @@ -20,7 +21,7 @@ type FindOpts struct {
// are not checked.
func FindEnvs(path string, opts FindOpts) ([]*v1alpha1.Environment, error) {
// find all environments at dir
envs, err := find(path)
envs, err := find(path, Opts{JsonnetOpts: opts.JsonnetOpts})
if err != nil {
return nil, err
}
Expand All @@ -42,9 +43,9 @@ func FindEnvs(path string, opts FindOpts) ([]*v1alpha1.Environment, error) {
}

// find implements the actual functionality described at 'FindEnvs'
func find(path string) ([]*v1alpha1.Environment, error) {
func find(path string, opts Opts) ([]*v1alpha1.Environment, error) {
// try if this has envs
list, err := List(path, Opts{})
list, err := List(path, opts)
if len(list) != 0 && err == nil {
// it has. don't search deeper
return list, nil
Expand Down Expand Up @@ -77,7 +78,7 @@ func find(path string) ([]*v1alpha1.Environment, error) {
}

routines++
go findShim(filepath.Join(path, fi.Name()), ch)
go findShim(filepath.Join(path, fi.Name()), opts, ch)
}

// collect parallel results
Expand Down Expand Up @@ -105,7 +106,7 @@ type findOut struct {
err error
}

func findShim(dir string, ch chan findOut) {
envs, err := find(dir)
func findShim(dir string, opts Opts, ch chan findOut) {
envs, err := find(dir, opts)
ch <- findOut{envs: envs, err: err}
}
2 changes: 1 addition & 1 deletion pkg/tanka/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func parallelLoadEnvironments(paths []string, opts parallelOpts) ([]*v1alpha1.En
jobsCh := make(chan parallelJob)
list := make(map[string]string)
for _, path := range paths {
envs, err := FindEnvs(path, FindOpts{opts.Selector})
envs, err := FindEnvs(path, FindOpts{Selector: opts.Selector, JsonnetOpts: opts.JsonnetOpts})
if err != nil {
return nil, err
}
Expand Down