Skip to content

Commit

Permalink
resource/migration: fixed version warning when no change (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored Apr 20, 2023
1 parent baa167b commit ae1e34e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/provider/atlas_migration_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ func (d *MigrationDataSource) Read(ctx context.Context, req datasource.ReadReque
}
data.Status = types.String{Value: r.Status}
if r.Status == "PENDING" && r.Current == noMigration {
data.Current = types.String{Null: true}
data.Current = types.String{Value: ""}
} else {
data.Current = types.String{Value: r.Current}
}
if r.Status == "OK" && r.Next == latestVersion {
data.Next = types.String{Null: true}
data.Next = types.String{Value: ""}
} else {
data.Next = types.String{Value: r.Next}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/atlas_migration_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestAccMigrationDataSource(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.atlas_migration.hello", "id", "migrations?format=atlas"),
resource.TestCheckResourceAttr("data.atlas_migration.hello", "status", "PENDING"),
resource.TestCheckNoResourceAttr("data.atlas_migration.hello", "current"),
resource.TestCheckResourceAttr("data.atlas_migration.hello", "current", ""),
resource.TestCheckResourceAttr("data.atlas_migration.hello", "next", "20221101163823"),
resource.TestCheckResourceAttr("data.atlas_migration.hello", "latest", "20221101165415"),
),
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/atlas_migration_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (r MigrationResource) ValidateConfig(ctx context.Context, req resource.Vali
return
}
resp.Diagnostics.Append(r.validateConfig(ctx, req.Config)...)
if !data.Version.IsUnknown() && data.Version.Value == "" {
if data.Version.IsNull() {
resp.Diagnostics.AddAttributeWarning(
path.Root("version"),
"version is unset",
Expand Down Expand Up @@ -224,7 +224,7 @@ func (r *MigrationResource) ModifyPlan(ctx context.Context, req resource.ModifyP
resp.Diagnostics.Append(atlas.ErrorDiagnostic(err, "Failed to read migration status"))
return
}
if plan.Version.IsNull() {
if plan.Version.Value == "" {
v := report.LatestVersion()
plan.Version = types.String{Value: v, Null: v == ""}
}
Expand Down

0 comments on commit ae1e34e

Please sign in to comment.