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 67f91f7 commit e0b96f4
Show file tree
Hide file tree
Showing 65 changed files with 79 additions and 83 deletions.
18 changes: 8 additions & 10 deletions pkg/plugin/v2/scaffolds/internal/templates/boilerplate.go
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 }}
*/`
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 }}
*/`
2 changes: 1 addition & 1 deletion testdata/project-v2-addon/api/v1/admiral_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2-addon/api/v1/captain_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2-addon/api/v1/firstmate_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2-addon/api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
2 changes: 1 addition & 1 deletion 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,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2-addon/controllers/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2-addon/hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2-addon/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
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,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
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,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
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,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
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,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
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,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
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,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
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,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes authors.
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.
Expand Down

0 comments on commit e0b96f4

Please sign in to comment.