Skip to content

Commit 3a2ca62

Browse files
authored
Align volume and env message names across ateapi, atelet, and ateom pbs (#2666)
Fixes #2419 1. In `internal/proto/ateletpb/atelet.proto`: - Rename `EnvEntry` -> `EnvVar`. - Rename `DurableDirVolume` -> `DurableDirVolumeSource` and `SystemInfoVolume` -> `SystemInfoVolumeSource`. 2. In `internal/proto/ateompb/ateom.proto`: - Rename `Container.csi_volume_mounts` -> `external_volume_mounts`. - Rename `ActorDirs.volumes_dir` -> `external_volume_mounts_dir`. - Consolidate `VolumeMount`, `DurableDirVolumeMount`, `SystemInfoVolumeMount`, and `ImageVolumeMount` into a single `VolumeMount { string name = 1; string mount_path = 2; }` message (matching `ateapi.VolumeMount` and `atelet.VolumeMount`).
1 parent e3a75a5 commit 3a2ca62

38 files changed

Lines changed: 382 additions & 591 deletions

‎cmd/ateapi/internal/controlapi/workload_spec.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ func workloadSpecFromActorTemplate(actorTemplate *ateapipb.ActorTemplate, actor
5858
case vol.GetDurableDir() != nil:
5959
workloadSpec.Volumes = append(workloadSpec.Volumes, &ateletpb.Volume{
6060
Name: vol.GetName(),
61-
DurableDir: &ateletpb.DurableDirVolume{},
61+
DurableDir: &ateletpb.DurableDirVolumeSource{},
6262
})
6363

6464
case vol.GetSystemInfo() != nil:
65-
ateletSystemInfo := &ateletpb.SystemInfoVolume{}
65+
ateletSystemInfo := &ateletpb.SystemInfoVolumeSource{}
6666
for _, dataSource := range vol.GetSystemInfo().GetDataSources() {
6767
switch {
6868
case dataSource.GetActorMetadata() != nil:
@@ -130,7 +130,7 @@ func workloadSpecFromActorTemplate(actorTemplate *ateapipb.ActorTemplate, actor
130130
Resources: ctrResources,
131131
}
132132
for _, env := range ctr.GetEnv() {
133-
ateletCtr.Env = append(ateletCtr.Env, &ateletpb.EnvEntry{
133+
ateletCtr.Env = append(ateletCtr.Env, &ateletpb.EnvVar{
134134
Name: env.GetName(),
135135
Value: env.GetValue(),
136136
})

‎cmd/ateapi/internal/controlapi/workload_spec_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) {
5151
Volumes: []*ateletpb.Volume{
5252
{
5353
Name: "home",
54-
DurableDir: &ateletpb.DurableDirVolume{},
54+
DurableDir: &ateletpb.DurableDirVolumeSource{},
5555
},
5656
},
5757
Containers: []*ateletpb.Container{
@@ -100,7 +100,7 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) {
100100
Volumes: []*ateletpb.Volume{
101101
{
102102
Name: "system-info",
103-
SystemInfo: &ateletpb.SystemInfoVolume{
103+
SystemInfo: &ateletpb.SystemInfoVolumeSource{
104104
DataSources: []*ateletpb.SystemInfoDataSource{
105105
{ActorMetadata: &ateletpb.ActorMetadataDataSource{
106106
Items: []*ateletpb.ActorMetadataItem{
@@ -147,7 +147,7 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) {
147147
Volumes: []*ateletpb.Volume{
148148
{
149149
Name: "home",
150-
DurableDir: &ateletpb.DurableDirVolume{},
150+
DurableDir: &ateletpb.DurableDirVolumeSource{},
151151
},
152152
{
153153
Name: "agent",
@@ -196,7 +196,7 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) {
196196
Volumes: []*ateletpb.Volume{
197197
{
198198
Name: "system-info",
199-
SystemInfo: &ateletpb.SystemInfoVolume{
199+
SystemInfo: &ateletpb.SystemInfoVolumeSource{
200200
DataSources: []*ateletpb.SystemInfoDataSource{
201201
{TrustBundle: &ateletpb.TrustBundleDataSource{Names: []string{"egress-trust"}, Path: "trust/ca.pem"}},
202202
},
@@ -236,7 +236,7 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) {
236236
Volumes: []*ateletpb.Volume{
237237
{
238238
Name: "home",
239-
DurableDir: &ateletpb.DurableDirVolume{},
239+
DurableDir: &ateletpb.DurableDirVolumeSource{},
240240
},
241241
},
242242
Containers: []*ateletpb.Container{
@@ -265,7 +265,7 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) {
265265
Volumes: []*ateletpb.Volume{
266266
{
267267
Name: "home",
268-
DurableDir: &ateletpb.DurableDirVolume{},
268+
DurableDir: &ateletpb.DurableDirVolumeSource{},
269269
},
270270
},
271271
Containers: []*ateletpb.Container{{Name: "main", Image: "main"}},
@@ -290,7 +290,7 @@ func TestWorkloadSpecFromActorTemplate(t *testing.T) {
290290
Containers: []*ateletpb.Container{{
291291
Name: "main",
292292
Image: "main",
293-
Env: []*ateletpb.EnvEntry{
293+
Env: []*ateletpb.EnvVar{
294294
{Name: "LITERAL", Value: "plain"},
295295
{Name: "EMPTY", Value: ""},
296296
},

‎cmd/atelet/internal/apivalidation/validation_test.go‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ func TestValidateWorkloadSpec(t *testing.T) {
14371437
}
14381438
valid := func(mutate ...func(*ateletpb.WorkloadSpec)) *ateletpb.WorkloadSpec {
14391439
s := &ateletpb.WorkloadSpec{
1440-
Volumes: []*ateletpb.Volume{{Name: "data", DurableDir: &ateletpb.DurableDirVolume{}}},
1440+
Volumes: []*ateletpb.Volume{{Name: "data", DurableDir: &ateletpb.DurableDirVolumeSource{}}},
14411441
Containers: []*ateletpb.Container{ctr("main"), ctr("sidecar")},
14421442
}
14431443
for _, m := range mutate {
@@ -1470,7 +1470,7 @@ func TestValidateWorkloadSpec(t *testing.T) {
14701470
obj: valid(func(s *ateletpb.WorkloadSpec) {
14711471
s.Volumes = nil
14721472
for i := range 33 {
1473-
s.Volumes = append(s.Volumes, &ateletpb.Volume{Name: fmt.Sprintf("v%d", i), DurableDir: &ateletpb.DurableDirVolume{}})
1473+
s.Volumes = append(s.Volumes, &ateletpb.Volume{Name: fmt.Sprintf("v%d", i), DurableDir: &ateletpb.DurableDirVolumeSource{}})
14741474
}
14751475
}),
14761476
want: field.ErrorList{field.TooMany(field.NewPath("volumes"), 33, 32).WithOrigin("maxItems")},
@@ -1522,7 +1522,7 @@ func TestValidateWorkloadSpec(t *testing.T) {
15221522
// asserted at their paths under the volume.
15231523
func TestValidateVolume(t *testing.T) {
15241524
durable := func(mutate ...func(*ateletpb.Volume)) *ateletpb.Volume {
1525-
v := &ateletpb.Volume{Name: "data", DurableDir: &ateletpb.DurableDirVolume{}}
1525+
v := &ateletpb.Volume{Name: "data", DurableDir: &ateletpb.DurableDirVolumeSource{}}
15261526
for _, m := range mutate {
15271527
m(v)
15281528
}
@@ -1543,7 +1543,7 @@ func TestValidateVolume(t *testing.T) {
15431543
return &ateletpb.Volume{Name: "data", Image: &ateletpb.ImageVolumeSource{Reference: ref}}
15441544
}
15451545
systemInfo := func(ds ...*ateletpb.SystemInfoDataSource) *ateletpb.Volume {
1546-
return &ateletpb.Volume{Name: "data", SystemInfo: &ateletpb.SystemInfoVolume{DataSources: ds}}
1546+
return &ateletpb.Volume{Name: "data", SystemInfo: &ateletpb.SystemInfoVolumeSource{DataSources: ds}}
15471547
}
15481548
bundle := func(name, path string) *ateletpb.SystemInfoDataSource {
15491549
return &ateletpb.SystemInfoDataSource{TrustBundle: &ateletpb.TrustBundleDataSource{Names: []string{name}, Path: path}}
@@ -1654,7 +1654,7 @@ func TestValidateVolume(t *testing.T) {
16541654
want: field.ErrorList{field.Invalid(field.NewPath("image", "reference"), nil, "")},
16551655
},
16561656

1657-
// SystemInfoVolume and SystemInfoDataSource.
1657+
// SystemInfoVolumeSource and SystemInfoDataSource.
16581658
{
16591659
name: "valid system info",
16601660
obj: systemInfo(bundle("podcert", "a.pem"), bundle("podcert", "b.pem"), metadata(item(fieldName, "name"))),
@@ -1774,7 +1774,7 @@ func TestValidateContainer(t *testing.T) {
17741774
Image: testDigestImage,
17751775
Command: []string{"/bin/app"},
17761776
Args: []string{"--serve"},
1777-
Env: []*ateletpb.EnvEntry{{Name: "PORT", Value: "8080"}},
1777+
Env: []*ateletpb.EnvVar{{Name: "PORT", Value: "8080"}},
17781778
VolumeMounts: []*ateletpb.VolumeMount{
17791779
{Name: "data", MountPath: "/data"},
17801780
{Name: "data", MountPath: "/mnt/data"},
@@ -1785,7 +1785,7 @@ func TestValidateContainer(t *testing.T) {
17851785
}
17861786
return c
17871787
}
1788-
env := func(mutate func(*ateletpb.EnvEntry)) *ateletpb.Container {
1788+
env := func(mutate func(*ateletpb.EnvVar)) *ateletpb.Container {
17891789
return valid(func(c *ateletpb.Container) { mutate(c.Env[0]) })
17901790
}
17911791
// mount replaces the mounts with a single one, so the nesting check
@@ -1860,31 +1860,31 @@ func TestValidateContainer(t *testing.T) {
18601860
want: field.ErrorList{field.TooLong(field.NewPath("args").Index(0), nil, 4096).WithOrigin("maxLength")},
18611861
},
18621862

1863-
// EnvEntry.
1863+
// EnvVar.
18641864
{
18651865
name: "duplicate env names",
18661866
obj: valid(func(c *ateletpb.Container) {
1867-
c.Env = append(c.Env, &ateletpb.EnvEntry{Name: "PORT", Value: "9"})
1867+
c.Env = append(c.Env, &ateletpb.EnvVar{Name: "PORT", Value: "9"})
18681868
}),
18691869
want: field.ErrorList{field.Duplicate(field.NewPath("env").Index(1), nil)},
18701870
}, {
18711871
name: "env: missing name",
1872-
obj: env(func(e *ateletpb.EnvEntry) { e.Name = "" }),
1872+
obj: env(func(e *ateletpb.EnvVar) { e.Name = "" }),
18731873
want: field.ErrorList{field.Required(envPath.Child("name"), "")},
18741874
}, {
18751875
name: "env: name with equals sign",
1876-
obj: env(func(e *ateletpb.EnvEntry) { e.Name = "A=B" }),
1876+
obj: env(func(e *ateletpb.EnvVar) { e.Name = "A=B" }),
18771877
want: field.ErrorList{field.Invalid(envPath.Child("name"), nil, "")},
18781878
}, {
18791879
name: "env: name too long",
1880-
obj: env(func(e *ateletpb.EnvEntry) { e.Name = strings.Repeat("N", 257) }),
1880+
obj: env(func(e *ateletpb.EnvVar) { e.Name = strings.Repeat("N", 257) }),
18811881
want: field.ErrorList{field.TooLong(envPath.Child("name"), nil, 256).WithOrigin("maxLength")},
18821882
}, {
18831883
name: "env: empty value is allowed",
1884-
obj: env(func(e *ateletpb.EnvEntry) { e.Value = "" }),
1884+
obj: env(func(e *ateletpb.EnvVar) { e.Value = "" }),
18851885
}, {
18861886
name: "env: value too long",
1887-
obj: env(func(e *ateletpb.EnvEntry) { e.Value = strings.Repeat("v", 32769) }),
1887+
obj: env(func(e *ateletpb.EnvVar) { e.Value = strings.Repeat("v", 32769) }),
18881888
want: field.ErrorList{field.TooLong(envPath.Child("value"), nil, 32768).WithOrigin("maxLength")},
18891889
},
18901890

‎cmd/atelet/internal/apivalidation/workloadspec.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func ValidateCustom_Container_Image(_ context.Context, _ operation.Operation, fl
5959
return resources.ValidatePinnedImage(fldPath, *value)
6060
}
6161

62-
func ValidateCustom_EnvEntry_Name(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ *string) field.ErrorList {
62+
func ValidateCustom_EnvVar_Name(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ *string) field.ErrorList {
6363
return resources.ValidateEnvVarName(fldPath, *value)
6464
}
6565

@@ -117,11 +117,11 @@ func ValidateCustom_TrustBundleDataSource_Path(_ context.Context, _ operation.Op
117117
return resources.ValidateProjectedPath(fldPath, *value)
118118
}
119119

120-
// ValidateCustom_SystemInfoVolume_DataSources allows at most one
120+
// ValidateCustom_SystemInfoVolumeSource_DataSources allows at most one
121121
// actor_metadata entry and requires every projected file path to be unique
122122
// across all data sources: atelet writes them in order into one tree, so a
123123
// repeated path silently clobbers the earlier file.
124-
func ValidateCustom_SystemInfoVolume_DataSources(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ []*ateletpb.SystemInfoDataSource) field.ErrorList {
124+
func ValidateCustom_SystemInfoVolumeSource_DataSources(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ []*ateletpb.SystemInfoDataSource) field.ErrorList {
125125
var errs field.ErrorList
126126
seen := sets.New[string]()
127127
sawMetadata := false

‎cmd/atelet/internal/apivalidation/zz_generated.validation.go‎

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)