Skip to content

Commit d99cfa4

Browse files
authored
feat: abort when trying to run envd up on non-dev images (#1751)
* feat: abort when trying to run `envd up` on non-dev images Signed-off-by: Keming <[email protected]> * fix v0 dev condition Signed-off-by: Keming <[email protected]> --------- Signed-off-by: Keming <[email protected]>
1 parent e712892 commit d99cfa4

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

pkg/app/up.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ func up(clicontext *cli.Context) error {
195195
if err = buildutil.InterpretEnvdDef(builder); err != nil {
196196
return err
197197
}
198+
if !builder.GetGraph().IsDev() {
199+
return errors.New("`envd up` only works for dev images. If you're using v1, please enable dev with `base(dev=True)`.")
200+
}
198201
if err = buildutil.DetectEnvironment(clicontext, buildOpt); err != nil {
199202
return err
200203
}

pkg/builder/build.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ func (b generalBuilder) ShmSize() int {
125125
return b.graph.GetShmSize()
126126
}
127127

128+
func (b generalBuilder) IsDev() bool {
129+
return b.graph.IsDev()
130+
}
131+
128132
func (b generalBuilder) Build(ctx context.Context, force bool) error {
129133
if !force && !b.checkIfNeedBuild(ctx) {
130134
return nil

pkg/lang/ir/graph.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type graphVisitor interface {
4444
GPUEnabled() bool
4545
GetNumGPUs() int
4646
GetShmSize() int
47+
IsDev() bool
4748
Labels() (map[string]string, error)
4849
ExposedPorts() (map[string]struct{}, error)
4950
GetEntrypoint(buildContextDir string) ([]string, error)

pkg/lang/ir/v0/compile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func NewGraph() ir.Graph {
7474

7575
var DefaultGraph = NewGraph()
7676

77+
func (g generalGraph) IsDev() bool {
78+
return g.Image == nil
79+
}
80+
7781
func (g generalGraph) GetShmSize() int {
7882
return g.ShmSize
7983
}

pkg/lang/ir/v1/compile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ func (g *generalGraph) SetWriter(w compileui.Writer) {
7171
g.Writer = w
7272
}
7373

74+
func (g generalGraph) IsDev() bool {
75+
return g.Dev
76+
}
77+
7478
func (g generalGraph) GetHTTP() []ir.HTTPInfo {
7579
return g.HTTP
7680
}

0 commit comments

Comments
 (0)