Skip to content

Commit

Permalink
feat: Adding codespell to Automatically Check Spelling (#3413)
Browse files Browse the repository at this point in the history
* feat: Adding `.codespellrc` to add configuration for spellchecker

* fix: Fixing a bunch of misspelled words

* feat: Adding `codespell` to CI
  • Loading branch information
yhakbar authored Sep 17, 2024
1 parent 814fb36 commit 1b5231a
Show file tree
Hide file tree
Showing 29 changed files with 66 additions and 39 deletions.
21 changes: 21 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ run_markdownlint: &run_markdownlint
-- \
docs
codespell: &codespell
name: Run codespell
command: |
pip install codespell
codespell .
version: 2.1
jobs:
test_windows:
Expand Down Expand Up @@ -520,6 +526,13 @@ jobs:
- run:
<<: *run_markdownlint

codespell:
<<: *defaults
steps:
- checkout
- run:
<<: *codespell

build:
resource_class: xlarge
<<: *defaults
Expand Down Expand Up @@ -758,6 +771,14 @@ workflows:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- codespell:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- build:
filters:
tags:
Expand Down
3 changes: 3 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[codespell]
skip = go.mod,go.sum,*.svg,Gemfile.lock
ignore-words-list = dRan
2 changes: 1 addition & 1 deletion cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func runAction(cliCtx *cli.Context, opts *options.TerragruntOptions, action cli.

// mostly preparing terragrunt options
func initialSetup(cliCtx *cli.Context, opts *options.TerragruntOptions) error {
// The env vars are renamed to "..._NO_AUTO_..." in the gobal flags`. These ones are left for backwards compatibility.
// The env vars are renamed to "..._NO_AUTO_..." in the global flags`. These ones are left for backwards compatibility.
opts.AutoInit = env.GetBool(os.Getenv("TERRAGRUNT_AUTO_INIT"), opts.AutoInit)
opts.AutoRetry = env.GetBool(os.Getenv("TERRAGRUNT_AUTO_RETRY"), opts.AutoRetry)
opts.RunAllAutoApprove = env.GetBool(os.Getenv("TERRAGRUNT_AUTO_APPROVE"), opts.RunAllAutoApprove)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Controller on to your EKS cluster.
* See the [eks-cluster-with-supporting-services example](/examples/eks-cluster-with-supporting-services) for example
usage.
* See [variables.tf](./variables.tf) for all the variables you can set on this module.
* See [outputs.tf](./outputs.tf) for all the variables that are outputed by this module.
* See [outputs.tf](./outputs.tf) for all the variables that are outputted by this module.


## Attaching IAM policy to workers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
```
In the above configuration, we create a Cluster IP based `Service` (so that it is only available internally to the
Kubernetes cluster) that routes requests to port 80 to any `Pod` that maches the label `app=backend` on port 80. Then,
Kubernetes cluster) that routes requests to port 80 to any `Pod` that matches the label `app=backend` on port 80. Then,
we configure an `Ingress` rule that routes any requests prefixed with `/service` to that `Service` endpoint on port 80.

The actual load balancer that is configured by the `Ingress` resource is defined by the particular [Ingress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The `aws-auth-merger` works as follows:
- The `aws-auth-merger` then does an initial merger of all the `ConfigMaps` in the configured namespace to create the
initial version of the main `aws-auth` `ConfigMap`.
- The `aws-auth-merger` then enters an infinite event loop that watches for changes to the `ConfigMaps` in the
configured namespace. The syncing routine will run everytime the merger detects changes in the namespace.
configured namespace. The syncing routine will run every time the merger detects changes in the namespace.

## How do I use the aws-auth-merger?

Expand Down
4 changes: 2 additions & 2 deletions cli/commands/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func NewGlobalFlags(opts *options.TerragruntOptions) cli.Flags {
Name: TerragruntIAMAssumeRoleSessionNameFlagName,
EnvVar: TerragruntIAMAssumeRoleSessionNameEnvName,
Destination: &opts.IAMRoleOptions.AssumeRoleSessionName,
Usage: "Name for the IAM Assummed Role session. Can also be set via TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME environment variable.",
Usage: "Name for the IAM Assumed Role session. Can also be set via TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME environment variable.",
},
&cli.GenericFlag[string]{
Name: TerragruntIAMWebIdentityTokenFlagName,
Expand Down Expand Up @@ -411,7 +411,7 @@ func NewGlobalFlags(opts *options.TerragruntOptions) cli.Flags {
Name: TerragruntFetchDependencyOutputFromStateFlagName,
EnvVar: TerragruntFetchDependencyOutputFromStateEnvName,
Destination: &opts.FetchDependencyOutputFromState,
Usage: "The option fetchs dependency output directly from the state file instead of init dependencies and running terraform on them.",
Usage: "The option fetches dependency output directly from the state file instead of init dependencies and running terraform on them.",
},
&cli.BoolFlag{
Name: TerragruntForwardTFStdoutFlagName,
Expand Down
4 changes: 3 additions & 1 deletion cli/commands/terraform/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ type TargetCallbackType func(ctx context.Context, opts *options.TerragruntOption

type TargetErrorCallbackType func(opts *options.TerragruntOptions, config *config.TerragruntConfig, e error) error

// Since most terragrunt CLI commands like `render-json`, `aws-provider-patch` ... require preparatory steps, such as `generate configuration` which is already coded in `terraform.runTerraform` and com;licated to extracted into a separate function due to some steps that can be called recursively in case of nested configuration or dependencies.
// Since most terragrunt CLI commands like `render-json`, `aws-provider-patch` ... require preparatory steps, such as `generate configuration`
// which is already coded in `terraform.runTerraform` and complicated to extract
// into a separate function due to some steps that can be called recursively in case of nested configuration or dependencies.
// Target struct helps to run `terraform.runTerraform` func up to the certain logic point, and the runs target's callback func and returns the flow.
// For example, `terragrunt-info` CLI command requires source to be downloaded before running its specific action. To do this it:
/*
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func ParseConfigString(ctx *ParsingContext, configPath string, configString stri
// Allowed References:
// - locals
// - dependency
// 5. Merge the included config with the parsed config. Note that all the config data is mergable except for `locals`
// 5. Merge the included config with the parsed config. Note that all the config data is mergeable except for `locals`
// blocks, which are only scoped to be available within the defining config.
func ParseConfig(ctx *ParsingContext, file *hclparse.File, includeFromChild *IncludeConfig) (*TerragruntConfig, error) {
ctx = ctx.WithTrackInclude(nil)
Expand Down
2 changes: 1 addition & 1 deletion config/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func parseGetEnvParameters(parameters []string) (EnvVar, error) {
return envVariable, nil
}

// RunCommand is a helper function that runs a command and returns the stdout as the interporation
// RunCommand is a helper function that runs a command and returns the stdout as the interpolation
// for each `run_cmd` in locals section, function is called twice
// result
func RunCommand(ctx *ParsingContext, args []string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion config/config_partial.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func PartialParseConfig(ctx *ParsingContext, file *hclparse.File, includeFromChi
decoded.Dependencies = decoded.Dependencies.FilteredWithoutConfigPath()

output.TerragruntDependencies = decoded.Dependencies
// Convert dependency blocks into module depenency lists. If we already decoded some dependencies,
// Convert dependency blocks into module dependency lists. If we already decoded some dependencies,
// merge them in. Otherwise, set as the new list.
dependencies := dependencyBlocksToModuleDependencies(decoded.Dependencies)
if output.Dependencies != nil {
Expand Down
2 changes: 1 addition & 1 deletion config/locals.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const MaxIter = 1000
// EvaluateLocalsBlock is a routine to evaluate the locals block in a way to allow references to other locals. This
// will:
// - Extract a reference to the locals block from the parsed file
// - Continuously evaluate the block until all references are evaluated, defering evaluation of anything that references
// - Continuously evaluate the block until all references are evaluated, deferring evaluation of anything that references
// other locals until those references are evaluated.
//
// This returns a map of the local names to the evaluated expressions (represented as `cty.Value` objects). This will
Expand Down
6 changes: 3 additions & 3 deletions config/locals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func TestEvaluateLocalsBlock(t *testing.T) {
require.NoError(t, gocty.FromCtyValue(evaluatedLocals["x"], &actualX))
assert.InEpsilon(t, float64(1), actualX, 0.0000001)

var actualY float64
require.NoError(t, gocty.FromCtyValue(evaluatedLocals["y"], &actualY))
assert.InEpsilon(t, float64(2), actualY, 0.0000001)
var actualY float64 //codespell:ignore
require.NoError(t, gocty.FromCtyValue(evaluatedLocals["y"], &actualY)) //codespell:ignore
assert.InEpsilon(t, float64(2), actualY, 0.0000001) //codespell:ignore

var actualZ float64
require.NoError(t, gocty.FromCtyValue(evaluatedLocals["z"], &actualZ))
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/02_features/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ nav_title_link: /docs/
## Debugging

Terragrunt and OpenTofu/Terraform usually play well together in helping you
write DRY, re-usable infrastructure. But how do we figure out what
write DRY, reusable infrastructure. But how do we figure out what
went wrong in the rare case that they _don't_ play well?

Terragrunt provides a way to configure logging level through the `--terragrunt-log-level`
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/02_features/provider-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ terragrunt apply
- The Terragrunt Provider Cache server will download the provider from the remote registry, unpack and store it into the cache directory or [create a symlink](#reusing-providers-from-the-user-plugins-directory) if the required provider exists in the user plugins directory. Note that the Terragrunt Provider Cache server will ensure that each unique provider is only ever downloaded and stored on disk once, handling concurrency (from multiple OpenTofu/Terraform and Terragrunt instances) correctly. Along with the provider, the cache server downloads hashes and signatures of the providers to check that the files are not corrupted.
- The Terragrunt Provider Cache server returns the HTTP status _429 Locked_ to OpenTofu/Terraform. This is because we do _not_ want OpenTofu/Terraform to actually download any providers as a result of calling `terraform init`; we only use that command to request the Terragrunt Provider Cache Server to start caching providers.
- At this point, all providers are downloaded and cached, so finally, we run `terragrunt init` a second time, which will find all the providers it needs in the cache, and it'll create symlinks to them nearly instantly, with no additional downloading.
- Note that if a OpenTofu/Terraform module doesn't have a lock file, OpenTofu/Terraform does _not_ use the cache, so it would end up downloading all the providers from scratch. To work around this, we generate `.terraform.lock.hcl` based on the request made by `terrafrom init` to the Terragrunt Provider Cache server. Since `terraform init` only requestes the providers that need to be added/updated, we can keep track of them using the Terragrunt Provider Cache server and update the OpenTofu/Terraform lock file with the appropriate hashes without having to parse `tf` configs.
- Note that if a OpenTofu/Terraform module doesn't have a lock file, OpenTofu/Terraform does _not_ use the cache, so it would end up downloading all the providers from scratch. To work around this, we generate `.terraform.lock.hcl` based on the request made by `terrafrom init` to the Terragrunt Provider Cache server. Since `terraform init` only requests the providers that need to be added/updated, we can keep track of them using the Terragrunt Provider Cache server and update the OpenTofu/Terraform lock file with the appropriate hashes without having to parse `tf` configs.

#### Reusing providers from the user plugins directory

Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/04_reference/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ Run the provided OpenTofu/Terraform command against the graph of dependencies fo
The Command will be executed following the order of dependencies: so it'll run on the module in the current working directory first, then on modules that depend on it directly, then on the modules that depend on those modules, and so on. Note that if the command is `destroy`, it will execute in the opposite order of the dependencies.

Example:
Having bellow dependencies:
Having below dependencies:
[![dependency-graph](/assets/img/collections/documentation/dependency-graph.png){: width="80%" }]({{site.baseurl}}/assets/img/collections/documentation/dependency-graph.png)

Running `terragrunt graph apply` in `eks` module will lead to the following execution order:
Expand Down Expand Up @@ -1041,7 +1041,7 @@ When passed in, and running `terragrunt validate-inputs`, enables strict mode fo
**CLI Arg**: `--terragrunt-ignore-dependency-order`<br/>
**Environment Variable**: `TERRAGRUNT_IGNORE_DEPENDENCY_ORDER`<br/>

When passed in, ignore the depedencies between modules when running `*-all` commands.
When passed in, ignore the dependencies between modules when running `*-all` commands.

### terragrunt-ignore-external-dependencies

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/05_rfc/imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ look for an alternative implementation.
This challenge has come up numerous times in the lifetime of Terragrunt. The following are relevant issues that raise
similar concerns:

- [Shared and overridable variabls](https://github.com/gruntwork-io/terragrunt/issues/814)
- [Shared and overridable variables](https://github.com/gruntwork-io/terragrunt/issues/814)
- [Being able to merge maps from inputs](https://github.com/gruntwork-io/terragrunt/issues/744)
- [Request to allow more than one level of include](https://github.com/gruntwork-io/terragrunt/issues/303)
- [Request to reference inputs from another config](https://github.com/gruntwork-io/terragrunt/issues/967)
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/collection-browser_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* TOC:
* - FILTER FUNCTIONS - functions to extract the terms from DOM element(s) and use them in search engine to show/hide elements.
* - MAIN - INITIALIZE - initializes Browser Search and registers actions (click etc.) on filter components.
* - SEARCH ENGINE - here is the logic to show & hide elements accoriding to filters terms.
* - SEARCH ENGINE - here is the logic to show & hide elements according to filters terms.
* - OTHER
*/
(function () {
Expand Down
4 changes: 2 additions & 2 deletions docs/assets/js/collection-browser_toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ $(document).ready(function () {
}
})

// Expand / collpase on click
// Expand / collapse on click
$('#toc .nav-collapse-handler').on('click', function() {
toggleNav($(this))
})

$(docSidebarInitialExpand)
})

// Expand / collpase on click
// Expand / collapse on click
function toggleNav(el) {
if (el.hasClass('collapsed')) {
el.removeClass('collapsed')
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (args Args) Slice() []string {
// if the given act is:
//
// `SingleDashFlag` - converts all arguments containing double dashes to single dashes
// `DoubleDashFlag` - converts all arguments containing signle dashes to double dashes
// `DoubleDashFlag` - converts all arguments containing single dashes to double dashes
func (args Args) Normalize(acts ...NormalizeActsType) Args {
strArgs := make(Args, 0, len(args.Slice()))

Expand Down
2 changes: 1 addition & 1 deletion pkg/log/format/prefix_style.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (

type prefixStyle struct {
// cache stores prefixes with their color schemes.
// We use [xsync.MapOf](https://github.com/puzpuzpuz/xsync?tab=readme-ov-file#map) instaed of standard `sync.Map` since it's faster and has generic types.
// We use [xsync.MapOf](https://github.com/puzpuzpuz/xsync?tab=readme-ov-file#map) instead of standard `sync.Map` since it's faster and has generic types.
cache *xsync.MapOf[string, ColorFunc]

availableStyles []ColorStyle
Expand Down
2 changes: 1 addition & 1 deletion pkg/log/writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (writer *Writer) SetOption(opts ...Option) {
}
}

// Write implements `io.Writer` interafce.
// Write implements `io.Writer` interface.
func (writer *Writer) Write(p []byte) (n int, err error) {
var (
str = string(p)
Expand Down
2 changes: 1 addition & 1 deletion remote/remote_state_gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func DoesGCSBucketExist(gcsClient *storage.Client, config *RemoteStateConfigGCS)
bucket := gcsClient.Bucket(config.Bucket)

// TODO - the code below attempts to determine whether the storage bucket exists by making a making a number of API
// calls, then attemping to list the contents of the bucket. It was adapted from Google's own integration tests and
// calls, then attempting to list the contents of the bucket. It was adapted from Google's own integration tests and
// should be improved once the appropriate API call is added. For more info see:
// https://github.com/GoogleCloudPlatform/google-cloud-go/blob/de879f7be552d57556875b8aaa383bce9396cc8c/storage/integration_test.go#L1231
if _, err := bucket.Attrs(ctx); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion terraform/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
tfLogTimeLevelMsgReg = regexp.MustCompile(`(?i)(^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\S*)\s*\[(trace|debug|warn|info|error)\]\s*(.+\S)$`)
)

// ParseLogFunc wraps `ParseLog` to add msg prefix and bypasses the the parse erorr if `returnError` is false,
// ParseLogFunc wraps `ParseLog` to add msg prefix and bypasses the parse error if `returnError` is false,
// since returning the error for `log/writer` will cause TG to fall with a `broken pipe` error.
func ParseLogFunc(msgPrefix string, returnError bool) writer.WriterParseFunc {
return func(str string) (msg string, ptrTime *time.Time, ptrLevel *log.Level, err error) {
Expand Down
2 changes: 1 addition & 1 deletion terraform/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestToSourceUrl(t *testing.T) {
{"https://www.googleapis.com/storage/v1/modules/foomodule.zip", "gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip"},
{"https://www.googleapis.com/storage/v1/modules/foomodule.zip", "gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip"},
{"git::https://name@dev.azure.com/name/project-name/_git/repo-name", "git::https://name@dev.azure.com/name/project-name/_git/repo-name"},
{"https://repositry.rnd.net/artifactory/generic-production-iac/tf-auto-azr-iam.2.6.0.zip", "https://repositry.rnd.net/artifactory/generic-production-iac/tf-auto-azr-iam.2.6.0.zip"},
{"https://repository.rnd.net/artifactory/generic-production-iac/tf-auto-azr-iam.2.6.0.zip", "https://repository.rnd.net/artifactory/generic-production-iac/tf-auto-azr-iam.2.6.0.zip"},
}

for i, testCase := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/hclvalidate/second/d/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variabl "d" {
variabl "d" { //codespell:ignore
type = string
default = "d"
}
Expand Down
4 changes: 2 additions & 2 deletions test/integration_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestEngineRunAllOpentofu(t *testing.T) {
assert.Contains(t, stderr, "plugin process exited:")
assert.Contains(t, stdout, "resource \"local_file\" \"test\"")
assert.Contains(t, stdout, "filename = \"./test.txt\"\n")
assert.Contains(t, stdout, "OpenTofu has been successfull")
assert.Contains(t, stdout, "OpenTofu has been successful")
assert.Contains(t, stdout, "Tofu Shutdown completed")
assert.Contains(t, stdout, "Apply complete!")
}
Expand All @@ -100,7 +100,7 @@ func TestEngineRunAllOpentofuCustomPath(t *testing.T) {

assert.Contains(t, stderr, "starting plugin:")
assert.Contains(t, stderr, "plugin process exited:")
assert.Contains(t, stdout, "OpenTofu has been successfull")
assert.Contains(t, stdout, "OpenTofu has been successful")
assert.Contains(t, stdout, "Tofu Shutdown completed")
assert.Contains(t, stdout, "Apply complete!")

Expand Down
Loading

0 comments on commit 1b5231a

Please sign in to comment.