Skip to content

Commit 2154a7b

Browse files
authored
Merge pull request #23 from SAP/spdx-license-headers
add command line option to generate license headers in spdx format
2 parents 40d16a7 + 4079442 commit 2154a7b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

scaffold/scaffold.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
type Config struct {
3030
Owner string `json:"owner,omitempty"`
31+
SpdxLicenseHeader bool `json:"spdxLicenseHeader"`
3132
GroupName string `json:"groupName,omitempty"`
3233
GroupVersion string `json:"groupVersion,omitempty"`
3334
Kind string `json:"kind,omitempty"`
@@ -97,6 +98,7 @@ func main() {
9798

9899
pflag.BoolVar(&showVersion, "version", false, "Show version")
99100
pflag.StringVar(&config.Owner, "owner", "SAP SE", "Owner of this project, as written to the license header")
101+
pflag.BoolVar(&config.SpdxLicenseHeader, "spdx-license-header", false, "Whether to write license headers in SPDX format")
100102
pflag.StringVar(&config.GroupName, "group-name", "operator.kyma-project.io", "API group name")
101103
pflag.StringVar(&config.GroupVersion, "group-version", "v1alpha1", "API group version")
102104
pflag.StringVar(&config.Kind, "kind", "", "API kind for the component")

scaffold/templates/hack/boilerplate.go.txt.tpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{{- if .spdxLicenseHeader -}}
2+
/*
3+
SPDX-FileCopyrightText: {{ now.Year }} {{ .owner }}
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
{{ else -}}
17
/*
28
Copyright {{ now.Year }} {{ .owner }}.
39

@@ -12,4 +18,5 @@ distributed under the License is distributed on an "AS IS" BASIS,
1218
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1319
See the License for the specific language governing permissions and
1420
limitations under the License.
15-
*/
21+
*/
22+
{{ end -}}

website/content/en/docs/usage/scaffolder.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Usage: scaffold [options] [output directory]
3030
--version Show version
3131
--owner string Owner of this project, as written to the license header
3232
(default "SAP SE")
33+
--spdx-license-header Whether to write license headers in SPDX format
3334
--group-name string API group name (default "operator.kyma-project.io")
3435
--group-version string API group version (default "v1alpha1")
3536
--kind string API kind for the component

0 commit comments

Comments
 (0)