Skip to content

Commit

Permalink
Change repo structure to the more common pkg/cmd structure
Browse files Browse the repository at this point in the history
  • Loading branch information
carte7000 committed Jul 22, 2019
1 parent 9dd7edb commit 8ca7585
Show file tree
Hide file tree
Showing 33 changed files with 60 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- setup_remote_docker
- run:
name: Build Docker Image
command: docker build -t ecadlabs/signatory:$CIRCLE_TAG -e GIT_REVISION=$CIRCLE_SHA1 -e GIT_BRANCH=$CIRCLE_BRANCH -e GIT_VERSION=$CIRCLE_TAG .
command: docker build -t ecadlabs/signatory:$CIRCLE_TAG -e GIT_REVISION=$CIRCLE_SHA1 -e GIT_BRANCH=$CIRCLE_BRANCH -e GIT_VERSION=$CIRCLE_TAG -f cmd/signatory .
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
Expand Down
15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT_REVISION := $(shell git rev-parse HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

COLLECTOR_PKG = github.com/ecadlabs/signatory/metrics
COLLECTOR_PKG = github.com/ecadlabs/signatory/pkg/metrics

signatory:
go build -o sig -ldflags "-X $(COLLECTOR_PKG).GitRevision=$(GIT_REVISION) -X $(COLLECTOR_PKG).GitBranch=$(GIT_BRANCH)"
go build -ldflags "-X $(COLLECTOR_PKG).GitRevision=$(GIT_REVISION) -X $(COLLECTOR_PKG).GitBranch=$(GIT_BRANCH)" ./cmd/signatory
15 changes: 15 additions & 0 deletions cmd/signatory/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:alpine AS build-env

ENV COLLECTOR_PKG="github.com/ecadlabs/signatory/pkg/metrics"
ENV GO111MODULE="on"
WORKDIR /build/signatory
RUN apk update && apk add git openssh bash
ADD . .
RUN go build -ldflags "-X ${COLLECTOR_PKG}.GitRevision=${GIT_REVISION} -X ${COLLECTOR_PKG}.GitBranch=${GIT_REVISION} -X ${COLLECTOR_PKG}.GitVersion=${GIT_VERSION}" ./cmd/signatory

# final stage
FROM alpine
RUN apk --no-cache add ca-certificates
WORKDIR /app
COPY --from=build-env /build/signatory/signatory /app/
ENTRYPOINT /app/signatory
12 changes: 6 additions & 6 deletions main.go → cmd/signatory/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"syscall"
"time"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/metrics"
"github.com/ecadlabs/signatory/server"
"github.com/ecadlabs/signatory/signatory"
"github.com/ecadlabs/signatory/vault"
"github.com/ecadlabs/signatory/watermark"
"github.com/ecadlabs/signatory/pkg/config"
"github.com/ecadlabs/signatory/pkg/metrics"
"github.com/ecadlabs/signatory/pkg/server"
"github.com/ecadlabs/signatory/pkg/signatory"
"github.com/ecadlabs/signatory/pkg/vault"
"github.com/ecadlabs/signatory/pkg/watermark"

"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
Expand Down
8 changes: 5 additions & 3 deletions docs/yubi.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ INFO[0001] Keys discovered in Key Vault:
INFO[0001] tz2Ch1abG7FNiibmV26Uzgdsnfni9XGrk5wD (Found in vault, not configured for use in signatory.yaml)
```

You must copy your tz2 key into the `tezos.keys`
list for Signatory to carry out signing operations using this address.
You must copy your tz2 key into the `tezos`
config section for Signatory to carry out signing operations using this address.


## Testing / Verify
Expand All @@ -99,4 +99,6 @@ to investigate. If it was successful, you should see output similar to:

```
{"signature":"p2sigR4JTRTMkT4XC4NgVuGdhZDbgaaSZpNPUserkyMCTY1GQJTFpCuihFRVk9n7YaNjA5U3cNcvJPRm7C9G5A1hsLsesVPcMu"}
```
```

## Importing your existing key inside
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion metrics/vaultmetrics.go → pkg/metrics/vaultmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package metrics
import (
"strconv"

"github.com/ecadlabs/signatory/signatory"
"github.com/ecadlabs/signatory/pkg/signatory"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion server/server.go → pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/pkg/config"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion server/server_test.go → pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"net/http/httptest"
"testing"

"github.com/ecadlabs/signatory/server"
"github.com/ecadlabs/signatory/pkg/server"
)

type FakeSignatory struct {
Expand Down
4 changes: 2 additions & 2 deletions server/utility.go → pkg/server/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"
"time"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/metrics"
"github.com/ecadlabs/signatory/pkg/config"
"github.com/ecadlabs/signatory/pkg/metrics"
"github.com/gorilla/mux"
)

Expand Down
2 changes: 1 addition & 1 deletion signatory/import.go → pkg/signatory/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package signatory
import (
"encoding/base64"

"github.com/ecadlabs/signatory/tezos"
"github.com/ecadlabs/signatory/pkg/tezos"
log "github.com/sirupsen/logrus"
)

Expand Down
4 changes: 2 additions & 2 deletions signatory/import_test.go → pkg/signatory/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"reflect"
"testing"

"github.com/ecadlabs/signatory/signatory"
"github.com/ecadlabs/signatory/tezos"
"github.com/ecadlabs/signatory/pkg/signatory"
"github.com/ecadlabs/signatory/pkg/tezos"
)

func TestToJWK(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions signatory/signatory.go → pkg/signatory/signatory.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

log "github.com/sirupsen/logrus"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/crypto"
"github.com/ecadlabs/signatory/tezos"
"github.com/ecadlabs/signatory/pkg/config"
"github.com/ecadlabs/signatory/pkg/crypto"
"github.com/ecadlabs/signatory/pkg/tezos"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"testing"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/signatory"
"github.com/ecadlabs/signatory/watermark"
"github.com/ecadlabs/signatory/pkg/config"
"github.com/ecadlabs/signatory/pkg/signatory"
"github.com/ecadlabs/signatory/pkg/watermark"
)

type FakeVault struct {
Expand Down
2 changes: 1 addition & 1 deletion tezos/encoding.go → pkg/tezos/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/btcsuite/btcutil/base58"
"github.com/ecadlabs/crypto/blake2b"
"github.com/ecadlabs/signatory/crypto"
"github.com/ecadlabs/signatory/pkg/crypto"
)

// DigestFunc is an alias for blake2b checksum algorithm
Expand Down
2 changes: 1 addition & 1 deletion tezos/encoding_test.go → pkg/tezos/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/ecadlabs/signatory/tezos"
"github.com/ecadlabs/signatory/pkg/tezos"
)

func TestEncodeSig(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tezos/key.go → pkg/tezos/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/ecadlabs/crypto/blake2b"
"github.com/ecadlabs/signatory/crypto"
"github.com/ecadlabs/signatory/pkg/crypto"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion tezos/key_test.go → pkg/tezos/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/ecadlabs/signatory/tezos"
"github.com/ecadlabs/signatory/pkg/tezos"
)

func TestValidate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tezos/message.go → pkg/tezos/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"math/big"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/pkg/config"
)

// Magic Bytes of different operations
Expand Down
4 changes: 2 additions & 2 deletions tezos/message_test.go → pkg/tezos/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/tezos"
"github.com/ecadlabs/signatory/pkg/config"
"github.com/ecadlabs/signatory/pkg/tezos"
)

func TestValidateMessage(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions vault/azure.go → pkg/vault/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"net/url"
"strings"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/crypto"
"github.com/ecadlabs/signatory/signatory"
"github.com/ecadlabs/signatory/pkg/config"
"github.com/ecadlabs/signatory/pkg/crypto"
"github.com/ecadlabs/signatory/pkg/signatory"
uuid "github.com/satori/go.uuid"
)

Expand Down Expand Up @@ -431,7 +431,7 @@ func (s *AzureVault) Import(jwk *signatory.JWK) (string, error) {
return "", err
}

id, err := uuid.NewV4()
id := uuid.NewV4()

if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions vault/azure_test.go → pkg/vault/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"net/http"
"testing"

"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/vault"
"github.com/ecadlabs/signatory/pkg/config"
"github.com/ecadlabs/signatory/pkg/vault"
)

type HandleFunc func(req *http.Request) (*http.Response, error)
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions vault/yubi.go → pkg/vault/yubi.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
yubihsm "github.com/certusone/yubihsm-go"
"github.com/certusone/yubihsm-go/commands"
"github.com/certusone/yubihsm-go/connector"
"github.com/ecadlabs/signatory/config"
"github.com/ecadlabs/signatory/crypto"
"github.com/ecadlabs/signatory/signatory"
"github.com/ecadlabs/signatory/pkg/config"
"github.com/ecadlabs/signatory/pkg/crypto"
"github.com/ecadlabs/signatory/pkg/signatory"
)

// YubiHSM struct containing information required to interrogate a Yubi HSM
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion watermark/memory_test.go → pkg/watermark/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math/big"
"testing"

"github.com/ecadlabs/signatory/watermark"
"github.com/ecadlabs/signatory/pkg/watermark"
)

func TestGetSigAlg(t *testing.T) {
Expand Down
Binary file added signatory
Binary file not shown.

0 comments on commit 8ca7585

Please sign in to comment.