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

Feat: azapi - not all resources support tags #210

Merged
merged 4 commits into from
Dec 4, 2024

Conversation

TomerHeber
Copy link
Collaborator

Based on Microsoft's documentation a whitelist of resources was created.

Only azapi types (type field) in the white list will be tagged.

fixes #209

@TomerHeber TomerHeber self-assigned this Nov 30, 2024
@@ -0,0 +1,42 @@
from io import StringIO
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is the utility for parsing the html file and building the white list.

once sync.Once
)

func getAzureTaggableResources() map[string]bool {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

parse the csv file...

@@ -51,14 +84,65 @@ func GetTagIdByResource(resourceType string) string {
return ""
}

func IsSupportedResource(resourceType string) bool {
func isSimpleStringLiteral(tokens hclwrite.Tokens) (string, bool) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

extracts the 'type' value.

return "", false
}

func azureTypeIsTaggable(resource hclwrite.Block) bool {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

check based on the white list if the 'type' is taggable.

}

resource "azapi_resource" "example4" {
type = "Microsoft.App/containerApps/authConfigs@2024-03-01"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

authConfig isn't taggable.

}

resource "azapi_resource" "example4" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should remain untaggable.

Copy link
Member

@eranelbaz eranelbaz left a comment

Choose a reason for hiding this comment

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

All in all looks good
Left couple of thoughts ideas, LMK WDYT

.gitignore Outdated Show resolved Hide resolved
internal/providers/providers.go Show resolved Hide resolved
internal/providers/providers.go Show resolved Hide resolved
internal/providers/providers.go Outdated Show resolved Hide resolved
azapi/generate.py Show resolved Hide resolved
azapi/README.md Outdated Show resolved Hide resolved
@TomerHeber TomerHeber requested a review from eranelbaz December 2, 2024 20:15
@TomerHeber TomerHeber merged commit 08fe5ac into master Dec 4, 2024
9 checks passed
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.

azapi - not all resources support tags
2 participants