Skip to content
This repository was archived by the owner on Feb 7, 2020. It is now read-only.

Commit 7ddd556

Browse files
committed
(#69) rename dependencies and remove need for choria/build
1 parent f7cde17 commit 7ddd556

12 files changed

+22
-25
lines changed

glide.lock

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocol/protocol.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ const (
1212
TransportV1 = "choria:transport:1"
1313
)
1414

15+
// Secure controls the signing and validations of certificates in the protocol
16+
var Secure = "true"
17+
18+
// IsSecure determines if this build will validate senders at protocol level
19+
func IsSecure() bool {
20+
return Secure == "true"
21+
}
22+
1523
// Additional to these the package for a specific version must also provide these constructors
1624
// with signature matching those in v1/constructors.go these are in use by mcollective/protocol.gos
1725

protocol/v1/constructors.go

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

9-
"github.com/choria-io/go-choria/build"
10-
"github.com/choria-io/go-choria/protocol"
9+
"github.com/choria-io/go-protocol/protocol"
1110
)
1211

1312
// NewRequest creates a choria:request:1
@@ -167,7 +166,7 @@ func NewSecureReplyFromTransport(message protocol.TransportMessage) (secure prot
167166
func NewSecureRequest(request protocol.Request, publicCert string, privateCert string) (secure protocol.SecureRequest, err error) {
168167
pubcerttxt := []byte("insecure")
169168

170-
if build.Secure == "true" {
169+
if protocol.IsSecure() {
171170
pubcerttxt, err = readFile(publicCert)
172171
if err != nil {
173172
err = fmt.Errorf("Could not read public certificate: %s", err.Error())

protocol/v1/reply_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package v1
33
import (
44
"time"
55

6-
"github.com/choria-io/go-choria/protocol"
6+
"github.com/choria-io/go-protocol/protocol"
77
"github.com/tidwall/gjson"
88

99
. "github.com/onsi/ginkgo"

protocol/v1/request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"sync"
88
"time"
99

10-
"github.com/choria-io/go-choria/protocol"
10+
"github.com/choria-io/go-protocol/protocol"
1111
)
1212

1313
type request struct {

protocol/v1/request_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package v1
33
import (
44
"time"
55

6-
"github.com/choria-io/go-choria/protocol"
6+
"github.com/choria-io/go-protocol/protocol"
77
. "github.com/onsi/ginkgo"
88
. "github.com/onsi/gomega"
99
"github.com/tidwall/gjson"

protocol/v1/security_reply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
"sync"
1010

11-
"github.com/choria-io/go-choria/protocol"
11+
"github.com/choria-io/go-protocol/protocol"
1212
)
1313

1414
// SecureReply contains 1 serialized Reply hashed

protocol/v1/security_reply_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"crypto/sha256"
55
"encoding/base64"
66

7-
"github.com/choria-io/go-choria/protocol"
7+
"github.com/choria-io/go-protocol/protocol"
88
"github.com/tidwall/gjson"
99

1010
. "github.com/onsi/ginkgo"

protocol/v1/security_request.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import (
1818
"strings"
1919
"sync"
2020

21-
"github.com/choria-io/go-choria/build"
22-
"github.com/choria-io/go-choria/protocol"
21+
"github.com/choria-io/go-protocol/protocol"
2322
log "github.com/sirupsen/logrus"
2423
)
2524

@@ -55,7 +54,7 @@ func (r *secureRequest) SetMessage(request protocol.Request) (err error) {
5554

5655
r.Signature = "insecure"
5756

58-
if r.isSecure() {
57+
if protocol.IsSecure() {
5958
var signature []byte
6059

6160
signature, err = r.signString([]byte(j))
@@ -81,7 +80,7 @@ func (r *secureRequest) Valid() bool {
8180
r.mu.Lock()
8281
defer r.mu.Unlock()
8382

84-
if !r.isSecure() {
83+
if !protocol.IsSecure() {
8584
log.Debug("Bypassing validation on secure request due to build time flags")
8685
return true
8786
}
@@ -407,7 +406,3 @@ func readFile(path string) (cert []byte, err error) {
407406

408407
return
409408
}
410-
411-
func (r *secureRequest) isSecure() bool {
412-
return build.Secure == "true"
413-
}

protocol/v1/security_request_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"os"
1313
"path/filepath"
1414

15-
"github.com/choria-io/go-choria/protocol"
15+
"github.com/choria-io/go-protocol/protocol"
1616
. "github.com/onsi/ginkgo"
1717
. "github.com/onsi/gomega"
1818
"github.com/sirupsen/logrus"

protocol/v1/transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"sync"
99

10-
"github.com/choria-io/go-choria/protocol"
10+
"github.com/choria-io/go-protocol/protocol"
1111
)
1212

1313
type transportMessage struct {

protocol/v1/transport_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package v1
22

33
import (
4-
"github.com/choria-io/go-choria/protocol"
4+
"github.com/choria-io/go-protocol/protocol"
55
. "github.com/onsi/ginkgo"
66
. "github.com/onsi/gomega"
77
"github.com/tidwall/gjson"

0 commit comments

Comments
 (0)