Skip to content

Commit 325e445

Browse files
committed
spire package with tests
Signed-off-by: pxp928 <parth.psu@gmail.com>
1 parent 4c021dc commit 325e445

File tree

221 files changed

+30423
-728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+30423
-728
lines changed

go.mod

+11-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ require (
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198
1818
github.com/pkg/errors v0.9.1
19+
github.com/spiffe/go-spiffe/v2 v2.1.0
20+
github.com/spiffe/spire-api-sdk v1.3.1
1921
github.com/tektoncd/plumbing v0.0.0-20220329085922-d765a5cba75f
2022
go.opencensus.io v0.23.0
2123
go.uber.org/zap v1.19.1
@@ -31,6 +33,12 @@ require (
3133
sigs.k8s.io/yaml v1.3.0
3234
)
3335

36+
require (
37+
github.com/Microsoft/go-winio v0.5.2 // indirect
38+
github.com/zeebo/errs v1.2.2 // indirect
39+
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
40+
)
41+
3442
require (
3543
cloud.google.com/go/compute v1.5.0 // indirect
3644
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
@@ -115,7 +123,7 @@ require (
115123
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect
116124
github.com/sirupsen/logrus v1.8.1 // indirect
117125
github.com/spf13/pflag v1.0.5 // indirect
118-
github.com/stretchr/testify v1.7.0 // indirect
126+
github.com/stretchr/testify v1.7.1 // indirect
119127
github.com/tektoncd/resolution v0.0.0-20220331203013-e4203c70c5eb
120128
github.com/vbatts/tar-split v0.11.2 // indirect
121129
go.uber.org/atomic v1.9.0 // indirect
@@ -135,8 +143,8 @@ require (
135143
google.golang.org/api v0.70.0 // indirect
136144
google.golang.org/appengine v1.6.7 // indirect
137145
google.golang.org/genproto v0.0.0-20220303160752-862486edd9cc // indirect
138-
google.golang.org/grpc v1.44.0 // indirect
139-
google.golang.org/protobuf v1.27.1 // indirect
146+
google.golang.org/grpc v1.46.0
147+
google.golang.org/protobuf v1.28.0 // indirect
140148
gopkg.in/inf.v0 v0.9.1 // indirect
141149
gopkg.in/yaml.v2 v2.4.0 // indirect
142150
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

+19-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/spire/config/config.go

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright 2019 The Tekton Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package config
18+
19+
import (
20+
"fmt"
21+
"sort"
22+
"strings"
23+
)
24+
25+
// SpireConfig holds the images reference for a number of container images used
26+
// across tektoncd pipelines.
27+
type SpireConfig struct {
28+
TrustDomain string
29+
SocketPath string
30+
ServerAddr string
31+
NodeAliasPrefix string
32+
33+
// MockSpire only to be used for testing the controller, will not exhibit
34+
// all characteristics of spire since it is only being used in the context
35+
// of process memory.
36+
MockSpire bool
37+
}
38+
39+
// Validate returns an error if any image is not set.
40+
func (c SpireConfig) Validate() error {
41+
var unset []string
42+
for _, f := range []struct {
43+
v, name string
44+
}{
45+
{c.TrustDomain, "spire-trust-domain"},
46+
{c.SocketPath, "spire-socket-path"},
47+
{c.ServerAddr, "spire-server-addr"},
48+
{c.NodeAliasPrefix, "spire-node-alias-prefix"},
49+
} {
50+
if f.v == "" {
51+
unset = append(unset, f.name)
52+
}
53+
}
54+
if len(unset) > 0 {
55+
sort.Strings(unset)
56+
return fmt.Errorf("found unset image flags: %s", unset)
57+
}
58+
59+
if !strings.HasPrefix(c.NodeAliasPrefix, "/") {
60+
return fmt.Errorf("Spire node alias should start with a /")
61+
}
62+
63+
return nil
64+
}

0 commit comments

Comments
 (0)