Skip to content

Commit 3d097e5

Browse files
authored
Improve app.yaml descriptor sanity checks
1 parent b2da745 commit 3d097e5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

internal/orchestrator/provision.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ func ProvisionApp(ctx context.Context, docker *dockerClient.Client, app parser.A
2424
return fmt.Errorf("provisioning failed to pull base image: %w", err)
2525
}
2626

27-
resp, err := docker.ContainerCreate(ctx, &container.Config{
28-
Image: pythonImage,
29-
User: getCurrentUser(),
30-
Entrypoint: []string{"/run.sh", "provision"},
31-
}, &container.HostConfig{
32-
Binds: []string{app.FullPath.String() + ":/app"},
33-
AutoRemove: true,
34-
}, nil, nil, generateContainerName(app.Name))
27+
resp, err := docker.ContainerCreate(
28+
ctx,
29+
&container.Config{
30+
Image: pythonImage,
31+
User: getCurrentUser(),
32+
Entrypoint: []string{"/run.sh", "provision"},
33+
}, &container.HostConfig{
34+
Binds: []string{app.FullPath.String() + ":/app"},
35+
AutoRemove: true,
36+
},
37+
nil,
38+
nil,
39+
generateContainerName(app.Name))
3540
if err != nil {
3641
return fmt.Errorf("provisiong failed to create container: %w", err)
3742
}

pkg/parser/parser.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func ParseDescriptorFile(file *paths.Path) (AppDescriptor, error) {
7676
return AppDescriptor{}, fmt.Errorf("cannot decode descriptor: %w", err)
7777
}
7878

79+
if descriptor.Name == "" {
80+
return AppDescriptor{}, fmt.Errorf("application name is empty")
81+
}
82+
7983
return descriptor, validate(descriptor)
8084
}
8185

0 commit comments

Comments
 (0)