Skip to content

Commit c099e89

Browse files
authored
Merge pull request #23 from tonedefdev/dependabot/go_modules/golang.org/x/text-0.3.8
Bump golang.org/x/text from 0.3.7 to 0.3.8
2 parents 2e4becb + ed1d9a7 commit c099e89

22 files changed

+200
-494
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: macOS Build
22

33
on:
4+
push:
5+
branches:
6+
- main
47
pull_request:
58
branches:
69
- main

.github/workflows/ubuntu-build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Ubuntu Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test-mac:
13+
name: Build and Test Ubuntu
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Set up Go 1.x
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: ^1.19
20+
id: go
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 0
25+
- name: Build
26+
run: |
27+
mkdir $HOME/.terraform.d
28+
go build .
29+
env:
30+
HOME: /home/runner
31+
- name: Test
32+
run: |
33+
export PATH=$PATH:$PWD
34+
cd cmd
35+
go test -v -cover
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Windows Build
22

33
on:
4+
push:
5+
branches:
6+
- main
47
pull_request:
58
branches:
69
- main

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![macOS Build](https://github.com/tonedefdev/terracreds/actions/workflows/macos-pr-build-test.yml/badge.svg?branch=hotfix)](https://github.com/tonedefdev/terracreds/actions/workflows/macos-pr-build-test.yml) [![Windows Build](https://github.com/tonedefdev/terracreds/actions/workflows/win-pr-build-test.yml/badge.svg?branch=hotfix)](https://github.com/tonedefdev/terracreds/actions/workflows/win-pr-build-test.yml)
1+
[![macOS Build](https://github.com/tonedefdev/terracreds/actions/workflows/macos-build.yml/badge.svg?branch=main)](https://github.com/tonedefdev/terracreds/actions/workflows/macos-build.yml) [![Ubuntu Build](https://github.com/tonedefdev/terracreds/actions/workflows/ubuntu-build.yml/badge.svg?branch=main)](https://github.com/tonedefdev/terracreds/actions/workflows/ubuntu-build.yml) [![Windows Build](https://github.com/tonedefdev/terracreds/actions/workflows/windows-build.yml/badge.svg?branch=main)](https://github.com/tonedefdev/terracreds/actions/workflows/window-build.yml)
22

33
<img src="./img/terracreds.png" align="right" width="350" height="350">
44

@@ -78,10 +78,16 @@ brew install tonedefdev/terracreds/terracreds
7878
You'll need to download the latest binary from our release page and place it anywhere on `$PATH` of your system. You can also copy and run the following commands:
7979

8080
```bash
81-
wget https://github.com/tonedefdev/terracreds/releases/download/v2.1.3/terracreds_2.1.3_linux_amd64.tar.gz && \
82-
tar -xvf terracreds_2.1.3_linux_amd64.tar.gz && \
81+
VERSION="<REPLACE_WITH_DESIRED_VERSION_FROM_GITHUB_RELEASES>" \
82+
wget https://github.com/tonedefdev/terracreds/releases/download/v${VERSION}/terracreds_${VERSION}_linux_amd64.tar.gz && \
83+
tar -xvf terracreds_${VERSION}_linux_amd64.tar.gz && \
8384
sudo mv -f terracreds /usr/bin/terracreds && \
84-
rm -f terracreds_2.1.3_linux_amd64.tar.gz README.md
85+
rm -f terracreds_${VERSION}_linux_amd64.tar.gz README.md
86+
```
87+
88+
You can also use `homebrew` to install on `Ubuntu` machines where `brew` is available:
89+
```bash
90+
brew install tonedefdev/terracreds/terracreds
8591
```
8692

8793
The `terracreds` Linux implementation uses `gnome-keyring` in conjunction with `gnome-keyring-daemon`
@@ -132,12 +138,12 @@ go install -v
132138
Navigate to the root of the project directory and you should see the `terracreds.exe` binary for Windows or `terracreds` for macOS and Linux. On Windows, copy the `.exe` to any directory of your choosing. Be sure to add the directory on `$env:PATH` for Windows to make using the application easier. On macOS and Linux we recommend you place the binary in `/usr/bin` as this directory should already be on the `$PATH` environment variable.
133139

134140
## Upgrading
135-
If you're upgrading to the latest version of `terracreds` from a previous version use one of the methods above to install the latest binary. Once successfully installed on your system you just need to run `terracreds generate` to copy the latest version to the correct `plugins` directory for your operating system.
141+
If you're upgrading to the latest version of `terracreds` from a previous version use one of the methods above to either install the latest binary or use the package manager for your specific operating system. Once successfully installed on your system you just need to run `terracreds generate` to copy the latest version to the correct `plugins` directory for your operating system.
136142

137143
## Initial Configuration
138144
In order for `terracreds` to act as your credential provider you'll need to generate the binary and the plugin directory in the default location that Terraform looks for plugins. Specifically, for credential helpers, and for Windows, the directory is `%APPDATA%\terraform.d\plugins` and for macOS and Linux `$HOME/.terraform.d/.terraformrc`.
139145

140-
To make things as simple as possible we created a helper command to generate everthing needed to use the app. All you need to do is run the following command in `terracreds` to generate the plugin directory, and the correctly formatted binary that Terraform will use:
146+
To make things as simple as possible we created a helper command to generate everything needed to use the app. All you need to do is run the following command in `terracreds` to generate the plugin directory, and the correctly formatted binary that Terraform will use:
141147
```bash
142148
terracreds generate
143149
```
@@ -262,7 +268,7 @@ The above example would maintain the dash `[-]` in the output of the formatted T
262268
Additionally, you can use `--as-json` to return the secret names and values as a JSON string. This is printed to standard output so you can make use of shell pipes and other commands to ingest the data.
263269

264270
## Setting Up a Vault Provider
265-
> We have example [terraform](https://github.com/tonedefdev/terracreds/tree/main/terraform) code you can reference in order to setup your `AWS` or `Azure` VMs to use `terracreds` for a CI/CD piepline agent or a development workstation.
271+
> We have example [terraform](https://github.com/tonedefdev/terracreds/tree/main/terraform) code you can reference in order to setup your `AWS` or `Azure` VMs to use `terracreds` for a CI/CD pipeline agent or a development workstation.
266272
267273
> New in version `2.1.0`
268274

cmd/config_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/tonedefdev/terracreds/api"
1010
"github.com/urfave/cli/v2"
11+
"github.com/zalando/go-keyring"
1112
)
1213

1314
func app() *cli.App {
@@ -23,7 +24,11 @@ func config() Config {
2324
ConfigFile: ConfigFile{
2425
Path: path,
2526
},
26-
TerraCreds: NewTerraCreds(runtime.GOOS),
27+
TerraCreds: NewTerraCreds(),
28+
}
29+
30+
if runtime.GOOS == "linux" {
31+
keyring.MockInit()
2732
}
2833

2934
return config

cmd/create.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package cmd
22

33
import (
4-
"fmt"
54
"os"
65
"os/user"
76

8-
"github.com/fatih/color"
7+
"github.com/tonedefdev/terracreds/pkg/errors"
98
"github.com/tonedefdev/terracreds/pkg/helpers"
109
"github.com/urfave/cli/v2"
1110
)
@@ -42,8 +41,13 @@ func (cmd *Config) NewCommandCreate() *cli.Command {
4241
// newCommandActionCreate creates the secret based on the OS and type of vault
4342
func (cmd *Config) newCommandActionCreate(c *cli.Context) error {
4443
if len(os.Args) == 2 {
45-
fmt.Fprintf(color.Output, "%s: No secret name or secret was specified. Use 'terracreds create -h' to print help info\n", color.RedString("ERROR"))
46-
return nil
44+
err := &errors.CustomError{
45+
Message: "No secret name or secret was specified. Use 'terracreds create -h' to print help info",
46+
Level: "ERROR",
47+
}
48+
49+
helpers.Logging(cmd.Cfg, err.Message, err.Level)
50+
return err
4751
}
4852

4953
terraVault := cmd.NewTerraVault(c.String("name"))

cmd/delete.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88

99
"github.com/fatih/color"
10+
"github.com/tonedefdev/terracreds/pkg/errors"
1011
"github.com/tonedefdev/terracreds/pkg/helpers"
1112
"github.com/urfave/cli/v2"
1213
)
@@ -36,8 +37,13 @@ func (cmd *Config) NewCommandDelete() *cli.Command {
3637
// newCommandActionDelete deletes the secret based on the type of vault
3738
func (cmd *Config) newCommandActionDelete(c *cli.Context) error {
3839
if len(os.Args) == 2 {
39-
fmt.Fprintf(color.Output, "%s: No secret name was specified. Use 'terracreds delete -h' for help info\n", color.RedString("ERROR"))
40-
return nil
40+
err := &errors.CustomError{
41+
Message: "No secret name was specified. Use 'terracreds delete -h' to print help info",
42+
Level: "ERROR",
43+
}
44+
45+
helpers.Logging(cmd.Cfg, err.Message, err.Level)
46+
return err
4147
}
4248

4349
if !strings.Contains(os.Args[2], "-n") && !strings.Contains(os.Args[2], "--name") {

cmd/delete_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ func TestNewCommandActionDelete(t *testing.T) {
1111
terracreds := config()
1212
app := app()
1313
app.Commands = []*cli.Command{
14+
terracreds.NewCommandCreate(),
1415
terracreds.NewCommandDelete(),
1516
}
1617

1718
args := os.Args[0:1]
19+
args = append(args, "create", "--name=test", "--secret=password")
20+
app.Run(args)
21+
22+
args = os.Args[0:1]
1823
args = append(args, "delete", "--name=test")
1924
app.Run(args)
2025
}

cmd/forget.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package cmd
22

33
import (
4-
"fmt"
54
"os"
65
"os/user"
76

8-
"github.com/fatih/color"
7+
"github.com/tonedefdev/terracreds/pkg/errors"
98
"github.com/tonedefdev/terracreds/pkg/helpers"
109
"github.com/urfave/cli/v2"
1110
)
@@ -26,8 +25,13 @@ func (cmd *Config) NewCommandForget() *cli.Command {
2625
// newCommandActionForget deletes the requested secret in the vault when called by 'terraform logout'
2726
func (cmd *Config) newCommandActionForget(c *cli.Context) error {
2827
if len(os.Args) == 2 {
29-
fmt.Fprintf(color.Output, "%s: No secret name or secret was specified. Use 'terracreds create -h' to print help info\n", color.RedString("ERROR"))
30-
return nil
28+
err := &errors.CustomError{
29+
Message: "No secret name or secret was specified. Use 'terracreds forget -h' to print help info",
30+
Level: "ERROR",
31+
}
32+
33+
helpers.Logging(cmd.Cfg, err.Message, err.Level)
34+
return err
3135
}
3236

3337
terraVault := cmd.NewTerraVault(os.Args[2])

cmd/forget_test.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,19 @@ import (
77
"github.com/urfave/cli/v2"
88
)
99

10-
func TestNewCommandActionCreateTemp(t *testing.T) {
10+
func TestNewCommandActionForget(t *testing.T) {
1111
terracreds := config()
1212
app := app()
1313
app.Commands = []*cli.Command{
1414
terracreds.NewCommandCreate(),
15+
terracreds.NewCommandForget(),
1516
}
1617

1718
args := os.Args[0:1]
1819
args = append(args, "create", "--name=test", "--secret=password")
1920
app.Run(args)
20-
}
2121

22-
func TestNewCommandActionForget(t *testing.T) {
23-
terracreds := config()
24-
app := app()
25-
app.Commands = []*cli.Command{
26-
terracreds.NewCommandForget(),
27-
}
28-
29-
args := os.Args[0:1]
22+
args = os.Args[0:1]
3023
args = append(args, "forget", "test")
3124
app.Run(args)
3225
}

0 commit comments

Comments
 (0)