-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2453cd4
commit 6d15b15
Showing
22 changed files
with
389 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/databricks/cli/bundle/config/paths" | ||
"github.com/databricks/databricks-sdk-go/service/catalog" | ||
) | ||
|
||
type LakehouseMonitor struct { | ||
// Represents the Input Arguments for Terraform and will get | ||
// converted to a HCL representation for CRUD | ||
*catalog.CreateMonitor | ||
|
||
// This represents the id which is the full name of the monitor | ||
// (catalog_name.schema_name.table_name) that can be used | ||
// as a reference in other resources. This value is returned by terraform. | ||
ID string `json:"id,omitempty" bundle:"readonly"` | ||
|
||
// Path to config file where the resource is defined. All bundle resources | ||
// include this for interpolation purposes. | ||
paths.Paths | ||
|
||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
bundle/deploy/terraform/tfdyn/convert_lakehouse_monitor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tfdyn | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/databricks/cli/bundle/internal/tf/schema" | ||
"github.com/databricks/cli/libs/dyn" | ||
"github.com/databricks/cli/libs/dyn/convert" | ||
"github.com/databricks/cli/libs/log" | ||
) | ||
|
||
func convertLakehouseMonitorResource(ctx context.Context, vin dyn.Value) (dyn.Value, error) { | ||
var substitutions = make(map[string]string) | ||
substitutions["full_name"] = "table_name" | ||
// Normalize the output value to the target schema. | ||
vout, diags := convert.Normalize(schema.ResourceLakehouseMonitor{}, vin, substitutions) | ||
for _, diag := range diags { | ||
log.Debugf(ctx, "lakehouse monitor normalization diagnostic: %s", diag.Summary) | ||
} | ||
|
||
return vout, nil | ||
} | ||
|
||
type lakehouseMonitorConverter struct{} | ||
|
||
func (lakehouseMonitorConverter) Convert(ctx context.Context, key string, vin dyn.Value, out *schema.Resources) error { | ||
vout, err := convertLakehouseMonitorResource(ctx, vin) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Add the converted resource to the output. | ||
out.LakehouseMonitor[key] = vout.AsAny() | ||
|
||
return nil | ||
} | ||
|
||
func init() { | ||
registerConverter("lakehouse_monitor", lakehouseMonitorConverter{}) | ||
} |
47 changes: 47 additions & 0 deletions
47
bundle/deploy/terraform/tfdyn/convert_lakehouse_monitor_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package tfdyn | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/databricks/cli/bundle/config/resources" | ||
"github.com/databricks/cli/bundle/internal/tf/schema" | ||
"github.com/databricks/cli/libs/dyn" | ||
"github.com/databricks/cli/libs/dyn/convert" | ||
"github.com/databricks/databricks-sdk-go/service/catalog" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestConvertLakehouseMonitor(t *testing.T) { | ||
var src = resources.LakehouseMonitor{ | ||
CreateMonitor: &catalog.CreateMonitor{ | ||
FullName: "test_table_name", | ||
AssetsDir: "assets_dir", | ||
OutputSchemaName: "output_schema_name", | ||
InferenceLog: &catalog.MonitorInferenceLogProfileType{ | ||
ModelIdCol: "model_id", | ||
PredictionCol: "test_prediction_col", | ||
ProblemType: "PROBLEM_TYPE_CLASSIFICATION", | ||
}, | ||
}, | ||
} | ||
vin, err := convert.FromTyped(src, dyn.NilValue) | ||
require.NoError(t, err) | ||
ctx := context.Background() | ||
out := schema.NewResources() | ||
err = lakehouseMonitorConverter{}.Convert(ctx, "my_lakehouse_monitor", vin, out) | ||
|
||
require.NoError(t, err) | ||
print(out) | ||
assert.Equal(t, map[string]any{ | ||
"assets_dir": "assets_dir", | ||
"output_schema_name": "output_schema_name", | ||
"table_name": "test_table_name", | ||
"inference_log": map[string]any{ | ||
"model_id_col": "model_id", | ||
"prediction_col": "test_prediction_col", | ||
"problem_type": "PROBLEM_TYPE_CLASSIFICATION", | ||
}, | ||
}, out.LakehouseMonitor["my_lakehouse_monitor"]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.