Skip to content

Commit

Permalink
🐛 fix copyright info when has not owner set
Browse files Browse the repository at this point in the history
  • Loading branch information
Camila Macedo committed Oct 28, 2020
1 parent aeed19b commit b1b373c
Show file tree
Hide file tree
Showing 134 changed files with 144 additions and 79 deletions.
4 changes: 4 additions & 0 deletions pkg/plugin/v2/scaffolds/internal/templates/boilerplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func (f *Boilerplate) SetTemplateDefaults() error {
const apache = `/*
{{ if .Owner -}}
Copyright {{ .Year }} {{ .Owner }}.
{{ else }}
Copyright {{ .Year }}.
{{- end }}
Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -89,5 +91,7 @@ limitations under the License.
const none = `/*
{{ if .Owner -}}
Copyright {{ .Year }} {{ .Owner }}.
{{ else }}
Copyright {{ .Year }}.
{{- end }}
*/`
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type Boilerplate struct {
// Owner is the copyright owner - e.g. "The Kubernetes Authors"
Owner string

// Year is the copyright year
Year string
// Copyright is data add in the License header
Copyright string
}

// SetTemplateDefaults implements input.Template
Expand All @@ -47,8 +47,10 @@ func (f *Boilerplate) SetTemplateDefaults() error {
f.Path = filepath.Join("hack", "boilerplate.go.txt")
}

if f.Year == "" {
f.Year = fmt.Sprintf("%v", time.Now().Year())
if f.Owner != "" {
f.Copyright = fmt.Sprintf("Copyright %v %v", time.Now().Year(), f.Owner)
} else {
f.Copyright = fmt.Sprintf("Copyright %v", time.Now().Year())
}

// Boilerplate given
Expand All @@ -69,9 +71,7 @@ func (f *Boilerplate) SetTemplateDefaults() error {
}

const apache = `/*
{{ if .Owner -}}
Copyright {{ .Year }} {{ .Owner }}.
{{- end }}
{{ .Copyright }}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -87,7 +87,5 @@ limitations under the License.
*/`

const none = `/*
{{ if .Owner -}}
Copyright {{ .Year }} {{ .Owner }}.
{{- end }}
{{ .Copyright }}
*/`
1 change: 1 addition & 0 deletions testdata/project-v2-addon/api/v1/admiral_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v2-addon/api/v1/captain_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v2-addon/api/v1/firstmate_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v2-addon/api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v2-addon/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v2-addon/controllers/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v2-addon/hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
1 change: 1 addition & 0 deletions testdata/project-v2-addon/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2020 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

0 comments on commit b1b373c

Please sign in to comment.