@@ -19,7 +19,7 @@ package internal
19
19
import (
20
20
"errors"
21
21
"fmt"
22
- log "log/slog"
22
+ "log/slog"
23
23
"os"
24
24
"os/exec"
25
25
"strings"
@@ -56,17 +56,17 @@ func (opts *Generate) Generate() error {
56
56
}
57
57
opts .OutputDir = cwd
58
58
if _ , err = os .Stat (opts .OutputDir ); err == nil {
59
- log .Warn ("Using current working directory to re-scaffold the project" )
60
- log .Warn ("This directory will be cleaned up and all files removed before the re-generation" )
59
+ slog .Warn ("Using current working directory to re-scaffold the project" )
60
+ slog .Warn ("This directory will be cleaned up and all files removed before the re-generation" )
61
61
62
62
// Ensure we clean the correct directory
63
- log .Info ("Cleaning directory" , "dir" , opts .OutputDir )
63
+ slog .Info ("Cleaning directory" , "dir" , opts .OutputDir )
64
64
65
65
// Use an absolute path to target files directly
66
66
cleanupCmd := fmt .Sprintf ("rm -rf %s/*" , opts .OutputDir )
67
67
err = util .RunCmd ("Running cleanup" , "sh" , "-c" , cleanupCmd )
68
68
if err != nil {
69
- log .Error ("Cleanup failed" , "error" , err )
69
+ slog .Error ("Cleanup failed" , "error" , err )
70
70
return fmt .Errorf ("cleanup failed: %w" , err )
71
71
}
72
72
@@ -77,7 +77,7 @@ func (opts *Generate) Generate() error {
77
77
)
78
78
err = util .RunCmd ("Running cleanup" , "sh" , "-c" , cleanupCmd )
79
79
if err != nil {
80
- log .Error ("Cleanup failed" , "error" , err )
80
+ slog .Error ("Cleanup failed" , "error" , err )
81
81
return fmt .Errorf ("cleanup failed: %w" , err )
82
82
}
83
83
}
@@ -123,13 +123,13 @@ func (opts *Generate) Generate() error {
123
123
124
124
// Run make targets to ensure the project is properly set up.
125
125
// These steps are performed on a best-effort basis: if any of the targets fail,
126
- // we log a warning to inform the user, but we do not stop the process or return an error.
126
+ // we slog a warning to inform the user, but we do not stop the process or return an error.
127
127
// This is to avoid blocking the migration flow due to non-critical issues during setup.
128
128
targets := []string {"manifests" , "generate" , "fmt" , "vet" , "lint-fix" }
129
129
for _ , target := range targets {
130
130
err := util .RunCmd (fmt .Sprintf ("Running make %s" , target ), "make" , target )
131
131
if err != nil {
132
- log .Warn ("make target failed" , "target" , target , "error" , err )
132
+ slog .Warn ("make target failed" , "target" , target , "error" , err )
133
133
}
134
134
}
135
135
@@ -220,7 +220,7 @@ func migrateGrafanaPlugin(s store.Store, src, des string) error {
220
220
var grafanaPlugin struct {}
221
221
err := s .Config ().DecodePluginConfig (plugin .KeyFor (v1alpha.Plugin {}), grafanaPlugin )
222
222
if errors .As (err , & config.PluginKeyNotFoundError {}) {
223
- log .Info ("Grafana plugin not found, skipping migration" )
223
+ slog .Info ("Grafana plugin not found, skipping migration" )
224
224
return nil
225
225
} else if err != nil {
226
226
return fmt .Errorf ("failed to decode grafana plugin config: %w" , err )
@@ -241,7 +241,7 @@ func migrateAutoUpdatePlugin(s store.Store) error {
241
241
var autoUpdatePlugin struct {}
242
242
err := s .Config ().DecodePluginConfig (plugin .KeyFor (autoupdate.Plugin {}), autoUpdatePlugin )
243
243
if errors .As (err , & config.PluginKeyNotFoundError {}) {
244
- log .Info ("Auto Update plugin not found, skipping migration" )
244
+ slog .Info ("Auto Update plugin not found, skipping migration" )
245
245
return nil
246
246
} else if err != nil {
247
247
return fmt .Errorf ("failed to decode autoupdate plugin config: %w" , err )
@@ -259,7 +259,7 @@ func migrateDeployImagePlugin(s store.Store) error {
259
259
var deployImagePlugin v1alpha1.PluginConfig
260
260
err := s .Config ().DecodePluginConfig (plugin .KeyFor (v1alpha1.Plugin {}), & deployImagePlugin )
261
261
if errors .As (err , & config.PluginKeyNotFoundError {}) {
262
- log .Info ("Deploy-image plugin not found, skipping migration" )
262
+ slog .Info ("Deploy-image plugin not found, skipping migration" )
263
263
return nil
264
264
} else if err != nil {
265
265
return fmt .Errorf ("failed to decode deploy-image plugin config: %w" , err )
@@ -300,7 +300,7 @@ func getInitArgs(s store.Store) []string {
300
300
// Replace outdated plugins and exit after the first replacement
301
301
for i , plg := range plugins {
302
302
if newPlugin , exists := outdatedPlugins [plg ]; exists {
303
- log .Warn ("We checked that your PROJECT file is configured with deprecated layout. " +
303
+ slog .Warn ("We checked that your PROJECT file is configured with deprecated layout. " +
304
304
"However, we will try our best to re-generate the project using new one" ,
305
305
"deprecated_layout" , plg ,
306
306
"new_layout" , newPlugin )
@@ -503,8 +503,8 @@ func hasHelmPlugin(cfg store.Store) bool {
503
503
if errors .As (err , & config.PluginKeyNotFoundError {}) {
504
504
return false
505
505
}
506
- // Log other errors if needed
507
- log .Error ("error decoding Helm plugin config" , "error" , err )
506
+ // slog other errors if needed
507
+ slog .Error ("error decoding Helm plugin config" , "error" , err )
508
508
return false
509
509
}
510
510
0 commit comments