Skip to content

Commit b311e15

Browse files
Add pkg to Dockerfile and Fix TLS issue (#67)
1 parent 5ed7ddf commit b311e15

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN go mod download
1515
COPY main.go main.go
1616
COPY api/ api/
1717
COPY controllers/ controllers/
18+
COPY pkg/ pkg/
1819

1920
# Build
2021
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -a -ldflags '-s -w' -o manager main.go

pkg/clusteragent/clusteragent.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ import (
1919
type Options struct {
2020
// IgnoreMachineNames is a set of ignored machine names that we don't want to pick their IP for the cluster agent endpoint.
2121
IgnoreMachineNames sets.String
22-
// InsecureSkipVerify skips the verification of the server's certificate chain and host name.
23-
// This is mostly used for testing purposes.
24-
InsecureSkipVerify bool
2522
}
2623

2724
type Client struct {
@@ -51,18 +48,19 @@ func NewClient(machines []clusterv1.Machine, port string, timeout time.Duration,
5148
return nil, errors.New("failed to find an IP for cluster agent")
5249
}
5350

54-
transport := &http.Transport{
55-
TLSClientConfig: &tls.Config{
56-
InsecureSkipVerify: opts.InsecureSkipVerify,
57-
},
58-
}
59-
6051
return &Client{
6152
ip: ip,
6253
port: port,
6354
client: &http.Client{
64-
Timeout: timeout,
65-
Transport: transport,
55+
Timeout: timeout,
56+
Transport: &http.Transport{
57+
TLSClientConfig: &tls.Config{
58+
// TODO(Hue): Workaround for now, address later on
59+
// get the certificate fingerprint from the matching node through a resource in the cluster (TBD),
60+
// and validate it in the TLSClientConfig
61+
InsecureSkipVerify: true,
62+
},
63+
},
6664
},
6765
}, nil
6866
}

pkg/clusteragent/clusteragent_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestDo(t *testing.T) {
145145
},
146146
},
147147
},
148-
}, port, time.Second, clusteragent.Options{InsecureSkipVerify: true})
148+
}, port, time.Second, clusteragent.Options{})
149149

150150
g.Expect(err).ToNot(HaveOccurred())
151151

pkg/clusteragent/remove_node_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestRemoveFromDqlite(t *testing.T) {
3434
},
3535
},
3636
},
37-
}, port, time.Second, clusteragent.Options{InsecureSkipVerify: true})
37+
}, port, time.Second, clusteragent.Options{})
3838

3939
g.Expect(err).ToNot(HaveOccurred())
4040
g.Expect(c.RemoveNodeFromDqlite(context.Background(), "1.1.1.1:1234")).To(Succeed())

0 commit comments

Comments
 (0)