diff --git a/internal/connector/common/common_utils.go b/internal/connector/common/common_utils.go index 924d1aa2..b54012a7 100644 --- a/internal/connector/common/common_utils.go +++ b/internal/connector/common/common_utils.go @@ -4,6 +4,8 @@ import ( "fmt" "os" "path/filepath" + "slices" + "strings" "text/template" "time" @@ -33,6 +35,11 @@ func WriteFiles(exportableResources []connector.ExportableResource, format, outp continue } + // Sort import blocks by ResourceName + slices.SortFunc(*importBlocks, func(i, j connector.ImportBlock) int { + return strings.Compare(i.ResourceName, j.ResourceName) + }) + l.Debug().Msgf("Generating import file for %s resource...", exportableResource.ResourceType()) outputFileName := fmt.Sprintf("%s.tf", exportableResource.ResourceType()) diff --git a/internal/connector/common/resources_common.go b/internal/connector/common/resources_common.go index 6dde40fe..f01bb25c 100644 --- a/internal/connector/common/resources_common.go +++ b/internal/connector/common/resources_common.go @@ -2,7 +2,9 @@ package common import ( "fmt" + "maps" "net/http" + "slices" "github.com/pingidentity/pingcli/internal/logger" ) @@ -38,9 +40,13 @@ func DataNilError(resourceType string, response *http.Response) error { } func GenerateCommentInformation(data map[string]string) string { + // Get a sorted slice of the keys + keys := slices.Sorted(maps.Keys(data)) + commentInformation := "\n" - for key, value := range data { - commentInformation += fmt.Sprintf("# %s: %s\n", key, value) + for _, key := range keys { + commentInformation += fmt.Sprintf("# %s: %s\n", key, data[key]) } + return commentInformation } diff --git a/internal/connector/pingone/platform/resources/pingone_notification_template_content.go b/internal/connector/pingone/platform/resources/pingone_notification_template_content.go index 6ab702b7..3a05e4ec 100644 --- a/internal/connector/pingone/platform/resources/pingone_notification_template_content.go +++ b/internal/connector/pingone/platform/resources/pingone_notification_template_content.go @@ -185,10 +185,6 @@ func (r *PingOneNotificationTemplateContentResource) getTemplateContentData(temp return nil, common.DataNilError(r.ResourceType(), cursor.HTTPResponse) } - if templateName == management.ENUMTEMPLATENAME_STRONG_AUTHENTICATION { - fmt.Printf("Page data length %d\n", len(embedded.GetContents())) - } - for _, templateContent := range embedded.GetContents() { var ( templateContentId *string @@ -222,7 +218,7 @@ func (r *PingOneNotificationTemplateContentResource) getTemplateContentData(temp templateContentLocale, templateContentLocaleOk = templateContent.TemplateContentVoice.GetLocaleOk() templateContentVariant = templateContent.TemplateContentVoice.GetVariant() default: - l.Warn().Msgf("Template content '%s' for template '%s' is not one of: Push, SMS, Email, or Voice. Skipping export.", *templateContentId, templateName) + l.Warn().Msgf("Template content '%v' for template '%s' is not one of: Push, SMS, Email, or Voice. Skipping export.", templateContent, templateName) continue }