Skip to content
Closed
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
25 changes: 15 additions & 10 deletions bundle/config/mutator/resourcemutator/apply_presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
return "ApplyPresets"
}

func appendError(diags diag.Diagnostics, format string, args ...interface{}) diag.Diagnostics {

Check failure on line 37 in bundle/config/mutator/resourcemutator/apply_presets.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gofmt)
return diags.Extend(diag.Errorf("failed to apply preset: "+format, args...))
}

func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
var diags diag.Diagnostics

Expand All @@ -47,9 +51,10 @@
tags := toTagArray(t.Tags)

// Jobs presets: Prefix, Tags, JobsMaxConcurrentRuns, TriggerPauseStatus

for key, j := range r.Jobs {
if j.JobSettings == nil {
diags = diags.Extend(diag.Errorf("job %s is not defined", key))
diags = appendError(diags, "job %s is not defined", key)
continue
}
j.Name = prefix + j.Name
Expand Down Expand Up @@ -88,7 +93,7 @@
// Pipelines presets: Prefix, PipelinesDevelopment
for key, p := range r.Pipelines {
if p.CreatePipeline == nil {
diags = diags.Extend(diag.Errorf("pipeline %s is not defined", key))
diags = appendError(diags, "pipeline %s is not defined", key)
continue
}
p.Name = prefix + p.Name
Expand All @@ -104,7 +109,7 @@
// Models presets: Prefix, Tags
for key, m := range r.Models {
if m.Model == nil {
diags = diags.Extend(diag.Errorf("model %s is not defined", key))
diags = appendError(diags, "model %s is not defined", key)
continue
}
m.Name = prefix + m.Name
Expand All @@ -122,7 +127,7 @@
// Experiments presets: Prefix, Tags
for key, e := range r.Experiments {
if e.Experiment == nil {
diags = diags.Extend(diag.Errorf("experiment %s is not defined", key))
diags = appendError(diags, "experiment %s is not defined", key)
continue
}
filepath := e.Name
Expand Down Expand Up @@ -150,7 +155,7 @@
// Model serving endpoint presets: Prefix
for key, e := range r.ModelServingEndpoints {
if e.CreateServingEndpoint == nil {
diags = diags.Extend(diag.Errorf("model serving endpoint %s is not defined", key))
diags = appendError(diags, "model serving endpoint %s is not defined", key)
continue
}
e.Name = normalizePrefix(prefix) + e.Name
Expand All @@ -161,7 +166,7 @@
// Registered models presets: Prefix
for key, m := range r.RegisteredModels {
if m.CreateRegisteredModelRequest == nil {
diags = diags.Extend(diag.Errorf("registered model %s is not defined", key))
diags = appendError(diags, "registered model %s is not defined", key)
continue
}
m.Name = normalizePrefix(prefix) + m.Name
Expand All @@ -173,7 +178,7 @@
if t.TriggerPauseStatus == config.Paused {
for key, q := range r.QualityMonitors {
if q.CreateMonitor == nil {
diags = diags.Extend(diag.Errorf("quality monitor %s is not defined", key))
diags = appendError(diags, "quality monitor %s is not defined", key)
continue
}
// Remove all schedules from monitors, since they don't support pausing/unpausing.
Expand All @@ -188,7 +193,7 @@
// Schemas: Prefix
for key, s := range r.Schemas {
if s.CreateSchema == nil {
diags = diags.Extend(diag.Errorf("schema %s is not defined", key))
diags = appendError(diags, "schema %s is not defined", key)
continue
}
s.Name = normalizePrefix(prefix) + s.Name
Expand All @@ -199,7 +204,7 @@
// Clusters: Prefix, Tags
for key, c := range r.Clusters {
if c.ClusterSpec == nil {
diags = diags.Extend(diag.Errorf("cluster %s is not defined", key))
diags = appendError(diags, "cluster %s is not defined", key)
continue
}
c.ClusterName = prefix + c.ClusterName
Expand All @@ -218,7 +223,7 @@
// Dashboards: Prefix
for key, dashboard := range r.Dashboards {
if dashboard == nil || dashboard.Dashboard == nil {
diags = diags.Extend(diag.Errorf("dashboard %s s is not defined", key))
diags = appendError(diags, "dashboard %s is not defined", key)
continue
}
dashboard.DisplayName = prefix + dashboard.DisplayName
Expand Down
Loading