Commit Graph

12 Commits

Author SHA1 Message Date
Julien 68524af701
Enable goheader rule and add missing license headers ()
This commit adds the `goheader` rule to `golangci-lint` to enforce that
all our Go source code includes appropriate licence headers, fixing up
files that currently fail that check.

---------

Co-authored-by: Will Jones <will@sacharissa.co.uk>
2024-09-09 12:05:45 +00:00
Fraser Waters b6645b372f
Lift context parameter for ApplyProjectConfig ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

`mergeConfig` uses `Crypter.Encrypt` that needs a context and was using
`context.TODO()`. This lifts that to a context parameter and fixes up
all call sites.

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-04-22 06:37:34 +00:00
Pat Gavlin ecb58cc9f7
[cli] Include config from ESC in `pulumi config` ()
These changes include any configuration values sourced from a stack's
ESC environment to the output of `pulumi config`.

These changes also add an `ENVIRONMENT` block to the output of `pulumi
config` for stacks that reference environments. This block shows the
definition of the stack's environment.

Finally, these changes add a warning to `pulumi config` if the stack's
ESC environment does not define any of the `environmentVariables`,
`files`, or `pulumiConfig` properties.
2023-11-21 10:44:45 +00:00
Pat Gavlin 4d3b82cb9f
[cli] Add support for environments ()
These changes add support for ESC environments to the Pulumi CLI. This
involves two major changes:

- Support for the `env` subcommand
- Support for the `environment` stanza in stack config files

The former reuses the command from `esc` itself with a little
rebranding.

The latter adds support to stack config files for an `environment`
property of the form:

```yaml
environment:
  - list
  - of
  - environment
  - names
```

If this property is present in a stack's config file, the CLI will open
the and merge the listed environments during `pulumi up` et. al. If an
object-valued `pulumiConfig` property is present in the opened
environment, its values will be merged on top of the stack's config
prior to whatever operation is to be performed. If an object-valued
`environmentVariables` property is present inthe opened environment, its
values will be published as environment variables prior to the Pulumi
operation. Any values in the open environment's `pulumiConfig` or
`environmentVariables` that are marked as secret will be encrypted in
the resulting config and will be filtered from the command's logs.
2023-10-10 01:35:39 +00:00
Pat Gavlin 889c020674
[workspace] Minor simplification for config merge ()
- Unexport a function that has no callers outside the workspace package
- Rather than using validation callbacks, use a flag + conditionally
call the single validator
2023-08-30 21:49:09 +00:00
Abhinav Gupta 7aa5b77a0c
all: Reformat with gofumpt
Per team discussion, switching to gofumpt.

[gofumpt][1] is an alternative, stricter alternative to gofmt.
It addresses other stylistic concerns that gofmt doesn't yet cover.

  [1]: https://github.com/mvdan/gofumpt

See the full list of [Added rules][2], but it includes:

- Dropping empty lines around function bodies
- Dropping unnecessary variable grouping when there's only one variable
- Ensuring an empty line between multi-line functions
- simplification (`-s` in gofmt) is always enabled
- Ensuring multi-line function signatures end with
  `) {` on a separate line.

  [2]: https://github.com/mvdan/gofumpt#Added-rules

gofumpt is stricter, but there's no lock-in.
All gofumpt output is valid gofmt output,
so if we decide we don't like it, it's easy to switch back
without any code changes.

gofumpt support is built into the tooling we use for development
so this won't change development workflows.

- golangci-lint includes a gofumpt check (enabled in this PR)
- gopls, the LSP for Go, includes a gofumpt option
  (see [installation instrutions][3])

  [3]: https://github.com/mvdan/gofumpt#installation

This change was generated by running:

```bash
gofumpt -w $(rg --files -g '*.go' | rg -v testdata | rg -v compilation_error)
```

The following files were manually tweaked afterwards:

- pkg/cmd/pulumi/stack_change_secrets_provider.go:
  one of the lines overflowed and had comments in an inconvenient place
- pkg/cmd/pulumi/destroy.go:
  `var x T = y` where `T` wasn't necessary
- pkg/cmd/pulumi/policy_new.go:
  long line because of error message
- pkg/backend/snapshot_test.go:
  long line trying to assign three variables in the same assignment

I have included mention of gofumpt in the CONTRIBUTING.md.
2023-03-03 09:00:24 -08:00
Zaid Ajaj 88558b271b typing made optional in hierarchical config and relaxed stack config validation 2022-10-30 23:42:39 +01:00
Fraser Waters ea609d546f Add 'secret' to config
Also separate the validation and merging of project-to-stack values, to
allow us to apply in values even if they're secure and we don't have an
available decrypter. We can't validate that they're all correct, but it
means at least `config get` can do a best effort retrival for config
values.
2022-10-24 09:22:24 +01:00
Zaid Ajaj 9a9a39bbf9 Make sure config defined by a stack are also defined by the project + a whole bunch of tests 2022-10-04 21:13:43 +02:00
Zaid Ajaj 5bd9b80256 namespaced config values don't need the project as root namespace 2022-09-24 14:51:08 +02:00
Zaid Ajaj 7975498b71 lint 2022-09-22 18:27:08 +02:00
Zaid Ajaj d419605d1b Moaar unit tests for config validation 2022-09-22 17:32:18 +02:00