Skip to content

Commit

Permalink
compute flow diffs WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickcping committed Feb 20, 2024
1 parent efe3c34 commit 2c6085e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ var _ xattr.TypeWithValidate = ParsedType{}

type ParsedType struct {
basetypes.StringType
ImportFile bool
// ... potentially other fields ...
davinci.ExportCmpOpts

Check failure on line 23 in internal/framework/customtypes/davinciexporttype/parsed_type.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: davinci.ExportCmpOpts
}

func (t ParsedType) Equal(o attr.Type) bool {
Expand All @@ -40,8 +40,8 @@ func (t ParsedType) String() string {
func (t ParsedType) ValueFromString(ctx context.Context, in basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics) {
// ParsedValue defined in the value type section
value := ParsedValue{
StringValue: in,
ImportFile: t.ImportFile,
StringValue: in,
ExportCmpOpts: t.ExportCmpOpts,
}

return value, nil
Expand Down Expand Up @@ -144,7 +144,7 @@ func (t ParsedType) Validate(ctx context.Context, in tftypes.Value, path path.Pa
IgnoreConfig: true,
IgnoreDesignerCues: true,
IgnoreEnvironmentMetadata: true,
IgnoreUnmappedProperties: !t.ImportFile,
IgnoreUnmappedProperties: false,
IgnoreVersionMetadata: true,
IgnoreFlowMetadata: true,
}); !ok {
Expand Down
14 changes: 7 additions & 7 deletions internal/framework/customtypes/davinciexporttype/parsed_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var _ basetypes.StringValuableWithSemanticEquals = ParsedValue{}
type ParsedValue struct {
basetypes.StringValue
// ... potentially other fields ...
ImportFile bool
davinci.ExportCmpOpts

Check failure on line 21 in internal/framework/customtypes/davinciexporttype/parsed_value.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: davinci.ExportCmpOpts
}

func (v ParsedValue) Equal(o attr.Value) bool {
Expand Down Expand Up @@ -76,12 +76,12 @@ func (v ParsedValue) StringSemanticEquals(ctx context.Context, newValuable baset

// Check whether the flows are equal, ignoring environment metadata and designer UI cues. Just the flow configuration
return davinci.FlowEqual(priorFlow, newFlow, davinci.ExportCmpOpts{

Check failure on line 78 in internal/framework/customtypes/davinciexporttype/parsed_value.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: davinci.FlowEqual

Check failure on line 78 in internal/framework/customtypes/davinciexporttype/parsed_value.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: davinci.ExportCmpOpts
IgnoreConfig: false,
IgnoreDesignerCues: true,
IgnoreEnvironmentMetadata: !v.ImportFile,
IgnoreUnmappedProperties: true,
IgnoreVersionMetadata: true,
IgnoreFlowMetadata: true,
IgnoreConfig: v.IgnoreConfig,
IgnoreDesignerCues: v.IgnoreDesignerCues,
IgnoreEnvironmentMetadata: v.IgnoreEnvironmentMetadata,
IgnoreUnmappedProperties: v.IgnoreUnmappedProperties,
IgnoreVersionMetadata: v.IgnoreVersionMetadata,
IgnoreFlowMetadata: v.IgnoreFlowMetadata,
}), diags
}

Expand Down
12 changes: 3 additions & 9 deletions internal/service/davinci/resource_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,29 +199,23 @@ func (r *FlowResource) Schema(ctx context.Context, req resource.SchemaRequest, r
Required: true,
//Sensitive: true,

CustomType: davinciexporttype.ParsedType{
ImportFile: true,
},
CustomType: davinciexporttype.ParsedType{},
},

"flow_configuration_json": schema.StringAttribute{
Description: framework.SchemaAttributeDescriptionFromMarkdown("The parsed configuration of the DaVinci Flow import JSON. Drift is calculated based on this attribute.").Description,
Computed: true,
//Sensitive: true,

CustomType: davinciexporttype.ParsedType{
ImportFile: false,
},
CustomType: davinciexporttype.ParsedType{},
},

"flow_export_json": schema.StringAttribute{
Description: framework.SchemaAttributeDescriptionFromMarkdown("The DaVinci Flow export in raw JSON format following successful import, including target environment metadata.").Description,
Computed: true,
//Sensitive: true,

CustomType: davinciexporttype.ParsedType{
ImportFile: false,
},
CustomType: davinciexporttype.ParsedType{},
},

"deploy": schema.BoolAttribute{
Expand Down

0 comments on commit 2c6085e

Please sign in to comment.