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

Keyring debugging and error handling, support darwin/arm64 #147

Merged
merged 4 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading