Skip to content

Commit 2471940

Browse files
committed
refactor: don't allow runtime variables in pipelines
1 parent ac99f33 commit 2471940

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

pkg/devspace/pipeline/engine/pipelinehandler/commands/get_image.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
)
1212

1313
type GetImageOptions struct {
14-
Only string `long:"only" description:"Displays either only the tag or only the image"`
14+
Dependency string `long:"dependency" description:"Retrieves the image from the named dependency"`
15+
Only string `long:"only" description:"Displays either only the tag or only the image"`
1516
}
1617

1718
func GetImage(ctx *devspacecontext.Context, args []string) error {
@@ -22,7 +23,7 @@ func GetImage(ctx *devspacecontext.Context, args []string) error {
2223
return errors.Wrap(err, "parse args")
2324
}
2425
if len(args) != 1 {
25-
return fmt.Errorf("usage: get_image [image_name] [--only=image|tag]")
26+
return fmt.Errorf("usage: get_image [--only=image|tag] [--dependency=DEPENDENCY] [image_name]")
2627
}
2728

2829
var (
@@ -36,7 +37,21 @@ func GetImage(ctx *devspacecontext.Context, args []string) error {
3637
case "tag":
3738
onlyTag = true
3839
default:
39-
return fmt.Errorf("usage: get_image [image_name] [--only=image|tag]")
40+
return fmt.Errorf("usage: get_image [--only=image|tag] [--dependency=DEPENDENCY] [image_name]")
41+
}
42+
43+
if options.Dependency != "" {
44+
found := false
45+
for _, dep := range ctx.Dependencies {
46+
if dep.Name() == options.Dependency {
47+
ctx = ctx.AsDependency(dep)
48+
found = true
49+
break
50+
}
51+
}
52+
if !found {
53+
return fmt.Errorf("couldn't find dependency %v", options.Dependency)
54+
}
4055
}
4156

4257
_, imageCache, err := runtime.GetImage(ctx.Config, args[0], onlyImage, onlyTag)

pkg/devspace/pipeline/env/env.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ type envProvider struct {
3434
}
3535

3636
func (e *envProvider) Get(name string) expand.Variable {
37-
v, ok := e.getRuntimeVariable(name)
38-
if ok {
39-
return v
40-
}
37+
// Should we enable this?
38+
// v, ok := e.getRuntimeVariable(name)
39+
// if ok {
40+
// return v
41+
// }
4142

42-
v, ok = e.getVariable(name)
43+
v, ok := e.getVariable(name)
4344
if ok {
4445
return v
4546
}
@@ -80,12 +81,13 @@ func (e *envProvider) getRuntimeVariable(name string) (expand.Variable, bool) {
8081
}
8182

8283
func (e *envProvider) Each(visitor func(name string, vr expand.Variable) bool) {
83-
for name := range e.config.ListRuntimeVariables() {
84-
v, ok := e.getRuntimeVariable(name)
85-
if ok {
86-
visitor(name, v)
87-
}
88-
}
84+
// Should we enable this?
85+
// for name := range e.config.ListRuntimeVariables() {
86+
// v, ok := e.getRuntimeVariable(name)
87+
// if ok {
88+
// visitor(name, v)
89+
// }
90+
// }
8991

9092
for name := range e.config.Variables() {
9193
v, ok := e.getVariable(name)

0 commit comments

Comments
 (0)