-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nexus Endpoint resource #221
base: main
Are you sure you want to change the base?
Conversation
worker_target_spec = { | ||
namespace_id = temporalcloud_namespace.target_namespace.id | ||
task_queue = "terraform-task-queue" | ||
} | ||
allowed_caller_namespaces = [ | ||
temporalcloud_namespace.caller_namespace.id, | ||
temporalcloud_namespace.caller_namespace_2.id, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine but I'm wondering if it'd be better to make the API a little more future-proof. Here's an example:
target = {
type = "worker"
namespace_id = temporalcloud_namespace.target_namespace.id
task_queue = "terraform-task-queue"
}
allowed_callers = [
{
type = "namespace"
namespace_id = "..."
}
]
But what you have is probably better for type safety.
Let's keep it as is.
Optional: true, | ||
Sensitive: true, | ||
}, | ||
"worker_target_spec": schema.SingleNestedAttribute{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just call this worker_target
?
} | ||
|
||
func getPolicySpecsFromModel(_ context.Context, model *nexusEndpointResourceModel) ([]*nexusv1.EndpointPolicySpec, diag.Diagnostics) { | ||
policySpecs := make([]*nexusv1.EndpointPolicySpec, 0, len(model.AllowedCallerNamespaces.Elements())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a sorted set? Can we ensure that nothing happens if the set elements are arbitrarily ordered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terraform sets are unordered
Name types.String `tfsdk:"name"` | ||
Description types.String `tfsdk:"description"` | ||
WorkerTargetSpec types.Object `tfsdk:"worker_target_spec"` | ||
AllowedCallerNamespaces types.Set `tfsdk:"allowed_caller_namespaces"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make these real Go types? The TF type system will know how to do the conversion to/from go types for us. (same goes for the structs below)
"description": schema.StringAttribute{ | ||
Description: "The description for the Nexus endpoint.", | ||
Optional: true, | ||
Sensitive: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is description meant to be marked as sensitive here?
Required: true, | ||
}, | ||
"allowed_caller_namespaces": schema.SetAttribute{ | ||
Description: "Namespace(s) that are allowed to call this Endpoint.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description: "Namespace(s) that are allowed to call this Endpoint.", | |
Description: "Namespace Id(s) that are allowed to call this Endpoint.", |
Timeouts timeouts.Value `tfsdk:"timeouts"` | ||
} | ||
|
||
nexusEndpointWorkerTargetModel struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This object and the Policy object are oneof
s in the API. Do we want to follow suit here and wrap these in an object? That way if a new oneof
option is added we can add it as another field in the wrapping struct?
Target: {
WorkerTarget: {...}
}
Policy: {
AllowedCallerNamesoaces: [...]
}
Closes #219