From 7a432d24bfe94e2e88c59c0e8d921e9f435b3ae1 Mon Sep 17 00:00:00 2001 From: Eileen Yu Date: Wed, 4 Sep 2024 12:58:54 -0700 Subject: [PATCH] update metadataanalyzer with built-in aws profile --- .../pkg/metadataanalyzer/analyzer.template | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.build-tools/pkg/metadataanalyzer/analyzer.template b/.build-tools/pkg/metadataanalyzer/analyzer.template index 6177c0050c..b648f94996 100644 --- a/.build-tools/pkg/metadataanalyzer/analyzer.template +++ b/.build-tools/pkg/metadataanalyzer/analyzer.template @@ -129,12 +129,30 @@ func getYamlMetadata(basePath string, pkg string) *map[string]string { func checkMissingMetadata(yamlMetadata *map[string]string, componentMetadata mdutils.MetadataMap) []string { missingMetadata := make([]string, 0) + if yamlMetadata == nil { + return missingMetadata + } + + // use the built-in aws profile, don't need check in the metadata yaml file + usingAWSProfile := false + for key := range *yamlMetadata { + if strings.Contains(strings.ToLower(key), "aws") { + usingAWSProfile = true + break + } + } + // if there is no yaml metadata, then we are not missing anything yet - if yamlMetadata != nil && len(*yamlMetadata) > 0 { + if len(*yamlMetadata) > 0 { for key, md := range componentMetadata { if md.Ignored { continue } + + if usingAWSProfile && (strings.ToLower(key) == "awsaccesskey" || strings.ToLower(key) == "awssecretkey" || strings.ToLower(key) == "awsregion") { + continue + } + lowerKey := strings.ToLower(key) if _, ok := (*yamlMetadata)[lowerKey]; !ok { missingMetadata = append(missingMetadata, key)