-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d70c92d
commit 581daf6
Showing
34 changed files
with
1,151 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Tests | ||
on: [pull_request] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: stable | ||
|
||
- name: Go Tests | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
amproxy | ||
packaging/*.rpm |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewCmd initializes a new command and sub-commands. | ||
func NewCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "client", | ||
Short: "Client operations.", | ||
} | ||
|
||
cmd.AddCommand( | ||
cmdSignature(), | ||
cmdTestClient(), | ||
) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package client | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/jasonhancock/amproxy/pkg/amproxy" | ||
"github.com/jasonhancock/go-helpers" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
const envKeyPrivate = "KEY_PRIVATE" | ||
|
||
func cmdSignature() *cobra.Command { | ||
var privateKey string | ||
|
||
cmd := &cobra.Command{ | ||
Use: "signature <message>", | ||
Short: "Generates a signature for the provided input message", | ||
SilenceUsage: true, | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if privateKey == "" { | ||
return errors.New("private key not specified") | ||
} | ||
|
||
msg, err := amproxy.Parse(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Println(msg.ComputeSignature(privateKey)) | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().StringVar( | ||
&privateKey, | ||
"key-private", | ||
os.Getenv(envKeyPrivate), | ||
helpers.EnvDesc("The API private key.", envKeyPrivate), | ||
) | ||
|
||
return cmd | ||
} |
Oops, something went wrong.