Skip to content

Use a container ClientContainer for meta interface{} to extend #29

Merged
Didainius merged 11 commits intovmware:mainfrom
Didainius:client-container
Feb 4, 2025
Merged

Use a container ClientContainer for meta interface{} to extend #29
Didainius merged 11 commits intovmware:mainfrom
Didainius:client-container

Conversation

@Didainius
Copy link
Copy Markdown
Contributor

@Didainius Didainius commented Feb 3, 2025

This code contains many search/replace things, but core change is in provider.go

The root thing is that the meta interface{} attribute will be type ClientContainer instead of *VCDClient.
Instead it is:

type ClientContainer struct {
	tmClient *VCDClient
        futureClient *OtherClient <------ not existing now
}

Such approach allows us to expand the meta argument that is used in all SDK method with additional structures that might be required.

The difference for consumption is that it becomes:

vcfaClient := meta.(ClientContainer).tmClient

instead of:

vcdClient := meta.(*VCDClient)

in each SDK consuming

Tests passed without any panics which should confirm that there are no missing replacements.

Signed-off-by: Dainius <Didainius@users.noreply.github.com>
Signed-off-by: Dainius <Didainius@users.noreply.github.com>
… 'Version'

Signed-off-by: Dainius <Didainius@users.noreply.github.com>
Signed-off-by: Dainius <Didainius@users.noreply.github.com>
@Didainius Didainius marked this pull request as ready for review February 3, 2025 15:15
Signed-off-by: Dainius <Didainius@users.noreply.github.com>
Signed-off-by: Dainius <Didainius@users.noreply.github.com>
@Didainius Didainius changed the title Use a container MetaContainer for meta interface{} to extend Use a container ClientContainer for meta interface{} to extend Feb 4, 2025
Signed-off-by: Dainius <Didainius@users.noreply.github.com>
Signed-off-by: Dainius <Didainius@users.noreply.github.com>
Signed-off-by: Dainius <Didainius@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@adambarreiro adambarreiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Dainius <Didainius@users.noreply.github.com>
Copy link
Copy Markdown

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just PR still mentions "meta" :)

@Didainius
Copy link
Copy Markdown
Contributor Author

Looks great, just PR still mentions "meta" :)

The parts of meta interface{} will stay, because this is the form which Terraform SDK uses to pass ClientContainer around all the CRUD functions

@Didainius Didainius merged commit 9c62946 into vmware:main Feb 4, 2025
@Didainius Didainius deleted the client-container branch February 4, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants