Skip to content
Open
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
10 changes: 10 additions & 0 deletions cmd/ateapi/internal/controlapi/actor_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ func ValidateCustom_Resources_Limits(_ context.Context, _ operation.Operation, f
return errs
}

// ValidateCustom_SnapshotsConfig_StorageLocation ensures an
// ActorTemplate's snapshotsConfig.location is a well-formed
// URI with a bucket, so a bad location fails fast.
func ValidateCustom_SnapshotsConfig_StorageLocation(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ *string) field.ErrorList {
if err := resources.ValidateSnapshotLocation(*value); err != nil {
return field.ErrorList{field.Invalid(fldPath, *value, err.Error())}
}
return nil
}

// ValidateCustom_SnapshotsConfig requires on_commit to be a
// subset of on_pause. UNSPECIFIED means FULL, so an unset on_commit over a
// DATA on_pause is rejected too.
Expand Down
12 changes: 12 additions & 0 deletions cmd/ateapi/internal/controlapi/actor_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ func TestValidateCreateActorTemplateRequest(t *testing.T) {
tmpl.SnapshotsConfig.StorageLocation = ""
})},
field.ErrorList{field.Required(field.NewPath("actor_template", "snapshots_config", "storage_location"), "")},
}, {
"storage_location without a bucket",
&ateapipb.CreateActorTemplateRequest{ActorTemplate: validActorTemplate(func(tmpl *ateapipb.ActorTemplate) {
tmpl.SnapshotsConfig.StorageLocation = "my-bucket/snapshots"
})},
field.ErrorList{field.Invalid(field.NewPath("actor_template", "snapshots_config", "storage_location"), "my-bucket/snapshots", "")},
}, {
"storage_location with a query",
&ateapipb.CreateActorTemplateRequest{ActorTemplate: validActorTemplate(func(tmpl *ateapipb.ActorTemplate) {
tmpl.SnapshotsConfig.StorageLocation = "gs://my-bucket/snapshots?versions=true"
})},
field.ErrorList{field.Invalid(field.NewPath("actor_template", "snapshots_config", "storage_location"), "gs://my-bucket/snapshots?versions=true", "")},
}, {
"on_commit broader than on_pause",
&ateapipb.CreateActorTemplateRequest{ActorTemplate: validActorTemplate(func(tmpl *ateapipb.ActorTemplate) {
Expand Down
4 changes: 4 additions & 0 deletions cmd/ateapi/internal/controlapi/zz_generated.validation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/proto/ateapipb/ateapi.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/proto/ateapipb/ateapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@ message SnapshotsConfig {
// this version are stored under. Required.
//
// +k8s:required
// +k8s:maxLength=1024 # bound only; object-storage URI formats vary
// TODO: validate that this is a well-formed object-storage URI
// +k8s:maxLength=1024
// +k8s:customValidation # Validate URI
string storage_location = 4;
}

Expand Down
Loading