[DO-169] Modify to add template with Avroid license

This commit is contained in:
Stanislav Gabenov
2024-04-10 14:47:27 +03:00
parent 4caba19b7e
commit 65deee00fd
2 changed files with 17 additions and 34 deletions

21
main.go
View File

@@ -1,19 +1,6 @@
// Copyright 2018 Google LLC
//
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This program ensures source code files have copyright license headers.
// See usage with "addlicense -h".
package main
import (
@@ -54,9 +41,9 @@ var (
ignorePatterns stringSlice
spdx spdxFlag
holder = flag.String("c", "Google LLC", "copyright holder")
license = flag.String("l", "apache", "license type: apache, bsd, mit, mpl")
licensef = flag.String("f", "", "license file")
holder = flag.String("c", "Avroid, Ltd.", "copyright holder")
license = flag.String("l", "commercial", "license type: commercial, apache, bsd, mit, mpl")
licensef = flag.String("f", "", "license file path")
year = flag.String("y", fmt.Sprint(time.Now().Year()), "copyright year(s)")
verbose = flag.Bool("v", false, "verbose mode: print the name of the files that are modified or were skipped")
checkonly = flag.Bool("check", false, "check only mode: verify presence of license headers and exit with non-zero code if missing")

30
tmpl.go
View File

@@ -1,17 +1,3 @@
// Copyright 2018 Google LLC
//
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
@@ -25,6 +11,7 @@ import (
)
var licenseTemplate = map[string]string{
"Commercial": tmplCommercial,
"Apache-2.0": tmplApache,
"MIT": tmplMIT,
"bsd": tmplBSD,
@@ -34,9 +21,10 @@ var licenseTemplate = map[string]string{
// maintain backwards compatibility by mapping legacy license types to their
// SPDX equivalents.
var legacyLicenseTypes = map[string]string{
"apache": "Apache-2.0",
"mit": "MIT",
"mpl": "MPL-2.0",
"commercial": "Commercial",
"apache": "Apache-2.0",
"mit": "MIT",
"mpl": "MPL-2.0",
}
// licenseData specifies the data used to fill out a license template.
@@ -101,6 +89,14 @@ func executeTemplate(t *template.Template, d licenseData, top, mid, bot string)
return out.Bytes(), nil
}
const tmplCommercial = `Copyright {{.Holder}} {{ if .Year }} 2023-{{.Year}}{{ end }}
You can not use the contents of the file in any way without
AVROID, Ltd. written permission.
To obtain such a permit, you should contact AVROID, Ltd.
at https://avroid.ru`
const tmplApache = `Copyright{{ if .Year }} {{.Year}}{{ end }} {{.Holder}}
Licensed under the Apache License, Version 2.0 (the "License");