Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/connector/common/common_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"text/template"
"time"

Expand Down Expand Up @@ -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())
Expand Down
10 changes: 8 additions & 2 deletions internal/connector/common/resources_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package common

import (
"fmt"
"maps"
"net/http"
"slices"

"github.com/pingidentity/pingcli/internal/logger"
)
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
Loading