Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3ba8242

Browse files
authored
feat: Add provisionerd service (#127)
This brings an async service that parses andprovisions to life! It's separated from coderdintentionally to allow for simpler testing.Integration with coderd will come in another PR!
1 parent38867b0 commit3ba8242

File tree

12 files changed

+1018
-50
lines changed

12 files changed

+1018
-50
lines changed

‎go.mod‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ replace github.com/hashicorp/terraform-config-inspect => github.com/kylecarbs/te
1010

1111
require (
1212
cdr.dev/slogv1.4.1
13+
github.com/coder/retryv1.3.0
1314
github.com/go-chi/chi/v5v5.0.7
1415
github.com/go-chi/renderv1.0.1
1516
github.com/go-playground/validator/v10v10.10.0
@@ -18,6 +19,7 @@ require (
1819
github.com/hashicorp/go-versionv1.4.0
1920
github.com/hashicorp/terraform-config-inspectv0.0.0-20211115214459-90acf1ca460f
2021
github.com/hashicorp/terraform-execv0.15.0
22+
github.com/hashicorp/yamuxv0.0.0-20211028200310-0bc27b27de87
2123
github.com/justinas/nosurfv1.1.1
2224
github.com/lib/pqv1.10.4
2325
github.com/moby/mobyv20.10.12+incompatible

‎go.sum‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWH
232232
github.com/cockroachdb/apdv1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
233233
github.com/cockroachdb/cockroach-go/v2v2.1.1/go.mod h1:7NtUnP6eK+l6k483WSYNrq3Kb23bWV10IRV1TyeSpwM=
234234
github.com/cockroachdb/datadrivenv0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
235+
github.com/coder/retryv1.3.0 h1:5lAAwt/2Cm6lVmnfBY7sOMXcBOwcwJhmV5QGSELIVWY=
236+
github.com/coder/retryv1.3.0/go.mod h1:tXuRgZgWjUnU5LZPT4lJh4ew2elUhexhlnXzrJWdyFY=
235237
github.com/containerd/aufsv0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
236238
github.com/containerd/aufsv0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU=
237239
github.com/containerd/aufsv0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU=
@@ -688,6 +690,8 @@ github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKEN
688690
github.com/hashicorp/serfv0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
689691
github.com/hashicorp/terraform-jsonv0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY=
690692
github.com/hashicorp/terraform-jsonv0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk=
693+
github.com/hashicorp/yamuxv0.0.0-20211028200310-0bc27b27de87 h1:xixZ2bWeofWV68J+x6AzmKuVM/JWCQwkWm6GW/MUR6I=
694+
github.com/hashicorp/yamuxv0.0.0-20211028200310-0bc27b27de87/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
691695
github.com/hpcloud/tailv1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
692696
github.com/iancoleman/strcasev0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
693697
github.com/ianlancetaylor/demanglev0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=

‎peerbroker/dial_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/pion/webrtc/v3"
88
"github.com/stretchr/testify/require"
99
"go.uber.org/goleak"
10-
"storj.io/drpc/drpcconn"
1110

1211
"cdr.dev/slog"
1312
"cdr.dev/slog/sloggers/slogtest"
@@ -37,7 +36,7 @@ func TestDial(t *testing.T) {
3736
})
3837
require.NoError(t,err)
3938

40-
api:=proto.NewDRPCPeerBrokerClient(drpcconn.New(client))
39+
api:=proto.NewDRPCPeerBrokerClient(provisionersdk.Conn(client))
4140
stream,err:=api.NegotiateConnection(ctx)
4241
require.NoError(t,err)
4342
clientConn,err:=peerbroker.Dial(stream, []webrtc.ICEServer{{

‎peerbroker/listen.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import (
44
"context"
55
"errors"
66
"io"
7+
"net"
78
"reflect"
89
"sync"
910

1011
"github.com/pion/webrtc/v3"
1112
"golang.org/x/xerrors"
12-
"storj.io/drpc"
1313
"storj.io/drpc/drpcmux"
1414
"storj.io/drpc/drpcserver"
1515

@@ -19,7 +19,7 @@ import (
1919

2020
// Listen consumes the transport as the server-side of the PeerBroker dRPC service.
2121
// The Accept function must be serviced, or new connections will hang.
22-
funcListen(transport drpc.Transport,opts*peer.ConnOptions) (*Listener,error) {
22+
funcListen(connListener net.Listener,opts*peer.ConnOptions) (*Listener,error) {
2323
ctx,cancelFunc:=context.WithCancel(context.Background())
2424
listener:=&Listener{
2525
connectionChannel:make(chan*peer.Conn),
@@ -39,7 +39,7 @@ func Listen(transport drpc.Transport, opts *peer.ConnOptions) (*Listener, error)
3939
}
4040
srv:=drpcserver.New(mux)
4141
gofunc() {
42-
err:=srv.ServeOne(ctx,transport)
42+
err:=srv.Serve(ctx,connListener)
4343
_=listener.closeWithError(err)
4444
}()
4545

‎peerbroker/listen_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"testing"
77

88
"github.com/stretchr/testify/require"
9-
"storj.io/drpc/drpcconn"
109

1110
"github.com/coder/coder/peerbroker"
1211
"github.com/coder/coder/peerbroker/proto"
@@ -27,7 +26,7 @@ func TestListen(t *testing.T) {
2726
listener,err:=peerbroker.Listen(server,nil)
2827
require.NoError(t,err)
2928

30-
api:=proto.NewDRPCPeerBrokerClient(drpcconn.New(client))
29+
api:=proto.NewDRPCPeerBrokerClient(provisionersdk.Conn(client))
3130
stream,err:=api.NegotiateConnection(ctx)
3231
require.NoError(t,err)
3332
clientConn,err:=peerbroker.Dial(stream,nil,nil)

‎provisioner/terraform/parse_test.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"testing"
1111

1212
"github.com/stretchr/testify/require"
13-
"storj.io/drpc/drpcconn"
1413

1514
"github.com/coder/coder/provisionersdk"
1615
"github.com/coder/coder/provisionersdk/proto"
@@ -30,12 +29,12 @@ func TestParse(t *testing.T) {
3029
gofunc() {
3130
err:=Serve(ctx,&ServeOptions{
3231
ServeOptions:&provisionersdk.ServeOptions{
33-
Transport:server,
32+
Listener:server,
3433
},
3534
})
3635
require.NoError(t,err)
3736
}()
38-
api:=proto.NewDRPCProvisionerClient(drpcconn.New(client))
37+
api:=proto.NewDRPCProvisionerClient(provisionersdk.Conn(client))
3938

4039
for_,testCase:=range []struct {
4140
Namestring

‎provisioner/terraform/provision_test.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"testing"
1111

1212
"github.com/stretchr/testify/require"
13-
"storj.io/drpc/drpcconn"
1413

1514
"github.com/coder/coder/provisionersdk"
1615
"github.com/coder/coder/provisionersdk/proto"
@@ -29,12 +28,12 @@ func TestProvision(t *testing.T) {
2928
gofunc() {
3029
err:=Serve(ctx,&ServeOptions{
3130
ServeOptions:&provisionersdk.ServeOptions{
32-
Transport:server,
31+
Listener:server,
3332
},
3433
})
3534
require.NoError(t,err)
3635
}()
37-
api:=proto.NewDRPCProvisionerClient(drpcconn.New(client))
36+
api:=proto.NewDRPCProvisionerClient(provisionersdk.Conn(client))
3837

3938
for_,testCase:=range []struct {
4039
Namestring

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp