Skip to content
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

Allow to customize read attributes in detail fetcher #908

Merged
merged 1 commit into from Aug 4, 2021

Conversation

eliecharra
Copy link
Contributor

Q A
πŸ› Bug fix? no
πŸš€ New feature? no
⚠ Deprecations? no
❌ BC Break no
πŸ”— Related issues none
❓ Documentation contribution doc

Description

With this new approach we can use remove all boilerplate of custom details fetcher bu setting the resolve func in the schema.
For example for a new resource we'll end with the code below instead of creating a custom detail fetcher:

package gcp

import "github.com/cloudskiff/driftctl/pkg/resource"

const GoogleStorageBucketResourceType = "google_storage_bucket"

func initGoogleStorageBucketMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) {
	resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleStorageBucketResourceType, func(res *resource.AbstractResource) map[string]string {
		return map[string]string{
			"name": res.TerraformId(),
		}
	})
}

@eliecharra eliecharra added priority/0 kind/maintenance Refactoring or changes to the workspace labels Aug 3, 2021
@eliecharra eliecharra requested a review from a team August 3, 2021 16:05
@eliecharra eliecharra added this to Review in driftctl Aug 3, 2021
@codecov
Copy link

codecov bot commented Aug 3, 2021

Codecov Report

Merging #908 (18b8f89) into main (75cd450) will decrease coverage by 0.09%.
The diff coverage is 30.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #908      +/-   ##
==========================================
- Coverage   81.70%   81.61%   -0.10%     
==========================================
  Files         233      233              
  Lines        7588     7599      +11     
==========================================
+ Hits         6200     6202       +2     
- Misses       1161     1169       +8     
- Partials      227      228       +1     
Impacted Files Coverage Ξ”
pkg/resource/schemas.go 84.28% <0.00%> (-7.91%) ⬇️
pkg/remote/common/details_fetcher.go 74.07% <57.14%> (-7.75%) ⬇️

@eliecharra eliecharra force-pushed the better_generic_detail_fetcher branch from 7c0e32b to 18b8f89 Compare August 4, 2021 12:23
@eliecharra eliecharra merged commit a8f9b17 into main Aug 4, 2021
@eliecharra eliecharra deleted the better_generic_detail_fetcher branch August 4, 2021 12:36
driftctl automation moved this from Review to Done Aug 4, 2021
driftctl automation moved this from Done to Review Aug 4, 2021
@eliecharra eliecharra moved this from Review to Done in driftctl Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/maintenance Refactoring or changes to the workspace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants