Skip to content

Commit

Permalink
Merge pull request #44 from platacard/bugfix/vistibility-state-value
Browse files Browse the repository at this point in the history
bugfix: archival state value
  • Loading branch information
ganievs authored May 7, 2024
2 parents 52e0d8f + d77400c commit 0a3a614
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
13 changes: 13 additions & 0 deletions internal/provider/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package provider

import (
"go.temporal.io/api/enums/v1"
)

var (
ArchivalState = map[string]enums.ArchivalState{
"Unspecified": enums.ARCHIVAL_STATE_UNSPECIFIED,
"Disabled": enums.ARCHIVAL_STATE_DISABLED,
"Enabled": enums.ARCHIVAL_STATE_ENABLED,
}
)
5 changes: 2 additions & 3 deletions internal/provider/namespace_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"go.temporal.io/api/enums/v1"
"go.temporal.io/api/workflowservice/v1"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -158,9 +157,9 @@ func (d *NamespaceDataSource) Read(ctx context.Context, req datasource.ReadReque
OwnerEmail: types.StringValue(ns.NamespaceInfo.GetOwnerEmail()),
Retention: types.Int64Value(int64(ns.Config.WorkflowExecutionRetentionTtl.AsDuration().Hours() / 24)),
ActiveClusterName: types.StringValue(ns.GetReplicationConfig().GetActiveClusterName()),
HistoryArchivalState: types.StringValue(enums.ArchivalState_name[int32(ns.Config.GetHistoryArchivalState())]),
HistoryArchivalState: types.StringValue(ns.Config.GetHistoryArchivalState().String()),
HistoryArchivalUri: types.StringValue(ns.Config.GetHistoryArchivalUri()),
VisibilityArchivalState: types.StringValue(enums.ArchivalState_name[int32(ns.Config.GetVisibilityArchivalState())]),
VisibilityArchivalState: types.StringValue(ns.Config.GetVisibilityArchivalState().String()),
VisibilityArchivalUri: types.StringValue(ns.Config.GetVisibilityArchivalUri()),
IsGlobalNamespace: types.BoolValue(ns.GetIsGlobalNamespace()),
}
Expand Down
15 changes: 8 additions & 7 deletions internal/provider/namespace_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package provider
import (
"context"
"fmt"
"google.golang.org/protobuf/types/known/durationpb"
"time"

"google.golang.org/protobuf/types/known/durationpb"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down Expand Up @@ -185,9 +186,9 @@ func (r *NamespaceResource) Create(ctx context.Context, req resource.CreateReque
OwnerEmail: data.OwnerEmail.ValueString(),
WorkflowExecutionRetentionPeriod: retention,
ActiveClusterName: data.ActiveClusterName.ValueString(),
VisibilityArchivalState: enums.ArchivalState(enums.ArchivalState_value[data.VisibilityArchivalState.ValueString()]),
VisibilityArchivalState: ArchivalState[data.VisibilityArchivalState.ValueString()],
VisibilityArchivalUri: data.VisibilityArchivalUri.ValueString(),
HistoryArchivalState: enums.ArchivalState(enums.ArchivalState_value[data.HistoryArchivalState.ValueString()]),
HistoryArchivalState: ArchivalState[data.HistoryArchivalState.ValueString()],
HistoryArchivalUri: data.HistoryArchivalUri.ValueString(),
IsGlobalNamespace: data.IsGlobalNamespace.ValueBool(),
}
Expand Down Expand Up @@ -252,9 +253,9 @@ func (r *NamespaceResource) Read(ctx context.Context, req resource.ReadRequest,
OwnerEmail: types.StringValue(ns.NamespaceInfo.GetOwnerEmail()),
Retention: types.Int64Value(int64(ns.Config.WorkflowExecutionRetentionTtl.AsDuration().Hours() / 24)),
ActiveClusterName: types.StringValue(ns.GetReplicationConfig().GetActiveClusterName()),
HistoryArchivalState: types.StringValue(enums.ArchivalState_name[int32(ns.Config.GetHistoryArchivalState())]),
HistoryArchivalState: types.StringValue(ns.Config.GetHistoryArchivalState().String()),
HistoryArchivalUri: types.StringValue(ns.Config.GetHistoryArchivalUri()),
VisibilityArchivalState: types.StringValue(enums.ArchivalState_name[int32(ns.Config.GetVisibilityArchivalState())]),
VisibilityArchivalState: types.StringValue(ns.Config.GetVisibilityArchivalState().String()),
VisibilityArchivalUri: types.StringValue(ns.Config.GetVisibilityArchivalUri()),
IsGlobalNamespace: types.BoolValue(ns.GetIsGlobalNamespace()),
}
Expand Down Expand Up @@ -288,9 +289,9 @@ func (r *NamespaceResource) Update(ctx context.Context, req resource.UpdateReque
},
Config: &namespace.NamespaceConfig{
WorkflowExecutionRetentionTtl: retention,
VisibilityArchivalState: enums.ArchivalState(enums.ArchivalState_value[data.VisibilityArchivalState.ValueString()]),
VisibilityArchivalState: ArchivalState[data.VisibilityArchivalState.ValueString()],
VisibilityArchivalUri: data.VisibilityArchivalUri.ValueString(),
HistoryArchivalState: enums.ArchivalState(enums.ArchivalState_value[data.HistoryArchivalState.ValueString()]),
HistoryArchivalState: ArchivalState[data.HistoryArchivalState.ValueString()],
HistoryArchivalUri: data.HistoryArchivalUri.ValueString(),
},
ReplicationConfig: &replication.NamespaceReplicationConfig{
Expand Down

0 comments on commit 0a3a614

Please sign in to comment.