44 "context"
55 "os"
66 "path/filepath"
7- "sort"
87
98 "github.com/databricks/cli/bundle"
109 "github.com/databricks/cli/bundle/config"
@@ -13,6 +12,7 @@ import (
1312 "github.com/databricks/cli/libs/diag"
1413 "github.com/databricks/cli/libs/log"
1514 "github.com/databricks/cli/libs/python"
15+ "github.com/databricks/cli/libs/utils"
1616)
1717
1818func Prepare () bundle.Mutator {
@@ -36,7 +36,7 @@ func (m *prepare) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
3636 removeFolders := make (map [string ]bool , len (b .Config .Artifacts ))
3737 cleanupWheelFolders := make (map [string ]bool , len (b .Config .Artifacts ))
3838
39- for _ , artifactName := range sortedKeys (b .Config .Artifacts ) {
39+ for _ , artifactName := range utils . SortedKeys (b .Config .Artifacts ) {
4040 artifact := b .Config .Artifacts [artifactName ]
4141 b .Metrics .AddBoolValue (metrics .ArtifactBuildCommandIsSet , artifact .BuildCommand != "" )
4242 b .Metrics .AddBoolValue (metrics .ArtifactFilesIsSet , len (artifact .Files ) != 0 )
@@ -89,14 +89,14 @@ func (m *prepare) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
8989 return diags
9090 }
9191
92- for _ , dir := range sortedKeys (removeFolders ) {
92+ for _ , dir := range utils . SortedKeys (removeFolders ) {
9393 err := os .RemoveAll (dir )
9494 if err != nil {
9595 log .Infof (ctx , "Failed to remove %s: %s" , dir , err )
9696 }
9797 }
9898
99- for _ , dir := range sortedKeys (cleanupWheelFolders ) {
99+ for _ , dir := range utils . SortedKeys (cleanupWheelFolders ) {
100100 log .Infof (ctx , "Cleaning up Python build artifacts in %s" , dir )
101101 python .CleanupWheelFolder (dir )
102102 }
@@ -140,12 +140,3 @@ func InsertPythonArtifact(ctx context.Context, b *bundle.Bundle) error {
140140
141141 return nil
142142}
143-
144- func sortedKeys [T any ](m map [string ]T ) []string {
145- keys := make ([]string , 0 , len (m ))
146- for k := range m {
147- keys = append (keys , k )
148- }
149- sort .Strings (keys )
150- return keys
151- }
0 commit comments