Skip to content

Commit

Permalink
Merge pull request #147 from simpsora/keyring_debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz committed Jun 29, 2023
2 parents 4752e85 + 314aa8f commit 2ff0299
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
15 changes: 12 additions & 3 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var addCmd = &cobra.Command{
PreRun: func(cmd *cobra.Command, args []string) {
if verbose {
log.SetLevel(log.DebugLevel)
keyring.Debug = true
}
},
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -169,14 +170,22 @@ var addCmd = &cobra.Command{
log.Fatal(err)
}

ring, _ := keyring.Open(keyringDefaults)
ring, err := keyring.Open(keyringDefaults)
if err != nil {
log.Fatalf("failed to open keyring backend: %s", strings.ToLower(err.Error()))
}

_ = ring.Set(keyring.Item{
resp := ring.Set(keyring.Item{
Key: fmt.Sprintf("%s-%s", profileName, authType),
Data: []byte(authValue),
})

fmt.Println("\nSuccess! Credentials have been set and are now ready for use!")
if resp == nil {
fmt.Println("\nSuccess! Credentials have been set and are now ready for use!")
} else {
// error of some sort
log.Fatal("Error adding credentials to keyring: ", resp)
}
},
}

Expand Down
1 change: 1 addition & 0 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var execCmd = &cobra.Command{
PreRun: func(cmd *cobra.Command, args []string) {
if verbose {
log.SetLevel(log.DebugLevel)
keyring.Debug = true
}
},
Run: func(cmd *cobra.Command, args []string) {
Expand Down
12 changes: 6 additions & 6 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ -d build ]; then
fi
mkdir -p build

platforms=("windows/amd64" "linux/amd64" "darwin/amd64")
platforms=("windows/amd64" "linux/amd64" "darwin/amd64" "darwin/arm64")

echo "==> Build started for v${version}"

Expand All @@ -35,9 +35,9 @@ do
GCFLAGS="-gcflags=all=-trimpath=$GOPATH -asmflags=all=-trimpath=$GOPATH"

if [ $GOOS = "windows" ]; then
env GOOS=$GOOS GOARCH=$GOARCH go build $GCFLAGS -o "build/${GOOS}/cf-vault.exe" -ldflags "-X github.com/jacobbednarz/cf-vault/cmd.Rev=${version_with_sha}" .
env GOOS=$GOOS GOARCH=$GOARCH go build $GCFLAGS -o "build/${GOOS}/${GOARCH}/cf-vault.exe" -ldflags "-X github.com/jacobbednarz/cf-vault/cmd.Rev=${version_with_sha}" .
else
env GOOS=$GOOS GOARCH=$GOARCH go build $GCFLAGS -o "build/${GOOS}/cf-vault" -ldflags "-X github.com/jacobbednarz/cf-vault/cmd.Rev=${version_with_sha}" .
env GOOS=$GOOS GOARCH=$GOARCH go build $GCFLAGS -o "build/${GOOS}/${GOARCH}/cf-vault" -ldflags "-X github.com/jacobbednarz/cf-vault/cmd.Rev=${version_with_sha}" .
fi
if [ $? -ne 0 ]; then
echo "Building the binary has failed!"
Expand All @@ -48,9 +48,9 @@ do

printf "==> Tarballing %s\t%s\n" "$platform" "build/${output_name}.tar.gz" | expand -t 30
if [ $GOOS = "windows" ]; then
tar -czf "build/${output_name}.tar.gz" -C "build/$GOOS" "cf-vault.exe"
tar -czf "build/${output_name}.tar.gz" -C "build/$GOOS/$GOARCH" "cf-vault.exe"
else
tar -czf "build/${output_name}.tar.gz" -C "build/$GOOS" "cf-vault"
tar -czf "build/${output_name}.tar.gz" -C "build/$GOOS/$GOARCH" "cf-vault"
fi

if [ $? -ne 0 ]; then
Expand All @@ -59,7 +59,7 @@ do
fi

echo "==> Adding file checksums to build/checksums.txt"
shasum -a 256 build/$GOOS/* >> "build/checksums.txt"
shasum -a 256 build/$GOOS/$GOARCH/* >> "build/checksums.txt"
done

shasum -a 256 build/*.tar.gz >> "build/checksums.txt"
Expand Down

0 comments on commit 2ff0299

Please sign in to comment.