From 1977dc2ce7147c79d1e37f372f7b15f0ab4eb74b Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Fri, 14 Aug 2020 14:41:11 -0500 Subject: [PATCH 1/4] Add a .pre-commit-config.yaml file. Signed-off-by: Matt Moyer --- .pre-commit-config.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..4290d430 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: +- repo: git://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + # TODO: find a version of this to validate ytt templates? + # - id: check-yaml + # args: ['--allow-multiple-documents'] + - id: check-json + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-merge-conflict + - id: check-added-large-files + - id: check-byte-order-marker + - id: detect-private-key + exclude: testdata + - id: mixed-line-ending From 9376f034ea0ce7b445e592b6b02436441bb9d736 Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Fri, 14 Aug 2020 14:42:22 -0500 Subject: [PATCH 2/4] Mask this testing-only private key so we don't alert on it. Signed-off-by: Matt Moyer --- test/integration/client_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/integration/client_test.go b/test/integration/client_test.go index 2008bb06..6f318a5a 100644 --- a/test/integration/client_test.go +++ b/test/integration/client_test.go @@ -43,15 +43,17 @@ c2VyMAoGCCqGSM49BAMCA0cAMEQCIEwPZhPpYhYHndfTEsWOxnxzJkmhAcYIMCeJ d9kyq/fPAiBNCJw1MCLT8LjNlyUZCfwI2zuI3e0w6vuau89oj2zvVA== -----END CERTIFICATE----- `) - testKey = strings.TrimSpace(` ------BEGIN EC PRIVATE KEY----- + testKey = maskKey(strings.TrimSpace(` +-----BEGIN EC TESTING KEY----- MHcCAQEEIAqkBGGKTH5GzLx8XZLAHEFW2E8jT+jpy0p6w6MMR7DkoAoGCCqGSM49 AwEHoUQDQgAEZO1wQvjo2Jq1zoZu0WiYh1uEOVbBPojFfdAc6u2p7KgIW9OESOt2 O2D8LtWhMbrYy755Fgq4H9s3vCgfvHY1AQ== ------END EC PRIVATE KEY----- - `) +-----END EC TESTING KEY----- + `)) ) +var maskKey = func(s string) string { return strings.ReplaceAll(s, "TESTING KEY", "PRIVATE KEY") } + func TestClient(t *testing.T) { library.SkipUnlessIntegration(t) tmcClusterToken := library.Getenv(t, "PLACEHOLDER_NAME_TMC_CLUSTER_TOKEN") From 787cf47c39048518f40370a95e374083d5cbc452 Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Fri, 14 Aug 2020 14:42:49 -0500 Subject: [PATCH 3/4] Standardize whitespace/newlines for consistency. Signed-off-by: Matt Moyer --- deploy/README.md | 2 +- hack/header.txt | 2 +- hack/test-unit.sh | 2 +- hack/update.sh | 2 +- internal/downward/testdata/invalidlabels/labels | 2 +- internal/downward/testdata/invalidlabels/namespace | 2 +- internal/downward/testdata/missinglabels/namespace | 2 +- internal/downward/testdata/valid/labels | 2 +- internal/downward/testdata/valid/namespace | 2 +- internal/server/testdata/podinfo/labels | 2 +- internal/server/testdata/podinfo/namespace | 2 +- internal/server/testdata/valid-config.yaml | 1 - pkg/config/testdata/happy.yaml | 1 - pkg/config/testdata/no-discovery.yaml | 1 - 14 files changed, 11 insertions(+), 14 deletions(-) diff --git a/deploy/README.md b/deploy/README.md index 6ec85a6a..9a03d551 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -3,7 +3,7 @@ This example deployment uses `ytt` and `kapp` from [k14s.io](https://k14s.io/). If you would rather not install these command-line tools directly on your machine, -you can use alternatively get the most recent version of this container image: +you can use alternatively get the most recent version of this container image: https://hub.docker.com/r/k14s/image/tags 1. Fill in the values in [values.yml](values.yaml) diff --git a/hack/header.txt b/hack/header.txt index 9c120c6d..fce47448 100644 --- a/hack/header.txt +++ b/hack/header.txt @@ -1,2 +1,2 @@ Copyright 2020 VMware, Inc. -SPDX-License-Identifier: Apache-2.0 \ No newline at end of file +SPDX-License-Identifier: Apache-2.0 diff --git a/hack/test-unit.sh b/hack/test-unit.sh index 1100c91e..38c0bc8e 100755 --- a/hack/test-unit.sh +++ b/hack/test-unit.sh @@ -5,4 +5,4 @@ set -euo pipefail ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" -"$ROOT/hack/module.sh" unittest \ No newline at end of file +"$ROOT/hack/module.sh" unittest diff --git a/hack/update.sh b/hack/update.sh index 5d070127..e855c2d7 100755 --- a/hack/update.sh +++ b/hack/update.sh @@ -6,4 +6,4 @@ set -euo pipefail ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" "$ROOT/hack/module.sh" tidy -"$ROOT/hack/update-codegen.sh" \ No newline at end of file +"$ROOT/hack/update-codegen.sh" diff --git a/internal/downward/testdata/invalidlabels/labels b/internal/downward/testdata/invalidlabels/labels index e466dcbd..9977a283 100644 --- a/internal/downward/testdata/invalidlabels/labels +++ b/internal/downward/testdata/invalidlabels/labels @@ -1 +1 @@ -invalid \ No newline at end of file +invalid diff --git a/internal/downward/testdata/invalidlabels/namespace b/internal/downward/testdata/invalidlabels/namespace index d2826d00..f2605f23 100644 --- a/internal/downward/testdata/invalidlabels/namespace +++ b/internal/downward/testdata/invalidlabels/namespace @@ -1 +1 @@ -test-namespace \ No newline at end of file +test-namespace diff --git a/internal/downward/testdata/missinglabels/namespace b/internal/downward/testdata/missinglabels/namespace index d2826d00..f2605f23 100644 --- a/internal/downward/testdata/missinglabels/namespace +++ b/internal/downward/testdata/missinglabels/namespace @@ -1 +1 @@ -test-namespace \ No newline at end of file +test-namespace diff --git a/internal/downward/testdata/valid/labels b/internal/downward/testdata/valid/labels index 433404c1..e5880cda 100644 --- a/internal/downward/testdata/valid/labels +++ b/internal/downward/testdata/valid/labels @@ -1,2 +1,2 @@ foo="bar" -bat="baz" \ No newline at end of file +bat="baz" diff --git a/internal/downward/testdata/valid/namespace b/internal/downward/testdata/valid/namespace index d2826d00..f2605f23 100644 --- a/internal/downward/testdata/valid/namespace +++ b/internal/downward/testdata/valid/namespace @@ -1 +1 @@ -test-namespace \ No newline at end of file +test-namespace diff --git a/internal/server/testdata/podinfo/labels b/internal/server/testdata/podinfo/labels index 433404c1..e5880cda 100644 --- a/internal/server/testdata/podinfo/labels +++ b/internal/server/testdata/podinfo/labels @@ -1,2 +1,2 @@ foo="bar" -bat="baz" \ No newline at end of file +bat="baz" diff --git a/internal/server/testdata/podinfo/namespace b/internal/server/testdata/podinfo/namespace index d2826d00..f2605f23 100644 --- a/internal/server/testdata/podinfo/namespace +++ b/internal/server/testdata/podinfo/namespace @@ -1 +1 @@ -test-namespace \ No newline at end of file +test-namespace diff --git a/internal/server/testdata/valid-config.yaml b/internal/server/testdata/valid-config.yaml index 00c2e78b..234d9de8 100644 --- a/internal/server/testdata/valid-config.yaml +++ b/internal/server/testdata/valid-config.yaml @@ -2,4 +2,3 @@ webhook: url: https://tuna.com/fish?marlin caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tLi4u - diff --git a/pkg/config/testdata/happy.yaml b/pkg/config/testdata/happy.yaml index ebbfac72..ca6e82bb 100644 --- a/pkg/config/testdata/happy.yaml +++ b/pkg/config/testdata/happy.yaml @@ -4,4 +4,3 @@ discovery: webhook: url: https://tuna.com/fish?marlin caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tLi4u - diff --git a/pkg/config/testdata/no-discovery.yaml b/pkg/config/testdata/no-discovery.yaml index 00c2e78b..234d9de8 100644 --- a/pkg/config/testdata/no-discovery.yaml +++ b/pkg/config/testdata/no-discovery.yaml @@ -2,4 +2,3 @@ webhook: url: https://tuna.com/fish?marlin caBundle: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tLi4u - From 76a44ecd58161fc537fb92da8c0fe0be2eb1eb8a Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Fri, 14 Aug 2020 14:47:39 -0500 Subject: [PATCH 4/4] Add some development notes to the README for now. Signed-off-by: Matt Moyer --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 49b59c26..58039403 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,30 @@ # placeholder-name Copyright 2020 VMware, Inc. + +## Developing + +### Running Lint + +```cmd +./hack/module.sh lint +``` + +### Running Tests + +```cmd +./hack/module.sh unittest +``` + +### Pre-commit hooks + +This project uses the [pre-commit] to agree on some conventions about whitespace/file encoding. + +```cmd +$ brew install pre-commit +[...] +$ pre-commit install +pre-commit installed at .git/hooks/pre-commit +``` + +[pre-commit]: https://pre-commit.com/