Skip to content
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
20 changes: 16 additions & 4 deletions cmd/ateapi/internal/controlapi/actor_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"regexp"
"strings"

"github.com/distribution/reference"

"github.com/agent-substrate/substrate/cmd/ateapi/internal/store"
"github.com/agent-substrate/substrate/internal/resources"
"github.com/agent-substrate/substrate/internal/volumepath"
Expand Down Expand Up @@ -269,11 +271,21 @@ func ValidateCustom_SystemInfoVolumeSource_DataSources(_ context.Context, _ oper
return errs
}

// validatePinnedImage requires an image reference to include a digest
// (e.g. "name@sha256:...").
// validatePinnedImage requires a well-formed OCI image reference pinned by
// digest (e.g. "name@sha256:..."): changing the image content under a fixed
// reference invalidates snapshots. It parses with the same grammar the
// container runtimes use, so a malformed digest is rejected rather than
// treated as pinned.
func validatePinnedImage(fldPath *field.Path, value string) field.ErrorList {
if !strings.Contains(value, "@") {
return field.ErrorList{field.Invalid(fldPath, value, "must include a digest")}
if value == "" {
return nil // required is enforced by tags
}
ref, err := reference.ParseNormalizedNamed(value)
if err != nil {
return field.ErrorList{field.Invalid(fldPath, value, fmt.Sprintf("must be a well-formed image reference: %v", err))}
}
if _, ok := ref.(reference.Digested); !ok {
return field.ErrorList{field.Invalid(fldPath, value, "must be pinned by digest (changing the image invalidates snapshots)")}
}
return nil
}
Expand Down
62 changes: 53 additions & 9 deletions cmd/ateapi/internal/controlapi/actor_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
func validActorTemplate(mutations ...func(*ateapipb.ActorTemplate)) *ateapipb.ActorTemplate {
template := &ateapipb.ActorTemplate{
Metadata: &ateapipb.ResourceMetadata{Atespace: "ns1", Name: "tmpl-a"},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:abc"}},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}},
SnapshotsConfig: &ateapipb.SnapshotsConfig{StorageLocation: "gs://my-bucket/snapshots"},
SandboxConfig: &ateapipb.SandboxConfig{SandboxClass: ateapipb.SandboxClass_SANDBOX_CLASS_GVISOR, ConfigName: "gvisor-default"},
}
Expand Down Expand Up @@ -308,7 +308,7 @@ func TestCreateActorTemplateIgnoresServerOwnedFields(t *testing.T) {
tmpl.Metadata.Uid = "11111111-1111-1111-1111-111111111111"
tmpl.Metadata.Version = 42
tmpl.WorkerSelector = &ateapipb.Selector{MatchLabels: map[string]string{"pool": "default"}}
tmpl.Containers = []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:abc"}}
tmpl.Containers = []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}}
tmpl.SnapshotsConfig = &ateapipb.SnapshotsConfig{StorageLocation: "gs://my-bucket/snapshots"}
tmpl.Resources = &ateapipb.Resources{Limits: []*ateapipb.Limits{{Name: "memory", Quantity: "1Gi"}}}
// Server-owned status a client must not be able to set.
Expand Down Expand Up @@ -550,14 +550,14 @@ func TestValidateActorTemplate(t *testing.T) {
name: "too many containers",
mutate: func(tmpl *ateapipb.ActorTemplate) {
for i := 0; i < 10; i++ {
tmpl.Containers = append(tmpl.Containers, &ateapipb.Container{Name: fmt.Sprintf("c-%d", i), Image: "example.com/app:v1@sha256:abc"})
tmpl.Containers = append(tmpl.Containers, &ateapipb.Container{Name: fmt.Sprintf("c-%d", i), Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"})
}
},
want: field.ErrorList{field.TooMany(field.NewPath("containers"), 11, 10).WithOrigin("maxItems")},
}, {
name: "duplicate container name",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Containers = append(tmpl.Containers, &ateapipb.Container{Name: "main", Image: "example.com/other:v1@sha256:abc"})
tmpl.Containers = append(tmpl.Containers, &ateapipb.Container{Name: "main", Image: "example.com/other:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"})
},
want: field.ErrorList{field.Duplicate(field.NewPath("containers").Index(1), nil)},
}, {
Expand Down Expand Up @@ -631,7 +631,7 @@ func TestValidateActorTemplate(t *testing.T) {
}, {
name: "the same path in different containers is allowed",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Containers = append(tmpl.Containers, &ateapipb.Container{Name: "sidecar", Image: "example.com/side:v1@sha256:abc"})
tmpl.Containers = append(tmpl.Containers, &ateapipb.Container{Name: "sidecar", Image: "example.com/side:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"})
tmpl.Containers[0].VolumeMounts = []*ateapipb.VolumeMount{{Name: "data", MountPath: "/var/data"}}
tmpl.Containers[1].VolumeMounts = []*ateapipb.VolumeMount{{Name: "data", MountPath: "/var/data"}}
},
Expand Down Expand Up @@ -712,9 +712,41 @@ func TestValidateActorTemplate(t *testing.T) {
}, {
name: "image too long",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Containers[0].Image = strings.Repeat("x", 513) + "@sha256:abc"
tmpl.Containers[0].Image = strings.Repeat("x", 513) + "@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
want: field.ErrorList{field.TooLong(field.NewPath("containers").Index(0).Child("image"), nil, 512).WithOrigin("maxLength")},
want: field.ErrorList{
field.Invalid(field.NewPath("containers").Index(0).Child("image"), nil, ""),
field.TooLong(field.NewPath("containers").Index(0).Child("image"), nil, 512).WithOrigin("maxLength"),
},
}, {
name: "invalid image: bare repository without digest",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Containers[0].Image = "ubuntu"
},
want: field.ErrorList{field.Invalid(field.NewPath("containers").Index(0).Child("image"), nil, "")},
}, {
name: "valid image: pinned by digest",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Containers[0].Image = "example.com/app@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
}, {
name: "invalid image: uppercase repository",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Containers[0].Image = "example.com/App:v1"
},
want: field.ErrorList{field.Invalid(field.NewPath("containers").Index(0).Child("image"), nil, "")},
}, {
name: "invalid image: malformed digest",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Containers[0].Image = "example.com/app@sha256:abc"
},
want: field.ErrorList{field.Invalid(field.NewPath("containers").Index(0).Child("image"), nil, "")},
}, {
name: "invalid image: empty tag",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Containers[0].Image = "example.com/app:"
},
want: field.ErrorList{field.Invalid(field.NewPath("containers").Index(0).Child("image"), nil, "")},
}, {
name: "container image missing digest",
mutate: func(tmpl *ateapipb.ActorTemplate) {
Expand Down Expand Up @@ -949,14 +981,14 @@ func TestValidateActorTemplate(t *testing.T) {
tmpl.Volumes = []*ateapipb.Volume{{
Name: "scratch",
DurableDir: &ateapipb.DurableDirVolumeSource{},
Image: &ateapipb.ImageVolumeSource{Reference: "example.com/app@sha256:abc"},
Image: &ateapipb.ImageVolumeSource{Reference: "example.com/app@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},
}}
},
want: field.ErrorList{field.Invalid(field.NewPath("volumes").Index(0), nil, "one of").WithOrigin("union")},
}, {
name: "valid image volume",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "tools", Image: &ateapipb.ImageVolumeSource{Reference: "example.com/app@sha256:abc"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "tools", Image: &ateapipb.ImageVolumeSource{Reference: "example.com/app@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}}}
},
}, {
name: "image volume missing reference",
Expand All @@ -970,6 +1002,18 @@ func TestValidateActorTemplate(t *testing.T) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "tools", Image: &ateapipb.ImageVolumeSource{Reference: "example.com/app:v1"}}}
},
want: field.ErrorList{field.Invalid(field.NewPath("volumes").Index(0).Child("image", "reference"), nil, "")},
}, {
name: "image volume reference with malformed digest",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "tools", Image: &ateapipb.ImageVolumeSource{Reference: "example.com/app@sha256:abc"}}}
},
want: field.ErrorList{field.Invalid(field.NewPath("volumes").Index(0).Child("image", "reference"), nil, "")},
}, {
name: "image volume reference not a reference at all",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "tools", Image: &ateapipb.ImageVolumeSource{Reference: "@"}}}
},
want: field.ErrorList{field.Invalid(field.NewPath("volumes").Index(0).Child("image", "reference"), nil, "")},
}, {
name: "valid external volume template",
mutate: func(tmpl *ateapipb.ActorTemplate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestActorTemplateCRUD(t *testing.T) {
created, err := tc.client.CreateActorTemplate(ctx, &ateapipb.CreateActorTemplateRequest{
ActorTemplate: &ateapipb.ActorTemplate{
Metadata: &ateapipb.ResourceMetadata{Atespace: testAtespace, Name: "tmpl-a"},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:abc"}},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}},
SnapshotsConfig: &ateapipb.SnapshotsConfig{StorageLocation: "gs://my-bucket/snapshots"},
SandboxConfig: &ateapipb.SandboxConfig{
SandboxClass: ateapipb.SandboxClass_SANDBOX_CLASS_GVISOR,
Expand All @@ -54,7 +54,7 @@ func TestActorTemplateCRUD(t *testing.T) {
}
want := &ateapipb.ActorTemplate{
Metadata: &ateapipb.ResourceMetadata{Atespace: testAtespace, Name: "tmpl-a", Version: 1},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:abc"}},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}},
SnapshotsConfig: &ateapipb.SnapshotsConfig{StorageLocation: "gs://my-bucket/snapshots"},
SandboxConfig: &ateapipb.SandboxConfig{
SandboxClass: ateapipb.SandboxClass_SANDBOX_CLASS_GVISOR,
Expand All @@ -70,7 +70,7 @@ func TestActorTemplateCRUD(t *testing.T) {
_, err = tc.client.CreateActorTemplate(ctx, &ateapipb.CreateActorTemplateRequest{
ActorTemplate: &ateapipb.ActorTemplate{
Metadata: &ateapipb.ResourceMetadata{Atespace: testAtespace, Name: "tmpl-a"},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:abc"}},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}},
SnapshotsConfig: &ateapipb.SnapshotsConfig{StorageLocation: "gs://my-bucket/snapshots"},
SandboxConfig: &ateapipb.SandboxConfig{SandboxClass: ateapipb.SandboxClass_SANDBOX_CLASS_GVISOR, ConfigName: "gvisor-default"},
},
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestActorTemplateCRUD(t *testing.T) {
_, err = tc.client.CreateActorTemplate(ctx, &ateapipb.CreateActorTemplateRequest{
ActorTemplate: &ateapipb.ActorTemplate{
Metadata: &ateapipb.ResourceMetadata{Atespace: testAtespace, Name: "tmpl-unnamed-config"},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:abc"}},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}},
SnapshotsConfig: &ateapipb.SnapshotsConfig{StorageLocation: "gs://my-bucket/snapshots"},
SandboxConfig: &ateapipb.SandboxConfig{SandboxClass: ateapipb.SandboxClass_SANDBOX_CLASS_GVISOR},
},
Expand Down
8 changes: 4 additions & 4 deletions cmd/ateapi/internal/controlapi/functionaltest/actor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestCreateActor_SubstrateTemplateRef(t *testing.T) {
if _, err := tc.client.CreateActorTemplate(ctx, &ateapipb.CreateActorTemplateRequest{
ActorTemplate: &ateapipb.ActorTemplate{
Metadata: &ateapipb.ResourceMetadata{Atespace: testAtespace, Name: "sub-tmpl"},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:abc"}},
Containers: []*ateapipb.Container{{Name: "main", Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}},
SnapshotsConfig: &ateapipb.SnapshotsConfig{StorageLocation: "gs://my-bucket/snapshots"},
SandboxConfig: &ateapipb.SandboxConfig{SandboxClass: ateapipb.SandboxClass_SANDBOX_CLASS_GVISOR, ConfigName: "gvisor-default"},
},
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestCreateActor_RejectsSnapshotWithExternalVolumes(t *testing.T) {
ConfigName: "gvisor-default",
},
Containers: []*ateapipb.Container{{
Name: "main", Image: "main@sha256:abc", VolumeMounts: []*ateapipb.VolumeMount{{Name: "data", MountPath: "/data"}},
Name: "main", Image: "main@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", VolumeMounts: []*ateapipb.VolumeMount{{Name: "data", MountPath: "/data"}},
}},
Volumes: []*ateapipb.Volume{{
Name: "data",
Expand Down Expand Up @@ -753,7 +753,7 @@ func TestUpdateActor_RepointTemplate(t *testing.T) {
Metadata: &ateapipb.ResourceMetadata{Atespace: testAtespace, Name: name},
Containers: []*ateapipb.Container{{
Name: "main",
Image: "example.com/app:v1@sha256:abc",
Image: "example.com/app:v1@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
VolumeMounts: []*ateapipb.VolumeMount{{Name: "data", MountPath: tmpl.mountPath}},
}},
Volumes: tmpl.volumes,
Expand Down Expand Up @@ -1865,7 +1865,7 @@ func TestResumeActorPassesLiteralEnv(t *testing.T) {
createTemplateWithContainers(t, tc, ns, []*ateapipb.Container{
{
Name: "main",
Image: "main@sha256:abc",
Image: "main@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
Command: []string{"/main"},
Env: []*ateapipb.EnvVar{
{
Expand Down
10 changes: 5 additions & 5 deletions cmd/ateapi/internal/controlapi/functionaltest/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func createTemplate(t *testing.T, tc *testContext, ns string) *ateapipb.ActorTem
return createTemplateWithContainers(t, tc, ns, []*ateapipb.Container{
{
Name: "main",
Image: "main@sha256:abc",
Image: "main@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
Command: []string{"/main"},
},
})
Expand All @@ -411,7 +411,7 @@ func createTemplateWithVolumes(t *testing.T, tc *testContext, ns string, volumes
return createTemplateWithContainersAndVolumes(t, tc, ns, []*ateapipb.Container{
{
Name: "main",
Image: "main@sha256:abc",
Image: "main@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
Command: []string{"/main"},
VolumeMounts: mounts,
},
Expand Down Expand Up @@ -476,7 +476,7 @@ func createTemplateWithContainersAndVolumes(t *testing.T, tc *testContext, ns st

// testPauseImage is the pause image the default test SandboxConfig carries;
// it is what a resolved WorkloadSpec's sandbox assets should name.
const testPauseImage = "pause@sha256:abc"
const testPauseImage = "pause@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

// ensureDefaultGvisorSandboxConfig creates the cluster-scoped "gvisor-default"
// SandboxConfig (idempotently) and waits for it to appear in the lister.
Expand Down Expand Up @@ -527,7 +527,7 @@ func createWorkerPool(t *testing.T, tc *testContext, ns string, name string, lab
},
Spec: atev1alpha1.WorkerPoolSpec{
Replicas: 1,
WorkerImage: "ateom@sha256:abc",
WorkerImage: "ateom@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
},
}
_, err := tc.substrateClient.ApiV1alpha1().WorkerPools(ns).Create(context.Background(), wp, metav1.CreateOptions{})
Expand Down Expand Up @@ -571,7 +571,7 @@ func createTemplateWithSelector(t *testing.T, tc *testContext, name string, sele
ConfigName: "gvisor-default",
},
Containers: []*ateapipb.Container{
{Name: "main", Image: "main@sha256:abc", Command: []string{"/main"}},
{Name: "main", Image: "main@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", Command: []string{"/main"}},
},
WorkerSelector: selector,
},
Expand Down
25 changes: 25 additions & 0 deletions cmd/ateapi/internal/controlapi/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ func ateDeepEqual[T any](a, b T) bool {
return reflect.DeepEqual(a, b)
}

// ValidateCustom_ResourceMetadata checks the server-stamped timestamps: each,
// when set, must be a valid google.protobuf.Timestamp, and update_time must
// not precede create_time. Both fields are scrubbed from input, so a
// violation here is a server stamping bug surfaced by the final-object
// validation pass, not a client error.
func ValidateCustom_ResourceMetadata(_ context.Context, _ operation.Operation, fldPath *field.Path, obj, _ *ateapipb.ResourceMetadata) field.ErrorList {
var errs field.ErrorList
createTimeValid := false
if ct := obj.GetCreateTime(); ct != nil {
if err := ct.CheckValid(); err != nil {
errs = append(errs, field.Invalid(fldPath.Child("create_time"), ct.String(), err.Error()))
} else {
createTimeValid = true
}
}
if ut := obj.GetUpdateTime(); ut != nil {
if err := ut.CheckValid(); err != nil {
errs = append(errs, field.Invalid(fldPath.Child("update_time"), ut.String(), err.Error()))
} else if createTimeValid && ut.AsTime().Before(obj.GetCreateTime().AsTime()) {
errs = append(errs, field.Invalid(fldPath.Child("update_time"), ut.String(), "must not precede create_time"))
}
}
return errs
}

// This is needed because DV doesn't have a standard format for IP addresses yet.
func ValidateCustom_WorkerAssignment_WorkerPodIp(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ *string) field.ErrorList {
return validation.IsValidIP(fldPath, *value)
Expand Down
29 changes: 27 additions & 2 deletions cmd/ateapi/internal/controlapi/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ func TestValidateResourceMetadataCreate(t *testing.T) {
name: "unspecified updateTime",
obj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime = nil }),
want: nil,
}, {
name: "invalid createTime: seconds out of range",
obj: valid(func(rm *ateapipb.ResourceMetadata) { rm.CreateTime = &timestamppb.Timestamp{Seconds: 253402300800} }),
want: field.ErrorList{field.Invalid(field.NewPath("create_time"), nil, "")},
}, {
name: "invalid updateTime: negative nanos",
obj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime = &timestamppb.Timestamp{Seconds: 5309, Nanos: -1} }),
want: field.ErrorList{field.Invalid(field.NewPath("update_time"), nil, "")},
}, {
name: "invalid updateTime: precedes createTime",
obj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime = &timestamppb.Timestamp{Seconds: 866} }),
want: field.ErrorList{field.Invalid(field.NewPath("update_time"), nil, "")},
}, {
name: "valid updateTime: equals createTime",
obj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime = &timestamppb.Timestamp{Seconds: 867} }),
want: nil,
}, {
name: "valid updateTime: set without createTime",
obj: valid(func(rm *ateapipb.ResourceMetadata) { rm.CreateTime = nil }),
want: nil,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -201,9 +221,14 @@ func TestValidateResourceMetadataUpdate(t *testing.T) {
want: field.ErrorList{field.Invalid(field.NewPath("update_time"), nil, "").WithOrigin("update")},
}, {
name: "update_time: changed to valid",
oldObj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime.Seconds = 123 }),
newObj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime.Seconds = 456 }),
oldObj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime.Seconds = 1000 }),
newObj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime.Seconds = 6000 }),
want: nil,
}, {
name: "update_time: changed to precede create_time",
oldObj: valid(),
newObj: valid(func(rm *ateapipb.ResourceMetadata) { rm.UpdateTime.Seconds = 866 }),
want: field.ErrorList{field.Invalid(field.NewPath("update_time"), nil, "")},
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading
Loading