-
Notifications
You must be signed in to change notification settings - Fork 4
Add missing namespace specification + address linting issues #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3137ed2
fix: log errors from Enrollment API call
irby d133022
fix: add missing namespaces, add linting to catch issues
irby 629436f
feat: add linting
irby 37736de
chore: address lint issues
irby 3058fd7
chore: update CHANGELOG
irby 96b98ee
chore: apply copilot feedback
irby 5d3d916
feat: fix typo
irby 4d45a27
feat: copilot suggestions
irby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,46 @@ | ||
| run: | ||
| # timeout for analysis, e.g. 30s, 5m, default is 1m | ||
| timeout: 12m | ||
|
|
||
| skip-dirs: | ||
| - testdata$ | ||
| - test/mock | ||
| - go/pkg/mod | ||
|
|
||
| skip-files: | ||
| - ".*\\.pb\\.go" | ||
|
|
||
| version: "2" | ||
| linters: | ||
| enable: | ||
| - bodyclose | ||
| - durationcheck | ||
| - errorlint | ||
| - goimports | ||
| - revive | ||
| - gocritic | ||
| - gosec | ||
| - misspell | ||
| - nakedret | ||
| - nolintlint | ||
| - revive | ||
| - unconvert | ||
| - unparam | ||
| - whitespace | ||
| - gocritic | ||
| - nolintlint | ||
|
|
||
| linters-settings: | ||
| revive: | ||
| # minimal confidence for issues, default is 0.8 | ||
| confidence: 0.0 | ||
| settings: | ||
| revive: | ||
| confidence: 0 | ||
| rules: | ||
| - name: var-naming | ||
| disabled: true | ||
| exclusions: | ||
| generated: lax | ||
| presets: | ||
| - comments | ||
| - common-false-positives | ||
| - legacy | ||
| - std-error-handling | ||
| paths: | ||
| - .*\.pb\.go | ||
| - testdata$ | ||
| - test/mock | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ | ||
| formatters: | ||
| enable: | ||
| - goimports | ||
| exclusions: | ||
| generated: lax | ||
| paths: | ||
| - .*\.pb\.go | ||
| - testdata$ | ||
| - test/mock | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| checks: | ||
| addAllBuiltIn: true | ||
| # Add project-specific exclusions below as needed, e.g.: | ||
| # exclude: | ||
| # - "unset-cpu-requirements" | ||
| # - "unset-memory-requirements" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Command Cert Manager Issuer Contribution Guide | ||
|
|
||
| ## Requirements | ||
| - Go (>= 1.24) | ||
| - golangci-lint (>= 2.4.0) ([installation notes](https://github.com/golangci/golangci-lint?tab=readme-ov-file#install-golangci-lint)) | ||
| - helm (>= 3.x) — required to render chart templates for manifest linting ([installation notes](https://helm.sh/docs/intro/install/)) | ||
| - conftest — policy testing tool powered by Open Policy Agent; installed automatically by `make lint-manifests` | ||
|
|
||
| ## Installing dependencies | ||
| Project dependencies can be installed by running the following: | ||
|
|
||
| ```bash | ||
| go mod download | ||
| ``` | ||
|
|
||
| The following command can be used to add missing requirements or remove unused modules: | ||
|
|
||
| ```bash | ||
| go mod tidy | ||
| ``` | ||
|
|
||
| ## Running unit tests | ||
| The following command can be run to run the project unit tests: | ||
|
|
||
| ```bash | ||
| go test -v ./... | ||
| ``` | ||
|
|
||
| ## Running linters | ||
| The project uses golangci-lint to lint the codebase. The following command can be run to run the linters: | ||
|
|
||
| ```bash | ||
| golangci-lint run | ||
| ``` | ||
|
|
||
| or, alternatively: | ||
|
|
||
| ```bash | ||
| make lint | ||
| ``` | ||
|
|
||
| ## Updating generated manifests | ||
|
|
||
| This command will update the generated custom resource definitions under `config/crd/bases`: | ||
|
|
||
| ```bash | ||
| make generate manifests | ||
| ``` | ||
|
|
||
| > [!IMPORTANT] | ||
| > There is no automated process to automatically update the CRDs under `deploy/charts/command-cert-manager-issuer`. If any changes are made to the CRDs, the generated CRDs under `config/crd/bases` must be copied to `deploy/charts/command-cert-manager-issuer/crds` to ensure the Helm chart is up to date. | ||
|
|
||
| ## Linting Helm manifests | ||
|
|
||
| The Helm chart under `deploy/charts/command-cert-manager-issuer` is linted with two tools on every PR: | ||
| - **conftest** — runs custom Rego policies located in the [`policy/`](policy/) directory against the rendered manifests | ||
|
|
||
| To run both checks locally: | ||
|
|
||
| ```bash | ||
| make lint-manifests | ||
| ``` | ||
|
|
||
| `conftest` is downloaded automatically into `bin/` on first use; no manual installation is required. | ||
|
|
||
| To inspect the rendered templates without linting: | ||
|
|
||
| ```bash | ||
| make helm-template | ||
| ``` | ||
|
|
||
| ### Adding or modifying policies | ||
|
|
||
| Rego policies live in [`policy/`](policy/). Each `.rego` file in that directory is evaluated by conftest against every resource in the rendered chart. Add a new `.rego` file to enforce additional rules. For example, `policy/roles.rego` enforces that all `Role` resources declare an explicit namespace. | ||
|
|
||
| kube-linter checks can be tuned in [.kube-linter.yaml](.kube-linter.yaml). To exclude a check, add its name under the `exclude` key. | ||
|
|
||
| ## Running end-to-end tests | ||
| A comprehensive end-to-end test suite is available to verify the issuer code works against cert-manager and a Keyfactor Command instance. | ||
|
|
||
| Instructions on how to run the end-to-end test suite can be found [here](./e2e/README.md). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
deploy/charts/command-cert-manager-issuer/ci/cluster-access-values.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Cluster-wide access configuration — exercises ClusterRole/ClusterRoleBinding | ||
| # paths for secret and configmap access, and enables secure metrics. | ||
| secretConfig: | ||
| useClusterRoleForSecretAccess: true | ||
| useClusterRoleForConfigMapAccess: true | ||
| metrics: | ||
| secure: true |
7 changes: 7 additions & 0 deletions
7
deploy/charts/command-cert-manager-issuer/ci/default-values.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Default configuration — all flags at their chart defaults. | ||
| # Role/RoleBinding namespace-scoped paths are exercised. | ||
| secretConfig: | ||
| useClusterRoleForSecretAccess: false | ||
| useClusterRoleForConfigMapAccess: false | ||
| metrics: | ||
| secure: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.