File tree Expand file tree Collapse file tree 4 files changed +41
-4
lines changed
deploy-image/v1alpha1/scaffolds Expand file tree Collapse file tree 4 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ limitations under the License.
17
17
package scaffolds
18
18
19
19
import (
20
+ "errors"
20
21
"fmt"
21
22
"path/filepath"
22
23
"strings"
@@ -79,10 +80,22 @@ func (s *apiScaffolder) Scaffold() error {
79
80
return err
80
81
}
81
82
83
+ // Define the boilerplate file path
84
+ boilerplatePath := filepath .Join ("hack" , "boilerplate.go.txt" )
85
+
82
86
// Load the boilerplate
83
- boilerplate , err := afero .ReadFile (s .fs .FS , filepath . Join ( "hack" , "boilerplate.go.txt" ) )
87
+ boilerplate , err := afero .ReadFile (s .fs .FS , boilerplatePath )
84
88
if err != nil {
85
- return fmt .Errorf ("error scaffolding API/controller: unable to load boilerplate: %w" , err )
89
+ if errors .Is (err , afero .ErrFileNotFound ) {
90
+ log .Warnf ("Unable to find %s : %s .\n " +
91
+ "This file is used to generate the license header in the project.\n " +
92
+ "Note that controller-gen will also use this. Therefore, ensure that you " +
93
+ "add the license file or configure your project accordingly." ,
94
+ boilerplatePath , err )
95
+ boilerplate = []byte ("" )
96
+ } else {
97
+ return fmt .Errorf ("error scaffolding API/controller: unable to load boilerplate: %w" , err )
98
+ }
86
99
}
87
100
88
101
// Initialize the machinery.Scaffold that will write the files to disk
Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ func (s *apiScaffolder) Scaffold() error {
70
70
boilerplate , err := afero .ReadFile (s .fs .FS , hack .DefaultBoilerplatePath )
71
71
if err != nil {
72
72
if errors .Is (err , afero .ErrFileNotFound ) {
73
+ log .Warnf ("Unable to find %s: %s.\n " +
74
+ "This file is used to generate the license header in the project.\n " +
75
+ "Note that controller-gen will also use this. Therefore, ensure that you " +
76
+ "add the license file or configure your project accordingly." ,
77
+ hack .DefaultBoilerplatePath , err )
73
78
boilerplate = []byte ("" )
74
79
} else {
75
80
return fmt .Errorf ("error scaffolding API/controller: unable to load boilerplate: %w" , err )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ limitations under the License.
17
17
package scaffolds
18
18
19
19
import (
20
+ "errors"
20
21
"fmt"
21
22
"strings"
22
23
@@ -114,7 +115,15 @@ func (s *initScaffolder) Scaffold() error {
114
115
115
116
boilerplate , err := afero .ReadFile (s .fs .FS , s .boilerplatePath )
116
117
if err != nil {
117
- return err
118
+ if errors .Is (err , afero .ErrFileNotFound ) {
119
+ log .Warnf ("Unable to find %s: %s.\n " + "This file is used to generate the license header in the project.\n " +
120
+ "Note that controller-gen will also use this. Therefore, ensure that you " +
121
+ "add the license file or configure your project accordingly." ,
122
+ s .boilerplatePath , err )
123
+ boilerplate = []byte ("" )
124
+ } else {
125
+ return fmt .Errorf ("unable to load boilerplate: %w" , err )
126
+ }
118
127
}
119
128
// Initialize the machinery.Scaffold that will write the files to disk
120
129
scaffold = machinery .NewScaffold (s .fs ,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ limitations under the License.
17
17
package scaffolds
18
18
19
19
import (
20
+ "errors"
20
21
"fmt"
21
22
"strings"
22
23
@@ -76,7 +77,16 @@ func (s *webhookScaffolder) Scaffold() error {
76
77
// Load the boilerplate
77
78
boilerplate , err := afero .ReadFile (s .fs .FS , hack .DefaultBoilerplatePath )
78
79
if err != nil {
79
- return fmt .Errorf ("error scaffolding webhook: unable to load boilerplate: %w" , err )
80
+ if errors .Is (err , afero .ErrFileNotFound ) {
81
+ log .Warnf ("Unable to find %s : %s .\n " +
82
+ "This file is used to generate the license header in the project.\n " +
83
+ "Note that controller-gen will also use this. Therefore, ensure that you " +
84
+ "add the license file or configure your project accordingly." ,
85
+ hack .DefaultBoilerplatePath , err )
86
+ boilerplate = []byte ("" )
87
+ } else {
88
+ return fmt .Errorf ("error scaffolding webhook: unable to load boilerplate: %w" , err )
89
+ }
80
90
}
81
91
82
92
// Initialize the machinery.Scaffold that will write the files to disk
You can’t perform that action at this time.
0 commit comments