Skip to content

Commit d14a187

Browse files
authored
add cr id in namespace datasource (#349)
* add cr id in namespace datasource * update doc * fix test
1 parent 5788d9c commit d14a187

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

docs/data-sources/namespace.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ output "namespace" {
5858
- `api_key_auth` (Boolean) If true, Temporal Cloud will use API key authentication for this namespace. If false, mutual TLS (mTLS) authentication will be used.
5959
- `certificate_filters` (Attributes List) A list of filters to apply to client certificates when initiating a connection Temporal Cloud. If present, connections will only be allowed from client certificates whose distinguished name properties match at least one of the filters. (see [below for nested schema](#nestedatt--certificate_filters))
6060
- `codec_server` (Attributes) A codec server is used by the Temporal Cloud UI to decode payloads for all users interacting with this namespace, even if the workflow history itself is encrypted. (see [below for nested schema](#nestedatt--codec_server))
61+
- `connectivity_rule_ids` (List of String) The IDs of the connectivity rules for this namespace.
6162
- `custom_search_attributes` (Map of String) The custom search attributes to use for the namespace.
6263
- `last_modified_time` (String) The date and time when the namespace was last modified. Will not be set if the namespace has never been modified.
6364
- `private_connectivities` (Attributes List) The private connectivities for the namespace, if any. (see [below for nested schema](#nestedatt--private_connectivities))

docs/data-sources/namespaces.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Optional:
4848
- `api_key_auth` (Boolean) If true, Temporal Cloud will use API key authentication for this namespace. If false, mutual TLS (mTLS) authentication will be used.
4949
- `certificate_filters` (Attributes List) A list of filters to apply to client certificates when initiating a connection Temporal Cloud. If present, connections will only be allowed from client certificates whose distinguished name properties match at least one of the filters. (see [below for nested schema](#nestedatt--namespaces--certificate_filters))
5050
- `codec_server` (Attributes) A codec server is used by the Temporal Cloud UI to decode payloads for all users interacting with this namespace, even if the workflow history itself is encrypted. (see [below for nested schema](#nestedatt--namespaces--codec_server))
51+
- `connectivity_rule_ids` (List of String) The IDs of the connectivity rules for this namespace.
5152
- `custom_search_attributes` (Map of String) The custom search attributes to use for the namespace.
5253
- `last_modified_time` (String) The date and time when the namespace was last modified. Will not be set if the namespace has never been modified.
5354
- `private_connectivities` (Attributes List) The private connectivities for the namespace, if any. (see [below for nested schema](#nestedatt--namespaces--private_connectivities))

internal/provider/namespaces_datasource.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type (
5454
Limits types.Object `tfsdk:"limits"`
5555
CreatedTime types.String `tfsdk:"created_time"`
5656
LastModifiedTime types.String `tfsdk:"last_modified_time"`
57+
ConnectivityRuleIds types.List `tfsdk:"connectivity_rule_ids"`
5758
}
5859

5960
endpointsDataModel struct {
@@ -275,6 +276,12 @@ func namespaceDataSourceSchema(idRequired bool) map[string]schema.Attribute {
275276
Optional: true,
276277
Description: "The date and time when the namespace was last modified. Will not be set if the namespace has never been modified.",
277278
},
279+
"connectivity_rule_ids": schema.ListAttribute{
280+
Computed: true,
281+
Optional: true,
282+
Description: "The IDs of the connectivity rules for this namespace.",
283+
ElementType: types.StringType,
284+
},
278285
}
279286
}
280287

@@ -502,5 +509,21 @@ func namespaceToNamespaceDataModel(ctx context.Context, ns *namespacev1.Namespac
502509
}
503510
namespaceModel.Limits = limits
504511

512+
// Initialize ConnectivityRuleIds with proper type
513+
connectivityRuleIds := types.ListNull(types.StringType)
514+
if len(ns.GetSpec().GetConnectivityRuleIds()) > 0 {
515+
var connectivityRuleIdStrs []attr.Value
516+
for _, id := range ns.GetSpec().GetConnectivityRuleIds() {
517+
connectivityRuleIdStrs = append(connectivityRuleIdStrs, types.StringValue(id))
518+
}
519+
connectivityRuleIdsList, listDiags := types.ListValue(types.StringType, connectivityRuleIdStrs)
520+
diags.Append(listDiags...)
521+
if diags.HasError() {
522+
return nil, diags
523+
}
524+
connectivityRuleIds = connectivityRuleIdsList
525+
}
526+
namespaceModel.ConnectivityRuleIds = connectivityRuleIds
527+
505528
return namespaceModel, nil
506529
}

0 commit comments

Comments
 (0)