From e1df12d8756dae2663a04bfb2d6c1ac45d95f7ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jasmin=20M=C3=BCller?= Date: Wed, 7 Dec 2022 12:40:05 +0100 Subject: [PATCH] chore(pre-commit): update linting INPRO-1444 --- .editorconfig | 2 - .github/renovate.json5 | 30 +++--- .markdownlint.yaml | 26 ++++++ .pre-commit-config.yaml | 92 +++++++++++++++++++ .prettierignore | 3 + .prettierrc.yaml | 5 + .terraform-docs.yaml | 36 ++++++++ .tflint.hcl | 18 ++++ .yamllint.config.yaml | 30 ++++++ .../README.md | 19 +++- .../example-with-google-buckets/README.md | 1 + examples/example-with-local-files/README.md | 1 + examples/example-yaml-files/README.md | 1 + .../example-yaml-files/group_settings.yaml | 1 + examples/example-yaml-files/groups.yaml | 1 + examples/example-yaml-files/users.yaml | 1 + .../example-yaml-files/users_external.yaml | 1 + modules/users_external_to_groups/README.md | 1 + 18 files changed, 248 insertions(+), 21 deletions(-) create mode 100644 .markdownlint.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierignore create mode 100644 .prettierrc.yaml create mode 100644 .terraform-docs.yaml create mode 100644 .tflint.hcl create mode 100644 .yamllint.config.yaml diff --git a/.editorconfig b/.editorconfig index ee2c8f7..6e87a00 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,12 +1,10 @@ # Editor configuration, see http://editorconfig.org - root = true [*] charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 2ecae6e..4913b76 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -1,19 +1,19 @@ { - "enabled": true, - "semanticCommits": "enabled", - "dependencyDashboard": true, - "dependencyDashboardTitle": ":robot: Renovate Dashboard", - "suppressNotifications": ["prIgnoreNotification"], - "rebaseWhen": "conflicted", - "labels": ["dependencies"], - "packageRules": [ + enabled: true, + semanticCommits: "enabled", + dependencyDashboard: true, + dependencyDashboardTitle: ":robot: Renovate Dashboard", + suppressNotifications: ["prIgnoreNotification"], + rebaseWhen: "conflicted", + labels: ["dependencies"], + packageRules: [ { - "matchPackagePatterns": ["eslint"], - "labels": ["linting"] + matchPackagePatterns: ["eslint"], + labels: ["linting"], }, { - "matchDepTypes": ["optionalDependencies"], - "addLabels": ["optional"] - } - ] -} \ No newline at end of file + matchDepTypes: ["optionalDependencies"], + addLabels: ["optional"], + }, + ], +} diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..fbd7536 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,26 @@ +--- +default: true + +# MD013/line-length - Line length +MD013: + # Number of characters + line_length: 240 + # Number of characters for headings + heading_line_length: 80 + # Number of characters for code blocks + code_block_line_length: 120 + # Include code blocks + code_blocks: true + # Include tables + tables: true + # Include headings + headings: true + # Include headings + headers: true + # Strict length checking + strict: false + # Stern length checking + stern: false + +# MD033/no-inline-html - Inline HTML disabled because of tf-docs +MD033: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4ce58ee --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,92 @@ +--- +fail_fast: false +default_stages: + - commit + - push + +repos: + - repo: https://github.com/terraform-docs/terraform-docs + rev: v0.16.0 + hooks: + - id: terraform-docs-go + args: + - --config + - .terraform-docs.yaml + - --output-file + - README.md + - . + + - repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.77.0 + hooks: + - id: terraform_fmt + - id: terraform_tflint + args: + - --args=--config=__GIT_WORKING_DIR__/.tflint.hcl + # - id: terraform_tfsec + # files: ^infra/terraform + # - id: terraform_validate + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-merge-conflict + - id: check-added-large-files + args: + - --maxkb=100 + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-json + - id: check-symlinks + - id: check-xml + - id: detect-private-key + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: mixed-line-ending + args: + - --fix=auto + - id: trailing-whitespace + args: + - --markdown-linebreak-ext=md + + - repo: https://github.com/adrienverge/yamllint + rev: v1.28.0 + hooks: + - id: yamllint + args: + - --config-file + - .yamllint.config.yaml + + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.3.1 + hooks: + - id: remove-crlf + - id: remove-tabs + + - repo: https://github.com/sirosen/fix-smartquotes + rev: 0.2.0 + hooks: + - id: fix-smartquotes + + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.32.2 + hooks: + - id: markdownlint-fix + args: + - --config + - .markdownlint.yaml + + - repo: https://github.com/k8s-at-home/sops-pre-commit + rev: v2.1.1 + hooks: + - id: forbid-secrets + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.0.0-alpha.4 + hooks: + - id: prettier + args: + - --ignore-path + - .prettierignore + - --config + - .prettierrc.yaml diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..964f58b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +*.sops.* +**/.terraform/** +terraform.tfstate* diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 0000000..e30d9f9 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,5 @@ +--- +trailingComma: "es5" +tabWidth: 2 +semi: false +singleQuote: false diff --git a/.terraform-docs.yaml b/.terraform-docs.yaml new file mode 100644 index 0000000..da9ee35 --- /dev/null +++ b/.terraform-docs.yaml @@ -0,0 +1,36 @@ +--- +formatter: markdown +header-from: main.tf + +sections: + hide-all: false + hide: [] + show-all: true + show: [] + +output: + file: "README.md" + mode: inject + template: |- + + {{ .Content }} + + check: false + +output-values: + enabled: false + from: "" + +sort: + enabled: true + by: required + +settings: + anchor: true + color: true + default: true + escape: true + indent: 2 + required: true + sensitive: true + type: true diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..e276f55 --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,18 @@ +config { + force = false + disabled_by_default = false +} + +rule "terraform_module_pinned_source" { + enabled = true + style = "flexible" + default_branches = ["main", "master", "default", "develop"] +} + +rule "terraform_required_providers" { + enabled = false +} + +rule "terraform_required_version" { + enabled = false +} diff --git a/.yamllint.config.yaml b/.yamllint.config.yaml new file mode 100644 index 0000000..100b666 --- /dev/null +++ b/.yamllint.config.yaml @@ -0,0 +1,30 @@ +--- +# see https://yamllint.readthedocs.io/en/stable/index.html for more options +extends: default +rules: + truthy: + allowed-values: ["true", "false", "on", "yes"] + + line-length: + max: 120 + level: warning + + braces: + min-spaces-inside: 0 + max-spaces-inside: 1 + + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + + indentation: + spaces: 2 + indent-sequences: consistent + check-multi-line-strings: false + + document-start: + present: true + level: error + + comments: + min-spaces-from-content: 1 diff --git a/examples/example-provider-authentication-with-tfvars/README.md b/examples/example-provider-authentication-with-tfvars/README.md index 892990e..755a336 100644 --- a/examples/example-provider-authentication-with-tfvars/README.md +++ b/examples/example-provider-authentication-with-tfvars/README.md @@ -1,23 +1,34 @@ # Example Provider Authentication + This folder contains an example how to implement the GSuite Authentication for Terraform. + ## Google Cloud Service account + ### Setup Service Account + [Google SDK Documentation about Delegation](https://developers.google.com/admin-sdk/directory/v1/guides/delegation) Go to [IAM service accounts](https://console.developers.google.com/iam-admin/serviceaccounts) and create a Service account. -* enter Service account name -* add yourself to 'Grant users access to this service account' + +- enter Service account name +- add yourself to 'Grant users access to this service account' ### Add key + In the Service account overview open the 'Actions' menu on the right of the dedicated service account and choose **Manage keys**. Click on 'Add key' and create a new key in JSON format, this key will be used for Terraform. Go back to Details and copy the Unique ID. ### Add service account to domain-wide delegation for GWorkspace + Go to [Google Admin console Domain wide delegation](https://admin.google.com/ac/owl/domainwidedelegation). Get the Service account with the ID provided before (Service account details), then add the following oauth scopes: -``` -https://www.googleapis.com/auth/admin.directory.user, https://www.googleapis.com/auth/admin.directory.userschema, https://www.googleapis.com/auth/admin.directory.group, https://www.googleapis.com/auth/apps.groups.settings + +```console +https://www.googleapis.com/auth/admin.directory.user, +https://www.googleapis.com/auth/admin.directory.userschema, +https://www.googleapis.com/auth/admin.directory.group, +https://www.googleapis.com/auth/apps.groups.settings ``` ### Provide Service account credentials to Terraform Provider diff --git a/examples/example-with-google-buckets/README.md b/examples/example-with-google-buckets/README.md index 66de878..532adfd 100644 --- a/examples/example-with-google-buckets/README.md +++ b/examples/example-with-google-buckets/README.md @@ -1,3 +1,4 @@ # Example Usage with Google Buckets + These templates show an example of how to use the terraform-gsuite-user-group-management module with Google Buckets as data source. The yaml files can be found in the Github repository, see [example-yaml-files](examples/example-yaml-files). diff --git a/examples/example-with-local-files/README.md b/examples/example-with-local-files/README.md index d1a734e..4100d5f 100644 --- a/examples/example-with-local-files/README.md +++ b/examples/example-with-local-files/README.md @@ -1,3 +1,4 @@ # Example Usage with local files + These templates show an example of how to use the terraform-gsuite-user-group-management module with local files as data source. The yaml files can be found in the Github repository, see [example-yaml-files](examples/example-yaml-files). diff --git a/examples/example-yaml-files/README.md b/examples/example-yaml-files/README.md index 3eefc3e..1290563 100644 --- a/examples/example-yaml-files/README.md +++ b/examples/example-yaml-files/README.md @@ -1,2 +1,3 @@ # Example YAML files + These templates show an example of how the terraform-gsuite-user-group-management module expects the data structure. Those YAML files can be used as data source for the module. Check out the other examples on how to provide them. diff --git a/examples/example-yaml-files/group_settings.yaml b/examples/example-yaml-files/group_settings.yaml index 1e5b4c5..5170beb 100644 --- a/examples/example-yaml-files/group_settings.yaml +++ b/examples/example-yaml-files/group_settings.yaml @@ -1,3 +1,4 @@ +--- # --------------------------------------------------------------------------------------------------------------------- # GOOGLE GROUP SETTINGS # --------------------------------------------------------------------------------------------------------------------- diff --git a/examples/example-yaml-files/groups.yaml b/examples/example-yaml-files/groups.yaml index 5a81bad..30c8231 100644 --- a/examples/example-yaml-files/groups.yaml +++ b/examples/example-yaml-files/groups.yaml @@ -1,3 +1,4 @@ +--- # --------------------------------------------------------------------------------------------------------------------- # GOOGLE GROUP # --------------------------------------------------------------------------------------------------------------------- diff --git a/examples/example-yaml-files/users.yaml b/examples/example-yaml-files/users.yaml index 4cc4cdc..e2979b5 100644 --- a/examples/example-yaml-files/users.yaml +++ b/examples/example-yaml-files/users.yaml @@ -1,3 +1,4 @@ +--- # --------------------------------------------------------------------------------------------------------------------- # GOOGLE USER WITH GROUP MEMBERSHIPS # --------------------------------------------------------------------------------------------------------------------- diff --git a/examples/example-yaml-files/users_external.yaml b/examples/example-yaml-files/users_external.yaml index b9142d5..cada2c9 100644 --- a/examples/example-yaml-files/users_external.yaml +++ b/examples/example-yaml-files/users_external.yaml @@ -1,3 +1,4 @@ +--- # --------------------------------------------------------------------------------------------------------------------- # EXTERNAL USER WITH GROUP MEMBERSHIPS # --------------------------------------------------------------------------------------------------------------------- diff --git a/modules/users_external_to_groups/README.md b/modules/users_external_to_groups/README.md index aec3299..547f853 100644 --- a/modules/users_external_to_groups/README.md +++ b/modules/users_external_to_groups/README.md @@ -1,2 +1,3 @@ # Module for adding external users to groups + This module is optional. For details on how to use it check [examples](examples/).