@@ -19,7 +19,7 @@ package scaffolds
19
19
import (
20
20
"errors"
21
21
"fmt"
22
- log "log/slog"
22
+ "log/slog"
23
23
"path/filepath"
24
24
25
25
"github.com/spf13/afero"
@@ -65,13 +65,13 @@ func (s *apiScaffolder) InjectFS(fs machinery.Filesystem) {
65
65
66
66
// Scaffold implements cmdutil.Scaffolder
67
67
func (s * apiScaffolder ) Scaffold () error {
68
- log .Info ("Writing scaffold for you to edit..." )
68
+ slog .Info ("Writing scaffold for you to edit..." )
69
69
70
70
// Load the boilerplate
71
71
boilerplate , err := afero .ReadFile (s .fs .FS , hack .DefaultBoilerplatePath )
72
72
if err != nil {
73
73
if errors .Is (err , afero .ErrFileNotFound ) {
74
- log .Warn ("Unable to find boilerplate file." +
74
+ slog .Warn ("Unable to find boilerplate file." +
75
75
"This file is used to generate the license header in the project.\n " +
76
76
"Note that controller-gen will also use this. Therefore, ensure that you " +
77
77
"add the license file or configure your project accordingly." ,
@@ -143,24 +143,25 @@ func (s *apiScaffolder) discoverFeatureGates() []string {
143
143
apiDir := "api"
144
144
if s .config .IsMultiGroup () && s .resource .Group != "" {
145
145
apiDir = filepath .Join ("api" , s .resource .Group )
146
+ }
146
147
147
148
// Check if the directory exists before trying to parse it
148
149
if _ , err := s .fs .FS .Stat (apiDir ); err != nil {
149
- log . Debugf ("API directory %s does not exist yet, skipping feature gate discovery" , apiDir )
150
+ slog . Debug ("API directory does not exist yet, skipping feature gate discovery" , "apiDir " , apiDir )
150
151
return []string {}
151
152
}
152
153
153
154
markers , err := parser .ParseDirectory (apiDir )
154
155
if err != nil {
155
- log . Debugf ("Failed to parse feature gates from %s: %v" , apiDir , err )
156
+ slog . Debug ("Failed to parse feature gates from directory" , "apiDir" , apiDir , "error" , err )
156
157
return []string {}
157
158
}
158
159
159
160
featureGates := machinery .ExtractFeatureGates (markers )
160
161
if len (featureGates ) > 0 {
161
- log . Infof ("Discovered feature gates: %v " , featureGates )
162
+ slog . Info ("Discovered feature gates" , "featureGates " , featureGates )
162
163
} else {
163
- log . Debugf ("No feature gates found in %s " , apiDir )
164
+ slog . Debug ("No feature gates found in directory" , "apiDir " , apiDir )
164
165
}
165
166
166
167
return featureGates
0 commit comments