Skip to content

Commit

Permalink
Don't need lastUpdatedAt or hasUndeployedChanges, they just create fa…
Browse files Browse the repository at this point in the history
…lse positives in tf plan
  • Loading branch information
danafallon committed Jul 30, 2024
1 parent 7fb1ecb commit 2581529
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 41 deletions.
12 changes: 5 additions & 7 deletions internal/provider/deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ func (r *DeploymentResource) Schema(ctx context.Context, req resource.SchemaRequ
resp.Schema = schema.Schema{
MarkdownDescription: "Artie Deployment resource",
Attributes: map[string]schema.Attribute{
"uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"company_uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"name": schema.StringAttribute{Required: true},
"status": schema.StringAttribute{Computed: true, Optional: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"destination_uuid": schema.StringAttribute{Computed: true, Optional: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"last_updated_at": schema.StringAttribute{Computed: true},
"has_undeployed_changes": schema.BoolAttribute{Computed: true},
"uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"company_uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"name": schema.StringAttribute{Required: true},
"status": schema.StringAttribute{Computed: true, Optional: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"destination_uuid": schema.StringAttribute{Computed: true, Optional: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"source": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
Expand Down
1 change: 0 additions & 1 deletion internal/provider/destination_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (r *DestinationResource) Schema(ctx context.Context, req resource.SchemaReq
"ssh_tunnel_uuid": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"name": schema.StringAttribute{Required: true},
"label": schema.StringAttribute{Optional: true},
"last_updated_at": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
"config": schema.SingleNestedAttribute{
Required: true,
Attributes: map[string]schema.Attribute{
Expand Down
18 changes: 8 additions & 10 deletions internal/provider/models/deployment_api_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ type DeploymentAPIResponse struct {
}

type DeploymentAPIModel struct {
UUID string `json:"uuid"`
CompanyUUID string `json:"companyUUID"`
Name string `json:"name"`
Status string `json:"status"`
LastUpdatedAt string `json:"lastUpdatedAt"`
DestinationUUID string `json:"destinationUUID"`
HasUndeployedChanges bool `json:"hasUndeployedChanges"`
Source SourceAPIModel `json:"source"`
AdvancedSettings *DeploymentAdvancedSettingsAPIModel `json:"advancedSettings"`
DestinationConfig DestinationConfigAPIModel `json:"uniqueConfig"`
UUID string `json:"uuid"`
CompanyUUID string `json:"companyUUID"`
Name string `json:"name"`
Status string `json:"status"`
DestinationUUID string `json:"destinationUUID"`
Source SourceAPIModel `json:"source"`
AdvancedSettings *DeploymentAdvancedSettingsAPIModel `json:"advancedSettings"`
DestinationConfig DestinationConfigAPIModel `json:"uniqueConfig"`
}

type SourceAPIModel struct {
Expand Down
18 changes: 8 additions & 10 deletions internal/provider/models/deployment_resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ package models
import "github.com/hashicorp/terraform-plugin-framework/types"

type DeploymentResourceModel struct {
UUID types.String `tfsdk:"uuid"`
CompanyUUID types.String `tfsdk:"company_uuid"`
Name types.String `tfsdk:"name"`
Status types.String `tfsdk:"status"`
LastUpdatedAt types.String `tfsdk:"last_updated_at"`
DestinationUUID types.String `tfsdk:"destination_uuid"`
HasUndeployedChanges types.Bool `tfsdk:"has_undeployed_changes"`
Source *SourceModel `tfsdk:"source"`
AdvancedSettings *DeploymentAdvancedSettingsModel `tfsdk:"advanced_settings"`
DestinationConfig *DeploymentDestinationConfigModel `tfsdk:"destination_config"`
UUID types.String `tfsdk:"uuid"`
CompanyUUID types.String `tfsdk:"company_uuid"`
Name types.String `tfsdk:"name"`
Status types.String `tfsdk:"status"`
DestinationUUID types.String `tfsdk:"destination_uuid"`
Source *SourceModel `tfsdk:"source"`
AdvancedSettings *DeploymentAdvancedSettingsModel `tfsdk:"advanced_settings"`
DestinationConfig *DeploymentDestinationConfigModel `tfsdk:"destination_config"`
}

type SourceModel struct {
Expand Down
1 change: 0 additions & 1 deletion internal/provider/models/destination_api_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type DestinationAPIModel struct {
CompanyUUID string `json:"companyUUID"`
Name string `json:"name"`
Label string `json:"label"`
LastUpdatedAt string `json:"lastUpdatedAt"`
SSHTunnelUUID string `json:"sshTunnelUUID"`
Config DestinationSharedConfigAPIModel `json:"sharedConfig"`
}
Expand Down
1 change: 0 additions & 1 deletion internal/provider/models/destination_resource_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ type DestinationResourceModel struct {
SSHTunnelUUID types.String `tfsdk:"ssh_tunnel_uuid"`
Name types.String `tfsdk:"name"`
Label types.String `tfsdk:"label"`
LastUpdatedAt types.String `tfsdk:"last_updated_at"`
Config *DestinationSharedConfigModel `tfsdk:"config"`
}

Expand Down
14 changes: 5 additions & 9 deletions internal/provider/models/translate_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ func DeploymentAPIToResourceModel(apiModel DeploymentAPIModel, resourceModel *De
resourceModel.CompanyUUID = types.StringValue(apiModel.CompanyUUID)
resourceModel.Name = types.StringValue(apiModel.Name)
resourceModel.Status = types.StringValue(apiModel.Status)
resourceModel.LastUpdatedAt = types.StringValue(apiModel.LastUpdatedAt)
resourceModel.HasUndeployedChanges = types.BoolValue(apiModel.HasUndeployedChanges)
resourceModel.DestinationUUID = types.StringValue(apiModel.DestinationUUID)

tables := []TableModel{}
Expand Down Expand Up @@ -158,13 +156,11 @@ func DeploymentResourceToAPIModel(resourceModel DeploymentResourceModel) Deploym
}

return DeploymentAPIModel{
UUID: resourceModel.UUID.ValueString(),
CompanyUUID: resourceModel.CompanyUUID.ValueString(),
Name: resourceModel.Name.ValueString(),
Status: resourceModel.Status.ValueString(),
LastUpdatedAt: resourceModel.LastUpdatedAt.ValueString(),
HasUndeployedChanges: resourceModel.HasUndeployedChanges.ValueBool(),
DestinationUUID: resourceModel.DestinationUUID.ValueString(),
UUID: resourceModel.UUID.ValueString(),
CompanyUUID: resourceModel.CompanyUUID.ValueString(),
Name: resourceModel.Name.ValueString(),
Status: resourceModel.Status.ValueString(),
DestinationUUID: resourceModel.DestinationUUID.ValueString(),
Source: SourceAPIModel{
Name: resourceModel.Source.Name.ValueString(),
Config: SourceConfigAPIModel{
Expand Down
2 changes: 0 additions & 2 deletions internal/provider/models/translate_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ func DestinationAPIToResourceModel(apiModel DestinationAPIModel, resourceModel *
resourceModel.CompanyUUID = types.StringValue(apiModel.CompanyUUID)
resourceModel.Name = types.StringValue(apiModel.Name)
resourceModel.Label = types.StringValue(apiModel.Label)
resourceModel.LastUpdatedAt = types.StringValue(apiModel.LastUpdatedAt)
resourceModel.SSHTunnelUUID = types.StringValue(apiModel.SSHTunnelUUID)

resourceModel.Config = &DestinationSharedConfigModel{
Expand Down Expand Up @@ -41,7 +40,6 @@ func DestinationResourceToAPIModel(resourceModel DestinationResourceModel) Desti
CompanyUUID: resourceModel.CompanyUUID.ValueString(),
Name: resourceModel.Name.ValueString(),
Label: resourceModel.Label.ValueString(),
LastUpdatedAt: resourceModel.LastUpdatedAt.ValueString(),
SSHTunnelUUID: sshTunnelUUID,
Config: DestinationSharedConfigAPIModel{
Host: resourceModel.Config.Host.ValueString(),
Expand Down

0 comments on commit 2581529

Please sign in to comment.