Skip to content
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

Add arm64 support for M1 Mac, replace golint #46

Merged
merged 28 commits into from Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a56dccd
ignore vscode files
physik932 Mar 29, 2022
37929d2
bump version of gomock for arm
physik932 Mar 29, 2022
3d4c258
add arm64 as supported release arch
physik932 Mar 29, 2022
3389d65
add go-version file for asdf and goenv users
physik932 Mar 29, 2022
092cb27
update versions referenced in contributing docs
physik932 Mar 29, 2022
2d33063
remove second param in DoAndReturn - breaking change introduced by la…
physik932 Mar 29, 2022
d1c5972
remove golint for now
physik932 Apr 1, 2022
8450146
add arm64 to sopstoolinstall script
physik932 Apr 1, 2022
9dd176d
an attempt and more verbose install docs
physik932 Apr 1, 2022
2cd7c3d
golangci-lint support
physik932 Apr 1, 2022
794ad8b
fix golangci-lint in travis
physik932 Apr 1, 2022
9f9e518
lint: remove trailing newline
physik932 Apr 4, 2022
07b9845
fmt sprintf not needed for multiline string
physik932 Apr 4, 2022
5b2353c
use less stutter in class naming
physik932 Apr 4, 2022
e828bad
rename test helper without underscore
physik932 Apr 4, 2022
2aea030
use shorter name for os wrap instance
physik932 Apr 4, 2022
e7a50cf
smaller oswrap instance name
physik932 Apr 4, 2022
ed9a397
remove redundant return statement
physik932 Apr 4, 2022
0007afb
add new archive step with arch, add id, specify in brewfile
physik932 Apr 4, 2022
0667efe
use golangci-lint tap to install latest
physik932 Apr 4, 2022
03f3f2a
update style doc for golangcilint
physik932 Apr 4, 2022
7606726
more arch additions
onyxraven Apr 4, 2022
a616f92
also have to add to installer
onyxraven Apr 4, 2022
0b903af
add binary based on goreleaser builds
physik932 Apr 5, 2022
27287ab
add note about docker build for linuxamd64
physik932 Apr 6, 2022
5a8b8c3
add note about releases
physik932 Apr 6, 2022
1bc64f6
Update README.md
physik932 Apr 6, 2022
004bbf7
accidentally an L
physik932 Apr 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .codeclimate.yml
@@ -1,7 +1,5 @@
---
engines:
golint:
enabled: true
physik932 marked this conversation as resolved.
Show resolved Hide resolved
gofmt:
enabled: true
govet:
Expand Down
87 changes: 52 additions & 35 deletions .github/CONTRIBUTING.md
Expand Up @@ -2,66 +2,83 @@

## Getting Started

## Layout

This is a single top-level namespace filled with packages. Each directory is potentially a package. Binary builds are done on packages with a main subpackage.

## Building Locally
## Install Golang

### Go Version
### Using asdf-vm
We utilize a `.go-version` file that can be used by [asdf-vm](https://github.com/kennyp/asdf-golang) like so:

Requires Go `>= 1.14`.
```bash
cd /path/to/sopstool/repository/
asdf plugin add golang
asdf install golang
```

1. Install go (currently 1.14)
### Using goenv

You may want to use a version manager.
[goenv](https://github.com/syndbg/goenv) will prefer the `GOENV_VERSION` environment variable first before looking for the `.go-version` file when [determining which Golang version](https://github.com/syndbg/goenv/blob/master/HOW_IT_WORKS.md#choosing-the-go-version) to install. If you do not have this set (`echo $GOENV_VERSION` is empty), install like so:

- [asdf](https://github.com/kennyp/asdf-golang)
```bash
cd /path/to/sopstool/repository/
goenv install
```

```sh
asdf install golang 1.14
# use global to update default go version. local set just for current directory
asdf local golang 1.14
```
### Using gimme
[gimme](https://github.com/travis-ci/gimme) uses `eval` in a simple way:

- [goenv](https://github.com/syndbg/goenv) is another option.
```bash
eval "$(gimme 1.17)"
```

```sh
goenv install 1.14
go version
# go version go1.14 darwin/amd64
```
### From the developers

- [gimme](https://github.com/travis-ci/gimme)
You can download and install the Golang [directly from the website](https://go.dev/dl/).

1. Install gomock
### Additional Go Libraries

```sh
go get -u github.com/golang/mock/gomock && go install github.com/golang/mock/mockgen
```
Install [gomock](https://github.com/golang/mock)

```sh
go get -u github.com/golang/mock/gomock && go install github.com/golang/mock/mockgen
```

### Build
Install [golangci-lint](https://golangci-lint.run/)

With go 1.11+ and addition of [Modules](https://github.com/golang/go/wiki/Modules), go projects can be located outside the GOPATH.
```sh
brew tap golangci/tap
brew install golangci/tap/golangci-lint
```

## Build

If you are having issues review [faq](https://github.com/golang/go/wiki/Modules#faqs--most-common)
With Go 1.11+ and addition of [Modules](https://github.com/golang/go/wiki/Modules), Go projects can be located outside the `$GOPATH`.

If generate has already run, then it does not need to run again.
If you are having issues, review the [FAQ](https://github.com/golang/go/wiki/Modules#faqs--most-common).

If `generate` has already run, then it does not need to run again.

```sh
go build
go fmt ./...
golint ./...
physik932 marked this conversation as resolved.
Show resolved Hide resolved
physik932 marked this conversation as resolved.
Show resolved Hide resolved
```

### Unit Test
## Unit Tests

Each module is unit tested, and passes all tests.

```sh
go test ./...
```

## Linting

`golangci-lint` runs several popular Go linters quickly:

```sh
golangci-lint run
```

## Releasing

This project uses [GoReleaser](https://goreleaser.com/) for builds and releases. Doing the tag/release below triggers the appropriate actions.
Expand All @@ -70,25 +87,25 @@ This project uses [GoReleaser](https://goreleaser.com/) for builds and releases.

You can preview the package changes by running `scripts/release-preview`. This will show a summary of changes since the last release.

1. Prepare the release
1. Prepare the release:

```sh
git checkout master && git pull
```

Commit and tag with the intended version bump
Commit and tag with the intended version bump:

```sh
git commit -am "Tagging release $VERSION" && git tag v$VERSION
```

for example:
For example:

```sh
git commit -am "Tagging release 0.1.1" && git tag v0.1.1
```

Then push the tag and commit to github
Then push the tag and commit to Github:

```sh
git push && git push --tags # or git push --follow-tags but YMMV
Expand Down Expand Up @@ -133,4 +150,4 @@ Document all public APIs to help users understand the module at a glance. Also c

### Style

Clean up style warnings thrown by gofmt/golint (configured at the base of this repository). These will be marked as build failures in CI. Also consider using 'gofmt' to automatically clean up your code style while conforming to the configuration.
Clean up style warnings thrown by gofmt/golangci-lint (configured at the base of this repository in `.golangci.yml`). These will be marked as build failures in CI. Also consider using these tools to automatically clean up your code style while conforming to the configuration.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@ sopstool
c.out
*.cover
.idea
.vscode
1 change: 1 addition & 0 deletions .go-version
@@ -0,0 +1 @@
1.17
20 changes: 20 additions & 0 deletions .golangci.yml
@@ -0,0 +1,20 @@
run:
physik932 marked this conversation as resolved.
Show resolved Hide resolved
timeout: 2m

linters:
disable-all: true
enable:
# defaults
- govet
- staticcheck
- gosimple
- typecheck
- revive
# additional
- goimports
- gosec
- misspell
- whitespace

output:
format: colored-line-number
8 changes: 6 additions & 2 deletions .goreleaser.yml
Expand Up @@ -7,12 +7,14 @@ builds:
- darwin
- linux
goarch:
# sops is only available for amd64
- amd64
- arm64
onyxraven marked this conversation as resolved.
Show resolved Hide resolved
physik932 marked this conversation as resolved.
Show resolved Hide resolved

archives:
- id: zips
name_template: "{{ .ProjectName }}_{{ .Os }}"
physik932 marked this conversation as resolved.
Show resolved Hide resolved
- id: newzips
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
physik932 marked this conversation as resolved.
Show resolved Hide resolved

checksum:
# You can change the name of the checksums file.
Expand Down Expand Up @@ -41,7 +43,9 @@ nfpms:
- sops

brews:
- tap:
- ids:
- newzips
tap:
# Repo to push the tap
owner: Ibotta
name: homebrew-public
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -45,10 +45,12 @@ cache:
- "$HOME/gopath/pkg/mod"

before_script:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
physik932 marked this conversation as resolved.
Show resolved Hide resolved
- go mod download && go build

script:
# See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
- 'golangci-lint run'
- 'if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then bash go test ./...; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./scripts/coverage_test; fi'

Expand Down
1 change: 0 additions & 1 deletion cmd/clean.go
Expand Up @@ -39,7 +39,6 @@ func CleanCommand(cmd *cobra.Command, args []string) error {
return err
}
}

}

return nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Expand Up @@ -30,9 +30,9 @@ var encrypter filecrypt.FileCrypt = filecrypt.SopsCryptInstance()
var RootCmd = &cobra.Command{
Use: "sopstool",
Short: "Wrapper around sops for multiple files",
Long: fmt.Sprintf(`sopstool
Long: `sopstool

sops wrapper supporting multiple files and helper commands.`),
sops wrapper supporting multiple files and helper commands.`,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
2 changes: 1 addition & 1 deletion filecrypt/sops.go
Expand Up @@ -12,7 +12,7 @@ type sopsCrypt struct {

var sops = sopsCrypt{
execWrap: oswrap.ExecWrapInstance(),
osWrap: oswrap.OsWrapInstance(),
osWrap: oswrap.Instance(),
}

// SopsCryptInstance gets an instance of the sops wrapper
Expand Down
8 changes: 0 additions & 8 deletions filecrypt/sops_test.go
Expand Up @@ -25,7 +25,6 @@ func TestEncryptFile(t *testing.T) {
}

sops.execWrap = origEw
return
})
}

Expand All @@ -46,7 +45,6 @@ func TestDecryptFile(t *testing.T) {
}

sops.execWrap = origEw
return
})
t.Run("run dec returns error", func(t *testing.T) {
ctrl := gomock.NewController(t)
Expand All @@ -63,7 +61,6 @@ func TestDecryptFile(t *testing.T) {
}

sops.execWrap = origEw
return
})
}

Expand All @@ -84,7 +81,6 @@ func TestDecryptFilePrint(t *testing.T) {
}

sops.execWrap = origEw
return
})
}

Expand All @@ -105,7 +101,6 @@ func TestRemoveFile(t *testing.T) {
}

sops.osWrap = origOw
return
})
}

Expand All @@ -126,7 +121,6 @@ func TestRemoveCryptFile(t *testing.T) {
}

sops.osWrap = origOw
return
})
}

Expand All @@ -146,7 +140,6 @@ func TestRotateFile(t *testing.T) {
}

sops.execWrap = origEw
return
})
}

Expand All @@ -166,6 +159,5 @@ func TestEditFile(t *testing.T) {
}

sops.execWrap = origEw
return
})
}
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -3,7 +3,7 @@ module github.com/Ibotta/sopstool
go 1.17

require (
github.com/golang/mock v1.5.0
github.com/golang/mock v1.6.0
github.com/mozilla-services/yaml v0.0.0-20201007153854-c369669a6625
github.com/spf13/cobra v1.2.1
)
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Expand Up @@ -87,6 +87,8 @@ github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -446,6 +448,7 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion oswrap/exec.go
Expand Up @@ -13,7 +13,7 @@ type ExecWrap interface {

type execWrap struct{}

//todo use OsWrapInstance() instead of package local ow?
//todo use oswrap.Instance() instead of package local ow?
var ew ExecWrap = execWrap{}

// ExecWrapInstance gets the execution wrapper interface
Expand Down