hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
616 stars 450 forks source link

Workload Managment Resource Need More Documentation and seperate namespace to differnete resource #2270

Open orenr2301 opened 2 weeks ago

orenr2301 commented 2 weeks ago

Community Guidelines

Description

For a long time, we waited for the workload management resource so first of all thank you.

Secondly: The doc of the supervisor resource is very light! It just has a simple description of each attribute.

You should take into account, that not everyone who is familiar with Tanzu(tkgs), has expertise in vSpehere. Therefore you need to describe as well, if there are crucial dependencies, and there are.

Use Case(s)

I need to assign more namespaces under one workload management cluster, currently, it's not enabled in your code

Potential Terraform Provider Configuration

For the namespace thing please look at below

resource_vsphere_supervisor.go under *_func resourceVsphereSupervisor() schema.Resource {_**

"namespace": {
                Type:        schema.TypeSet, ==> make it to be  "schema.TypeList" please 
                Optional:    true,
                Description: "List of namespaces associated with the cluster.",
                Elem:        namespaceSchema(),
            },

more say to be it dynamically so we can add multiple blocks

I Suggest to : 1) adding MinItems

"namespace": {
                Type:        schema.TypeSet, ==> make it to be  "schema.TypeList" please 
                Optional:    true,
                **MinItems:**    1, ==> tell it it can have more then one block and its repeatable 
                Description: "List of namespaces associated with the cluster.",
                Elem:        namespaceSchema(),
            },

For not having to call a function and maybe have it more organized, For you your judgment of course

Change the namespace scheme from:

"namespace": {
                Type:        schema.TypeSet,
                Optional:    true,
                Description: "List of namespaces associated with the cluster.",
                Elem:        namespaceSchema(),
            },

To:

"namespace": {
                Type:        schema.TypeList,
                Optional:    true,
                MinItem: 1
                Description: "List of namespaces associated with the cluster.",
                Elem:        &schema.Resource{
                                        Schema: map[string]*schema.Schema{
                                                  "name": {
                                                   Type:        schema.TypeString,
                                                   Required:    true,
                                                  Description: "The name of the namespace.",
                                                 },
                                                "content_libraries": {
                                                Type:        schema.TypeList,
                                                Optional:    true,
                                                Description: "A list of content libraries.",
                                               Elem: &schema.Schema{
                                          Type: schema.TypeString,
                                            },
                                         },
                                           "vm_classes": {
                                           Type:        schema.TypeList,
                                          Optional:    true,
                                          Description: "A list of virtual machine classes.",
                                          Elem: &schema.Schema{
                                               Type: schema.TypeString,
                                    },
                                   },
            },

Also, you can take all of the blocks and create the schema in particular for each block and assign the element without having to have a return function that constructs the scheme back to the Elem key

Also if you would like to do so in addition you can create or have in the beginning some constant that will represent your resource keys/attributes and then use specKey whenever needed based on the scheme structure under the relevant schema

References

No response

github-actions[bot] commented 2 weeks ago

Hello, orenr2301! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.