Commit Graph

10 Commits

Author SHA1 Message Date
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
Abhinav Gupta 1158d4acee
all: Drop ioutil
Stop using io/ioutil across the entire repository.
The io/ioutil package was deprecated in Go 1.16 (2021-02)
with replacements provided in other packages.
Specifically:

    ioutil.Discard   => io.Discard
    ioutil.NopCloser => io.NopCloser
    ioutil.ReadAll   => io.ReadAll
    ioutil.ReadFile  => os.ReadFile
    ioutil.TempDir   => os.MkdirTemp
    ioutil.TempFile  => os.CreateTemp
    ioutil.WriteFile => os.WriteFile

This change switches all of these entities
across the repository.

Following this change,
the only references to ioutil are in schema files:

    % rg -l ioutil
    pkg/codegen/testing/test/testdata/aws-4.26.0.json
    pkg/codegen/testing/test/testdata/aws-4.36.0.json
    pkg/codegen/testing/test/testdata/aws-4.37.1.json
    pkg/codegen/testing/test/testdata/aws-5.4.0.json
    pkg/codegen/testing/test/testdata/aws-5.16.2.json

The bulk of this change was generated automatically
with manual touch ups afterwards.
2023-01-06 16:35:14 -08:00
Aaron Friel a74886120d yamlutil: Export 2-space encoder and refactor encoding package to use 2022-12-10 14:26:14 -08:00
Aaron Friel 5666684030 cli: Implement comment preserving edits on config, projects 2022-12-10 12:29:33 -08:00
Fraser Waters 53f28c487e
Consistently disable HTML escaping in JSON output ()
* Consistently disable HTML escaping in JSON output

* Add to CHANGELOG

* Add test

* fix warning

* Add RawJSON

* Change to RawJSON

* Change MarshalIndent to JSON

* Don't try to replace everywhere

* Targeted fix for stack state
2022-08-19 13:27:34 +01:00
Ian Wahbe 9bb8efe597
Add gzip flag to filestate backend ()
* add gzip compression in filestate backend

New versions of pulumi can now read json files wrapped in .gz
Compression is disabled by default, can be enabled via:
  PULUMI_SELF_MANAGED_STATE_GZIP=true

* functionnal test for gzip filestate

* update CHANGELOG_PENDING.md

* Move compression to encoding

* Update changelog

* Clean up tests

* Adjust IsCompressed check

* Don't leave out of data state files

Co-authored-by: Arthur Woimbée <arthur@extrality.ai>
Co-authored-by: Arthur Woimbée <arthur.woimbee@gmail.com>
2022-05-23 12:13:21 -07:00
Fraser Waters b39c81e4cb
Improve error message and add test for ()
* Improve error message and add test for 

* lint

* lint

* Use %w instead of errors.Wrap
2021-10-26 16:55:52 +01:00
Levi Blackstone 2dad8a6649
Revert "Swap out YAML parser library ()" ()
This reverts commit ff2cf70
2021-04-01 14:44:29 -06:00
Levi Blackstone ff2cf701a7
Swap out YAML parser library ()
Related to 
2021-03-29 14:49:00 -06:00
evanboyle cdfb8608c9 move pkg/encoding -> sdk/go/common/encoding 2020-03-18 15:28:19 -07:00