Repository: GoogleContainerTools/kpt
Pull request #3153 (2022-05-13 02:03:33)

chore: update addlicense to v1.0.1
chore: update addlicense to v1.0.1
    
- Use github.com/justinsb/addlicense to handle makefiles
- Use the same update-license.sh script for kpt and porch
- Rename testdata to testData for consistency
- Fix addlicense to always use the current year on new files

droot: Thank you @karlkfi . Merging this.

Patch:
diff --git a/Makefile b/Makefile
index cd6be768..978fcb84 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@ tidy:
 	go mod tidy
 
 license:
-	GOBIN=$(GOBIN) scripts/update-license.sh
+	scripts/update-license.sh
 
 lint:
 	(which golangci-lint || go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0)
diff --git a/firebase/functions/.eslintrc.js b/firebase/functions/.eslintrc.js
index 973030b2..e4c237e3 100644
--- a/firebase/functions/.eslintrc.js
+++ b/firebase/functions/.eslintrc.js
@@ -1,3 +1,19 @@
+/**
+ * Copyright 2022 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.
+ */
+
 module.exports = {
   root: true,
   env: {
diff --git a/firebase/functions/index.js b/firebase/functions/index.js
index eba5298c..90ec6100 100644
--- a/firebase/functions/index.js
+++ b/firebase/functions/index.js
@@ -1,3 +1,19 @@
+/**
+ * Copyright 2022 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.
+ */
+
 const functions = require("firebase-functions");
 
 
diff --git a/internal/builtins/testData/pkg-with-existing-ctx/in.yaml b/internal/builtins/testdata/pkg-with-existing-ctx/in.yaml
similarity index 100%
rename from internal/builtins/testData/pkg-with-existing-ctx/in.yaml
rename to internal/builtins/testdata/pkg-with-existing-ctx/in.yaml
diff --git a/internal/builtins/testData/pkg-with-existing-ctx/out.yaml b/internal/builtins/testdata/pkg-with-existing-ctx/out.yaml
similarity index 100%
rename from internal/builtins/testData/pkg-with-existing-ctx/out.yaml
rename to internal/builtins/testdata/pkg-with-existing-ctx/out.yaml
diff --git a/internal/builtins/testData/pkg-with-nesting/in.yaml b/internal/builtins/testdata/pkg-with-nesting/in.yaml
similarity index 100%
rename from internal/builtins/testData/pkg-with-nesting/in.yaml
rename to internal/builtins/testdata/pkg-with-nesting/in.yaml
diff --git a/internal/builtins/testData/pkg-with-nesting/out.yaml b/internal/builtins/testdata/pkg-with-nesting/out.yaml
similarity index 100%
rename from internal/builtins/testData/pkg-with-nesting/out.yaml
rename to internal/builtins/testdata/pkg-with-nesting/out.yaml
diff --git a/internal/builtins/testData/pkg-wo-nesting/in.yaml b/internal/builtins/testdata/pkg-wo-nesting/in.yaml
similarity index 100%
rename from internal/builtins/testData/pkg-wo-nesting/in.yaml
rename to internal/builtins/testdata/pkg-wo-nesting/in.yaml
diff --git a/internal/builtins/testData/pkg-wo-nesting/out.yaml b/internal/builtins/testdata/pkg-wo-nesting/out.yaml
similarity index 100%
rename from internal/builtins/testData/pkg-wo-nesting/out.yaml
rename to internal/builtins/testdata/pkg-wo-nesting/out.yaml
diff --git a/internal/util/porch/approval.go b/internal/util/porch/approval.go
index 1a5eb66a..19e49798 100644
--- a/internal/util/porch/approval.go
+++ b/internal/util/porch/approval.go
@@ -1,3 +1,17 @@
+// Copyright 2022 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 porch
 
 import (
diff --git a/package-examples/tenant/namespace.yaml b/package-examples/tenant/namespace.yaml
index 72503847..853aab02 100644
--- a/package-examples/tenant/namespace.yaml
+++ b/package-examples/tenant/namespace.yaml
@@ -1,3 +1,17 @@
+# Copyright 2022 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.
+
 apiVersion: v1
 kind: Namespace
 metadata:
diff --git a/package-examples/tenant/ns-invariant.yaml b/package-examples/tenant/ns-invariant.yaml
index 42070ff5..4991c4f7 100644
--- a/package-examples/tenant/ns-invariant.yaml
+++ b/package-examples/tenant/ns-invariant.yaml
@@ -1,3 +1,17 @@
+# Copyright 2022 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.
+
 apiVersion: fn.kpt.dev/v1alpha1
 kind: StarlarkRun
 metadata:
diff --git a/package-examples/tenant/quota.yaml b/package-examples/tenant/quota.yaml
index 181e211f..5337fe70 100644
--- a/package-examples/tenant/quota.yaml
+++ b/package-examples/tenant/quota.yaml
@@ -1,3 +1,17 @@
+# Copyright 2022 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.
+
 apiVersion: v1
 kind: ResourceQuota
 metadata:
diff --git a/package-examples/tenant/role-binding.yaml b/package-examples/tenant/role-binding.yaml
index 7de67282..d5cbb5e2 100644
--- a/package-examples/tenant/role-binding.yaml
+++ b/package-examples/tenant/role-binding.yaml
@@ -1,3 +1,17 @@
+# Copyright 2022 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.
+
 apiVersion: rbac.authorization.k8s.io/v1beta1
 kind: RoleBinding
 metadata:
diff --git a/package-examples/tenant/service-account.yaml b/package-examples/tenant/service-account.yaml
index 7390ee13..48f5fc88 100644
--- a/package-examples/tenant/service-account.yaml
+++ b/package-examples/tenant/service-account.yaml
@@ -1,3 +1,17 @@
+# Copyright 2022 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.
+
 apiVersion: v1
 kind: ServiceAccount
 metadata:
diff --git a/porch/Makefile b/porch/Makefile
index 1ce66f32..ec23b981 100644
--- a/porch/Makefile
+++ b/porch/Makefile
@@ -152,8 +152,7 @@ porch:
 
 .PHONY: fix-headers
 fix-headers:
-	# TODO: switch to google/addlicense once we have https://github.com/google/addlicense/pull/104
-	go run github.com/justinsb/addlicense@v1.0.1 -c "Google LLC" -l apache --ignore ".build/**" --ignore "**/testdata/**" . 2>/dev/null
+	../scripts/update-license.sh
 
 .PHONY: fix-all
 fix-all: fix-headers fmt tidy
diff --git a/scripts/update-license.sh b/scripts/update-license.sh
index a2e3b73a..05a9710f 100755
--- a/scripts/update-license.sh
+++ b/scripts/update-license.sh
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
 # Copyright 2019 Google LLC
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,13 +13,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# don't add licenses to the site directory, it will break the docs
-# and will add them to the theme which is a submodule (bad)
-which addlicense || go install github.com/google/addlicense@latest
-find . -type f \
-! -path "./site/*" \
-! -path "./docs/*" \
-! -path "**/.expected/results.yaml" \
-! -path "**/testData/*" \
-! -path "**/generated/*" \
-| xargs $GOBIN/addlicense -y 2021 -l apache
+set -o nounset
+set -o errexit
+set -o pipefail
+
+# TODO: switch to google/addlicense once we have https://github.com/google/addlicense/pull/104
+go run github.com/justinsb/addlicense@v1.0.1 \
+  -c "Google LLC" -l apache \
+  --ignore ".build/**" \
+  --ignore "site/**" \
+  --ignore "docs/**" \
+  --ignore "**/.expected/results.yaml" \
+  --ignore "**/testdata/**" \
+  --ignore "**/generated/**" \
+  . 2>&1 | ( grep -v "skipping: " || true )


Test patch:
diff --git a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/diff.patch b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/diff.patch
index 6b29730d..d05d59be 100644
--- a/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/diff.patch
+++ b/e2e/testdata/fn-eval/save-fn/custom-pkg-path/.expected/diff.patch
@@ -12,15 +12,10 @@ index d9e2f05..93c547b 100644
 +    - image: gcr.io/kpt-fn/set-namespace:v0.1.3
 +      configPath: fn-config.yaml
 diff --git a/sub-pkg/fn-config.yaml b/sub-pkg/fn-config.yaml
-index 3b3dc0f..670db5a 100644
+index 6db3003..a04940f 100644
 --- a/sub-pkg/fn-config.yaml
 +++ b/sub-pkg/fn-config.yaml
-@@ -11,10 +11,10 @@
- # 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.
--
- apiVersion: v1
+@@ -2,5 +2,6 @@ apiVersion: v1
  kind: ConfigMap
  metadata:
    name: fn-config
diff --git a/internal/builtins/pkg_context_test.go b/internal/builtins/pkg_context_test.go
index ac5bb69d..c1a6334f 100644
--- a/internal/builtins/pkg_context_test.go
+++ b/internal/builtins/pkg_context_test.go
@@ -52,10 +52,10 @@ func TestPkgContextGenerator(t *testing.T) {
 			pkgCtxGenerator := &PackageContextGenerator{}
 			out := &bytes.Buffer{}
 
-			in, err := ioutil.ReadFile(filepath.Join("testData", test.dir, "in.yaml"))
+			in, err := ioutil.ReadFile(filepath.Join("testdata", test.dir, "in.yaml"))
 			assert.NoError(t, err)
 
-			exp, err := ioutil.ReadFile(filepath.Join("testData", test.dir, "out.yaml"))
+			exp, err := ioutil.ReadFile(filepath.Join("testdata", test.dir, "out.yaml"))
 			assert.NoError(t, err)
 
 			err = pkgCtxGenerator.Run(bytes.NewReader(in), out)
diff --git a/mdtogo/cmddocs/cmddocs_test.go b/mdtogo/cmddocs/cmddocs_test.go
index 9d69e314..a33de379 100644
--- a/mdtogo/cmddocs/cmddocs_test.go
+++ b/mdtogo/cmddocs/cmddocs_test.go
@@ -32,7 +32,7 @@ func TestParsingDocWithNameFromFolder(t *testing.T) {
 	exampleMd, err := ioutil.TempFile(testDir, "_index.md")
 	assert.NoError(t, err)
 
-	testData := []byte(`
+	testdata := []byte(`
 <!--mdtogo:Short
 Short documentation.
 -->
@@ -58,7 +58,7 @@ example_bin arg1
 <!--mdtogo-->
 	`)
 
-	err = ioutil.WriteFile(exampleMd.Name(), testData, os.ModePerm)
+	err = ioutil.WriteFile(exampleMd.Name(), testdata, os.ModePerm)
 	assert.NoError(t, err)
 
 	docs := cmddocs.ParseCmdDocs([]string{exampleMd.Name()})
@@ -76,7 +76,7 @@ func TestParsingDocWithBackticks(t *testing.T) {
 	exampleMd, err := ioutil.TempFile(testDir, "_index.md")
 	assert.NoError(t, err)
 
-	testData := []byte(`
+	testdata := []byte(`
 <!--mdtogo:Short
 Short ` +
 		"`documentation`" +
@@ -90,7 +90,7 @@ Test document.
 <!--mdtogo-->
 	`)
 
-	err = ioutil.WriteFile(exampleMd.Name(), testData, os.ModePerm)
+	err = ioutil.WriteFile(exampleMd.Name(), testdata, os.ModePerm)
 	assert.NoError(t, err)
 
 	docs := cmddocs.ParseCmdDocs([]string{exampleMd.Name()})
@@ -107,7 +107,7 @@ func TestParsingDocWithNameFromComment(t *testing.T) {
 	exampleMd, err := ioutil.TempFile(testDir, "_index.md")
 	assert.NoError(t, err)
 
-	testData := []byte(`
+	testdata := []byte(`
 <!--mdtogo:FirstShort
 First short documentation.
 -->
@@ -136,7 +136,7 @@ example_bin arg1
 <!--mdtogo-->
 	`)
 
-	err = ioutil.WriteFile(exampleMd.Name(), testData, os.ModePerm)
+	err = ioutil.WriteFile(exampleMd.Name(), testdata, os.ModePerm)
 	assert.NoError(t, err)
 
 	docs := cmddocs.ParseCmdDocs([]string{exampleMd.Name()})