2022-12-09 07:57:30 +00:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
2024-02-16 20:54:38 +00:00
|
|
|
"context"
|
2022-12-09 07:57:30 +00:00
|
|
|
"encoding/json"
|
2022-12-15 14:12:47 +00:00
|
|
|
"fmt"
|
2022-12-09 07:57:30 +00:00
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle/config"
|
|
|
|
"github.com/databricks/cli/bundle/config/resources"
|
2024-02-16 20:54:38 +00:00
|
|
|
"github.com/databricks/cli/bundle/deploy/terraform/tfdyn"
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle/internal/tf/schema"
|
2024-02-16 20:54:38 +00:00
|
|
|
"github.com/databricks/cli/libs/dyn"
|
2022-12-15 14:12:47 +00:00
|
|
|
tfjson "github.com/hashicorp/terraform-json"
|
2022-12-09 07:57:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func conv(from any, to any) {
|
|
|
|
buf, _ := json.Marshal(from)
|
|
|
|
json.Unmarshal(buf, &to)
|
|
|
|
}
|
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
func convPermissions(acl []resources.Permission) *schema.ResourcePermissions {
|
|
|
|
if len(acl) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
resource := schema.ResourcePermissions{}
|
|
|
|
for _, ac := range acl {
|
|
|
|
resource.AccessControl = append(resource.AccessControl, convPermission(ac))
|
|
|
|
}
|
|
|
|
|
|
|
|
return &resource
|
|
|
|
}
|
|
|
|
|
|
|
|
func convPermission(ac resources.Permission) schema.ResourcePermissionsAccessControl {
|
|
|
|
dst := schema.ResourcePermissionsAccessControl{
|
|
|
|
PermissionLevel: ac.Level,
|
|
|
|
}
|
|
|
|
if ac.UserName != "" {
|
|
|
|
dst.UserName = ac.UserName
|
|
|
|
}
|
|
|
|
if ac.GroupName != "" {
|
|
|
|
dst.GroupName = ac.GroupName
|
|
|
|
}
|
|
|
|
if ac.ServicePrincipalName != "" {
|
|
|
|
dst.ServicePrincipalName = ac.ServicePrincipalName
|
|
|
|
}
|
|
|
|
return dst
|
|
|
|
}
|
|
|
|
|
2023-10-16 15:32:49 +00:00
|
|
|
func convGrants(acl []resources.Grant) *schema.ResourceGrants {
|
|
|
|
if len(acl) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
resource := schema.ResourceGrants{}
|
|
|
|
for _, ac := range acl {
|
|
|
|
resource.Grant = append(resource.Grant, schema.ResourceGrantsGrant{
|
|
|
|
Privileges: ac.Privileges,
|
|
|
|
Principal: ac.Principal,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return &resource
|
|
|
|
}
|
|
|
|
|
2022-12-09 07:57:30 +00:00
|
|
|
// BundleToTerraform converts resources in a bundle configuration
|
|
|
|
// to the equivalent Terraform JSON representation.
|
|
|
|
//
|
2024-07-31 12:16:28 +00:00
|
|
|
// Note: This function is an older implementation of the conversion logic. It is
|
|
|
|
// no longer used in any code paths. It is kept around to be used in tests.
|
|
|
|
// New resources do not need to modify this function and can instead can define
|
|
|
|
// the conversion login in the tfdyn package.
|
2023-09-13 22:50:37 +00:00
|
|
|
func BundleToTerraform(config *config.Root) *schema.Root {
|
2022-12-09 07:57:30 +00:00
|
|
|
tfroot := schema.NewRoot()
|
2022-12-12 10:31:28 +00:00
|
|
|
tfroot.Provider = schema.NewProviders()
|
|
|
|
tfroot.Resource = schema.NewResources()
|
2023-09-06 09:52:31 +00:00
|
|
|
noResources := true
|
2022-12-09 07:57:30 +00:00
|
|
|
|
|
|
|
for k, src := range config.Resources.Jobs {
|
2023-09-06 09:52:31 +00:00
|
|
|
noResources = false
|
2022-12-09 07:57:30 +00:00
|
|
|
var dst schema.ResourceJob
|
|
|
|
conv(src, &dst)
|
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
if src.JobSettings != nil {
|
|
|
|
for _, v := range src.Tasks {
|
|
|
|
var t schema.ResourceJobTask
|
|
|
|
conv(v, &t)
|
2022-12-12 15:36:59 +00:00
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
for _, v_ := range v.Libraries {
|
|
|
|
var l schema.ResourceJobTaskLibrary
|
|
|
|
conv(v_, &l)
|
|
|
|
t.Library = append(t.Library, l)
|
|
|
|
}
|
2022-12-12 15:36:59 +00:00
|
|
|
|
2024-04-05 15:52:39 +00:00
|
|
|
// Convert for_each_task libraries
|
|
|
|
if v.ForEachTask != nil {
|
|
|
|
for _, v_ := range v.ForEachTask.Task.Libraries {
|
|
|
|
var l schema.ResourceJobTaskForEachTaskTaskLibrary
|
|
|
|
conv(v_, &l)
|
|
|
|
t.ForEachTask.Task.Library = append(t.ForEachTask.Task.Library, l)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
dst.Task = append(dst.Task, t)
|
|
|
|
}
|
2022-12-09 07:57:30 +00:00
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
for _, v := range src.JobClusters {
|
|
|
|
var t schema.ResourceJobJobCluster
|
|
|
|
conv(v, &t)
|
|
|
|
dst.JobCluster = append(dst.JobCluster, t)
|
|
|
|
}
|
2022-12-09 07:57:30 +00:00
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
// Unblock downstream work. To be addressed more generally later.
|
|
|
|
if git := src.GitSource; git != nil {
|
|
|
|
dst.GitSource = &schema.ResourceJobGitSource{
|
|
|
|
Url: git.GitUrl,
|
|
|
|
Branch: git.GitBranch,
|
|
|
|
Commit: git.GitCommit,
|
|
|
|
Provider: string(git.GitProvider),
|
|
|
|
Tag: git.GitTag,
|
|
|
|
}
|
2022-12-09 07:57:30 +00:00
|
|
|
}
|
2023-09-07 12:48:59 +00:00
|
|
|
|
|
|
|
for _, v := range src.Parameters {
|
|
|
|
var t schema.ResourceJobParameter
|
|
|
|
conv(v, &t)
|
|
|
|
dst.Parameter = append(dst.Parameter, t)
|
|
|
|
}
|
2022-12-09 07:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tfroot.Resource.Job[k] = &dst
|
2023-03-21 09:58:16 +00:00
|
|
|
|
|
|
|
// Configure permissions for this resource.
|
|
|
|
if rp := convPermissions(src.Permissions); rp != nil {
|
|
|
|
rp.JobId = fmt.Sprintf("${databricks_job.%s.id}", k)
|
|
|
|
tfroot.Resource.Permissions["job_"+k] = rp
|
|
|
|
}
|
2022-12-09 07:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for k, src := range config.Resources.Pipelines {
|
2023-09-06 09:52:31 +00:00
|
|
|
noResources = false
|
2022-12-09 07:57:30 +00:00
|
|
|
var dst schema.ResourcePipeline
|
|
|
|
conv(src, &dst)
|
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
if src.PipelineSpec != nil {
|
|
|
|
for _, v := range src.Libraries {
|
|
|
|
var l schema.ResourcePipelineLibrary
|
|
|
|
conv(v, &l)
|
|
|
|
dst.Library = append(dst.Library, l)
|
|
|
|
}
|
2022-12-09 07:57:30 +00:00
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
for _, v := range src.Clusters {
|
|
|
|
var l schema.ResourcePipelineCluster
|
|
|
|
conv(v, &l)
|
|
|
|
dst.Cluster = append(dst.Cluster, l)
|
|
|
|
}
|
2023-12-12 11:36:06 +00:00
|
|
|
|
|
|
|
for _, v := range src.Notifications {
|
|
|
|
var l schema.ResourcePipelineNotification
|
|
|
|
conv(v, &l)
|
|
|
|
dst.Notification = append(dst.Notification, l)
|
|
|
|
}
|
2022-12-09 07:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tfroot.Resource.Pipeline[k] = &dst
|
2023-03-21 09:58:16 +00:00
|
|
|
|
|
|
|
// Configure permissions for this resource.
|
|
|
|
if rp := convPermissions(src.Permissions); rp != nil {
|
|
|
|
rp.PipelineId = fmt.Sprintf("${databricks_pipeline.%s.id}", k)
|
|
|
|
tfroot.Resource.Permissions["pipeline_"+k] = rp
|
|
|
|
}
|
2022-12-09 07:57:30 +00:00
|
|
|
}
|
|
|
|
|
2023-03-20 20:28:43 +00:00
|
|
|
for k, src := range config.Resources.Models {
|
2023-09-06 09:52:31 +00:00
|
|
|
noResources = false
|
2023-03-20 20:28:43 +00:00
|
|
|
var dst schema.ResourceMlflowModel
|
|
|
|
conv(src, &dst)
|
|
|
|
tfroot.Resource.MlflowModel[k] = &dst
|
2023-03-21 09:58:16 +00:00
|
|
|
|
|
|
|
// Configure permissions for this resource.
|
|
|
|
if rp := convPermissions(src.Permissions); rp != nil {
|
|
|
|
rp.RegisteredModelId = fmt.Sprintf("${databricks_mlflow_model.%s.registered_model_id}", k)
|
|
|
|
tfroot.Resource.Permissions["mlflow_model_"+k] = rp
|
|
|
|
}
|
2023-03-20 20:28:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for k, src := range config.Resources.Experiments {
|
2023-09-06 09:52:31 +00:00
|
|
|
noResources = false
|
2023-03-20 20:28:43 +00:00
|
|
|
var dst schema.ResourceMlflowExperiment
|
|
|
|
conv(src, &dst)
|
|
|
|
tfroot.Resource.MlflowExperiment[k] = &dst
|
2023-03-21 09:58:16 +00:00
|
|
|
|
|
|
|
// Configure permissions for this resource.
|
|
|
|
if rp := convPermissions(src.Permissions); rp != nil {
|
|
|
|
rp.ExperimentId = fmt.Sprintf("${databricks_mlflow_experiment.%s.id}", k)
|
|
|
|
tfroot.Resource.Permissions["mlflow_experiment_"+k] = rp
|
|
|
|
}
|
2023-03-20 20:28:43 +00:00
|
|
|
}
|
|
|
|
|
2023-09-07 21:54:31 +00:00
|
|
|
for k, src := range config.Resources.ModelServingEndpoints {
|
|
|
|
noResources = false
|
|
|
|
var dst schema.ResourceModelServing
|
|
|
|
conv(src, &dst)
|
|
|
|
tfroot.Resource.ModelServing[k] = &dst
|
|
|
|
|
|
|
|
// Configure permissions for this resource.
|
|
|
|
if rp := convPermissions(src.Permissions); rp != nil {
|
|
|
|
rp.ServingEndpointId = fmt.Sprintf("${databricks_model_serving.%s.serving_endpoint_id}", k)
|
|
|
|
tfroot.Resource.Permissions["model_serving_"+k] = rp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-16 15:32:49 +00:00
|
|
|
for k, src := range config.Resources.RegisteredModels {
|
|
|
|
noResources = false
|
|
|
|
var dst schema.ResourceRegisteredModel
|
|
|
|
conv(src, &dst)
|
|
|
|
tfroot.Resource.RegisteredModel[k] = &dst
|
|
|
|
|
|
|
|
// Configure permissions for this resource.
|
|
|
|
if rp := convGrants(src.Grants); rp != nil {
|
|
|
|
rp.Function = fmt.Sprintf("${databricks_registered_model.%s.id}", k)
|
|
|
|
tfroot.Resource.Grants["registered_model_"+k] = rp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-31 09:42:25 +00:00
|
|
|
for k, src := range config.Resources.QualityMonitors {
|
|
|
|
noResources = false
|
|
|
|
var dst schema.ResourceQualityMonitor
|
|
|
|
conv(src, &dst)
|
|
|
|
tfroot.Resource.QualityMonitor[k] = &dst
|
|
|
|
}
|
|
|
|
|
2023-09-13 22:50:37 +00:00
|
|
|
// We explicitly set "resource" to nil to omit it from a JSON encoding.
|
|
|
|
// This is required because the terraform CLI requires >= 1 resources defined
|
|
|
|
// if the "resource" property is used in a .tf.json file.
|
|
|
|
if noResources {
|
|
|
|
tfroot.Resource = nil
|
|
|
|
}
|
|
|
|
return tfroot
|
2022-12-09 07:57:30 +00:00
|
|
|
}
|
2022-12-15 14:12:47 +00:00
|
|
|
|
2024-02-16 20:54:38 +00:00
|
|
|
// BundleToTerraformWithDynValue converts resources in a bundle configuration
|
|
|
|
// to the equivalent Terraform JSON representation.
|
|
|
|
func BundleToTerraformWithDynValue(ctx context.Context, root dyn.Value) (*schema.Root, error) {
|
|
|
|
tfroot := schema.NewRoot()
|
|
|
|
tfroot.Provider = schema.NewProviders()
|
|
|
|
|
|
|
|
// Convert each resource in the bundle to the equivalent Terraform representation.
|
2024-05-01 08:22:35 +00:00
|
|
|
dynResources, err := dyn.Get(root, "resources")
|
2024-02-16 20:54:38 +00:00
|
|
|
if err != nil {
|
|
|
|
// If the resources key is missing, return an empty root.
|
|
|
|
if dyn.IsNoSuchKeyError(err) {
|
|
|
|
return tfroot, nil
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
tfroot.Resource = schema.NewResources()
|
|
|
|
|
|
|
|
numResources := 0
|
2024-05-01 08:22:35 +00:00
|
|
|
_, err = dyn.Walk(dynResources, func(p dyn.Path, v dyn.Value) (dyn.Value, error) {
|
2024-02-16 20:54:38 +00:00
|
|
|
if len(p) < 2 {
|
|
|
|
return v, nil
|
|
|
|
}
|
|
|
|
|
2024-05-01 08:22:35 +00:00
|
|
|
// Skip resources that have been deleted locally.
|
|
|
|
modifiedStatus, err := dyn.Get(v, "modified_status")
|
|
|
|
if err == nil {
|
|
|
|
modifiedStatusStr, ok := modifiedStatus.AsString()
|
|
|
|
if ok && modifiedStatusStr == resources.ModifiedStatusDeleted {
|
|
|
|
return v, dyn.ErrSkip
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-16 20:54:38 +00:00
|
|
|
typ := p[0].Key()
|
|
|
|
key := p[1].Key()
|
|
|
|
|
|
|
|
// Lookup the converter based on the resource type.
|
|
|
|
c, ok := tfdyn.GetConverter(typ)
|
|
|
|
if !ok {
|
|
|
|
return dyn.InvalidValue, fmt.Errorf("no converter for resource type %s", typ)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert resource to Terraform representation.
|
2024-05-01 08:22:35 +00:00
|
|
|
err = c.Convert(ctx, key, v, tfroot.Resource)
|
2024-02-16 20:54:38 +00:00
|
|
|
if err != nil {
|
|
|
|
return dyn.InvalidValue, err
|
|
|
|
}
|
|
|
|
|
|
|
|
numResources++
|
|
|
|
|
|
|
|
// Skip traversal of the resource itself.
|
|
|
|
return v, dyn.ErrSkip
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// We explicitly set "resource" to nil to omit it from a JSON encoding.
|
|
|
|
// This is required because the terraform CLI requires >= 1 resources defined
|
|
|
|
// if the "resource" property is used in a .tf.json file.
|
|
|
|
if numResources == 0 {
|
|
|
|
tfroot.Resource = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return tfroot, nil
|
|
|
|
}
|
|
|
|
|
2024-05-01 08:22:35 +00:00
|
|
|
func TerraformToBundle(state *resourcesState, config *config.Root) error {
|
|
|
|
for _, resource := range state.Resources {
|
|
|
|
if resource.Mode != tfjson.ManagedResourceMode {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
for _, instance := range resource.Instances {
|
2024-01-25 11:32:47 +00:00
|
|
|
switch resource.Type {
|
|
|
|
case "databricks_job":
|
|
|
|
if config.Resources.Jobs == nil {
|
|
|
|
config.Resources.Jobs = make(map[string]*resources.Job)
|
|
|
|
}
|
|
|
|
cur := config.Resources.Jobs[resource.Name]
|
2024-05-01 08:22:35 +00:00
|
|
|
if cur == nil {
|
|
|
|
cur = &resources.Job{ModifiedStatus: resources.ModifiedStatusDeleted}
|
|
|
|
}
|
|
|
|
cur.ID = instance.Attributes.ID
|
2024-01-25 11:32:47 +00:00
|
|
|
config.Resources.Jobs[resource.Name] = cur
|
|
|
|
case "databricks_pipeline":
|
|
|
|
if config.Resources.Pipelines == nil {
|
|
|
|
config.Resources.Pipelines = make(map[string]*resources.Pipeline)
|
|
|
|
}
|
|
|
|
cur := config.Resources.Pipelines[resource.Name]
|
2024-05-01 08:22:35 +00:00
|
|
|
if cur == nil {
|
|
|
|
cur = &resources.Pipeline{ModifiedStatus: resources.ModifiedStatusDeleted}
|
|
|
|
}
|
|
|
|
cur.ID = instance.Attributes.ID
|
2024-01-25 11:32:47 +00:00
|
|
|
config.Resources.Pipelines[resource.Name] = cur
|
|
|
|
case "databricks_mlflow_model":
|
|
|
|
if config.Resources.Models == nil {
|
|
|
|
config.Resources.Models = make(map[string]*resources.MlflowModel)
|
|
|
|
}
|
|
|
|
cur := config.Resources.Models[resource.Name]
|
2024-05-01 08:22:35 +00:00
|
|
|
if cur == nil {
|
|
|
|
cur = &resources.MlflowModel{ModifiedStatus: resources.ModifiedStatusDeleted}
|
|
|
|
}
|
|
|
|
cur.ID = instance.Attributes.ID
|
2024-01-25 11:32:47 +00:00
|
|
|
config.Resources.Models[resource.Name] = cur
|
|
|
|
case "databricks_mlflow_experiment":
|
|
|
|
if config.Resources.Experiments == nil {
|
|
|
|
config.Resources.Experiments = make(map[string]*resources.MlflowExperiment)
|
|
|
|
}
|
|
|
|
cur := config.Resources.Experiments[resource.Name]
|
2024-05-01 08:22:35 +00:00
|
|
|
if cur == nil {
|
|
|
|
cur = &resources.MlflowExperiment{ModifiedStatus: resources.ModifiedStatusDeleted}
|
|
|
|
}
|
|
|
|
cur.ID = instance.Attributes.ID
|
2024-01-25 11:32:47 +00:00
|
|
|
config.Resources.Experiments[resource.Name] = cur
|
|
|
|
case "databricks_model_serving":
|
|
|
|
if config.Resources.ModelServingEndpoints == nil {
|
|
|
|
config.Resources.ModelServingEndpoints = make(map[string]*resources.ModelServingEndpoint)
|
|
|
|
}
|
|
|
|
cur := config.Resources.ModelServingEndpoints[resource.Name]
|
2024-05-01 08:22:35 +00:00
|
|
|
if cur == nil {
|
|
|
|
cur = &resources.ModelServingEndpoint{ModifiedStatus: resources.ModifiedStatusDeleted}
|
|
|
|
}
|
|
|
|
cur.ID = instance.Attributes.ID
|
2024-01-25 11:32:47 +00:00
|
|
|
config.Resources.ModelServingEndpoints[resource.Name] = cur
|
|
|
|
case "databricks_registered_model":
|
|
|
|
if config.Resources.RegisteredModels == nil {
|
|
|
|
config.Resources.RegisteredModels = make(map[string]*resources.RegisteredModel)
|
|
|
|
}
|
|
|
|
cur := config.Resources.RegisteredModels[resource.Name]
|
2024-05-01 08:22:35 +00:00
|
|
|
if cur == nil {
|
|
|
|
cur = &resources.RegisteredModel{ModifiedStatus: resources.ModifiedStatusDeleted}
|
|
|
|
}
|
|
|
|
cur.ID = instance.Attributes.ID
|
2024-01-25 11:32:47 +00:00
|
|
|
config.Resources.RegisteredModels[resource.Name] = cur
|
2024-05-31 09:42:25 +00:00
|
|
|
case "databricks_quality_monitor":
|
|
|
|
if config.Resources.QualityMonitors == nil {
|
|
|
|
config.Resources.QualityMonitors = make(map[string]*resources.QualityMonitor)
|
|
|
|
}
|
|
|
|
cur := config.Resources.QualityMonitors[resource.Name]
|
|
|
|
if cur == nil {
|
|
|
|
cur = &resources.QualityMonitor{ModifiedStatus: resources.ModifiedStatusDeleted}
|
|
|
|
}
|
|
|
|
cur.ID = instance.Attributes.ID
|
|
|
|
config.Resources.QualityMonitors[resource.Name] = cur
|
2024-07-31 12:16:28 +00:00
|
|
|
case "databricks_schema":
|
|
|
|
if config.Resources.Schemas == nil {
|
|
|
|
config.Resources.Schemas = make(map[string]*resources.Schema)
|
|
|
|
}
|
|
|
|
cur := config.Resources.Schemas[resource.Name]
|
|
|
|
if cur == nil {
|
|
|
|
cur = &resources.Schema{ModifiedStatus: resources.ModifiedStatusDeleted}
|
|
|
|
}
|
|
|
|
cur.ID = instance.Attributes.ID
|
|
|
|
config.Resources.Schemas[resource.Name] = cur
|
2024-01-25 11:32:47 +00:00
|
|
|
case "databricks_permissions":
|
|
|
|
case "databricks_grants":
|
|
|
|
// Ignore; no need to pull these back into the configuration.
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("missing mapping for %s", resource.Type)
|
|
|
|
}
|
2022-12-15 14:12:47 +00:00
|
|
|
}
|
2024-01-25 11:32:47 +00:00
|
|
|
}
|
2022-12-15 14:12:47 +00:00
|
|
|
|
2024-01-25 11:32:47 +00:00
|
|
|
for _, src := range config.Resources.Jobs {
|
|
|
|
if src.ModifiedStatus == "" && src.ID == "" {
|
|
|
|
src.ModifiedStatus = resources.ModifiedStatusCreated
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, src := range config.Resources.Pipelines {
|
|
|
|
if src.ModifiedStatus == "" && src.ID == "" {
|
|
|
|
src.ModifiedStatus = resources.ModifiedStatusCreated
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, src := range config.Resources.Models {
|
|
|
|
if src.ModifiedStatus == "" && src.ID == "" {
|
|
|
|
src.ModifiedStatus = resources.ModifiedStatusCreated
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, src := range config.Resources.Experiments {
|
|
|
|
if src.ModifiedStatus == "" && src.ID == "" {
|
|
|
|
src.ModifiedStatus = resources.ModifiedStatusCreated
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, src := range config.Resources.ModelServingEndpoints {
|
|
|
|
if src.ModifiedStatus == "" && src.ID == "" {
|
|
|
|
src.ModifiedStatus = resources.ModifiedStatusCreated
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, src := range config.Resources.RegisteredModels {
|
|
|
|
if src.ModifiedStatus == "" && src.ID == "" {
|
|
|
|
src.ModifiedStatus = resources.ModifiedStatusCreated
|
2022-12-15 14:12:47 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-31 09:42:25 +00:00
|
|
|
for _, src := range config.Resources.QualityMonitors {
|
|
|
|
if src.ModifiedStatus == "" && src.ID == "" {
|
|
|
|
src.ModifiedStatus = resources.ModifiedStatusCreated
|
|
|
|
}
|
|
|
|
}
|
2024-07-31 12:16:28 +00:00
|
|
|
for _, src := range config.Resources.Schemas {
|
|
|
|
if src.ModifiedStatus == "" && src.ID == "" {
|
|
|
|
src.ModifiedStatus = resources.ModifiedStatusCreated
|
|
|
|
}
|
|
|
|
}
|
2022-12-15 14:12:47 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|