Skip to content

Commit 22d189d

Browse files
committed
add stub tpf provider
1 parent 72bed80 commit 22d189d

File tree

4 files changed

+97
-4
lines changed

4 files changed

+97
-4
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ require (
4949
github.com/hashicorp/logutils v1.0.0 // indirect
5050
github.com/hashicorp/terraform-exec v0.22.0 // indirect
5151
github.com/hashicorp/terraform-json v0.24.0 // indirect
52+
github.com/hashicorp/terraform-plugin-framework v1.14.1 // indirect
5253
github.com/hashicorp/terraform-plugin-go v0.26.0 // indirect
5354
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
55+
github.com/hashicorp/terraform-plugin-mux v0.18.0 // indirect
5456
github.com/hashicorp/terraform-registry-address v0.2.4 // indirect
5557
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
5658
github.com/hashicorp/yamux v0.1.1 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,14 @@ github.com/hashicorp/terraform-exec v0.22.0 h1:G5+4Sz6jYZfRYUCg6eQgDsqTzkNXV+fP8
105105
github.com/hashicorp/terraform-exec v0.22.0/go.mod h1:bjVbsncaeh8jVdhttWYZuBGj21FcYw6Ia/XfHcNO7lQ=
106106
github.com/hashicorp/terraform-json v0.24.0 h1:rUiyF+x1kYawXeRth6fKFm/MdfBS6+lW4NbeATsYz8Q=
107107
github.com/hashicorp/terraform-json v0.24.0/go.mod h1:Nfj5ubo9xbu9uiAoZVBsNOjvNKB66Oyrvtit74kC7ow=
108+
github.com/hashicorp/terraform-plugin-framework v1.14.1 h1:jaT1yvU/kEKEsxnbrn4ZHlgcxyIfjvZ41BLdlLk52fY=
109+
github.com/hashicorp/terraform-plugin-framework v1.14.1/go.mod h1:xNUKmvTs6ldbwTuId5euAtg37dTxuyj3LHS3uj7BHQ4=
108110
github.com/hashicorp/terraform-plugin-go v0.26.0 h1:cuIzCv4qwigug3OS7iKhpGAbZTiypAfFQmw8aE65O2M=
109111
github.com/hashicorp/terraform-plugin-go v0.26.0/go.mod h1:+CXjuLDiFgqR+GcrM5a2E2Kal5t5q2jb0E3D57tTdNY=
110112
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
111113
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
114+
github.com/hashicorp/terraform-plugin-mux v0.18.0 h1:7491JFSpWyAe0v9YqBT+kel7mzHAbO5EpxxT0cUL/Ms=
115+
github.com/hashicorp/terraform-plugin-mux v0.18.0/go.mod h1:Ho1g4Rr8qv0qTJlcRKfjjXTIO67LNbDtM6r+zHUNHJQ=
112116
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.0 h1:7/iejAPyCRBhqAg3jOx+4UcAhY0A+Sg8B+0+d/GxSfM=
113117
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.0/go.mod h1:TiQwXAjFrgBf5tg5rvBRz8/ubPULpU0HjSaVi5UoJf8=
114118
github.com/hashicorp/terraform-registry-address v0.2.4 h1:JXu/zHB2Ymg/TGVCRu10XqNa4Sh2bWcqCNyKWjnCPJA=

main.go

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,65 @@
11
package main
22

33
import (
4-
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
4+
"context"
5+
"flag"
6+
"log"
7+
8+
"github.com/hashicorp/terraform-plugin-framework/providerserver"
9+
10+
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
11+
"github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server"
12+
"github.com/hashicorp/terraform-plugin-mux/tf5to6server"
13+
"github.com/hashicorp/terraform-plugin-mux/tf6muxserver"
514

615
"github.com/coder/terraform-provider-coder/v2/provider"
16+
"github.com/coder/terraform-provider-coder/v2/tpfprovider"
717
)
818

919
// Run the docs generation tool, check its repository for more information on how it works and how docs
1020
// can be customized.
1121
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
1222

1323
func main() {
24+
ctx := context.Background()
25+
var debug bool
26+
flag.BoolVar(&debug, "debug", false, "enable debug logging")
27+
flag.Parse()
28+
1429
servePprof()
15-
plugin.Serve(&plugin.ServeOpts{
16-
ProviderFunc: provider.New,
17-
})
30+
31+
upgradedSDKServer, err := tf5to6server.UpgradeServer(
32+
ctx,
33+
provider.New().GRPCProvider,
34+
)
35+
if err != nil {
36+
log.Fatal(err)
37+
}
38+
39+
providers := []func() tfprotov6.ProviderServer{
40+
providerserver.NewProtocol6(tpfprovider.NewFrameworkProvider()),
41+
func() tfprotov6.ProviderServer {
42+
return upgradedSDKServer
43+
},
44+
}
45+
46+
muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...)
47+
if err != nil {
48+
log.Fatal(err)
49+
}
50+
51+
var serveOpts []tf6server.ServeOpt
52+
if debug {
53+
serveOpts = append(serveOpts, tf6server.WithManagedDebug())
54+
}
55+
56+
err = tf6server.Serve(
57+
"registry.terraform.io/coder/coder",
58+
muxServer.ProviderServer,
59+
serveOpts...,
60+
)
61+
62+
if err != nil {
63+
log.Fatal(err)
64+
}
1865
}

tpfprovider/tpfprovider.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package tpfprovider
2+
3+
import (
4+
"context"
5+
6+
"github.com/hashicorp/terraform-plugin-framework/datasource"
7+
"github.com/hashicorp/terraform-plugin-framework/provider"
8+
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
9+
"github.com/hashicorp/terraform-plugin-framework/resource"
10+
)
11+
12+
type coderProvider struct{}
13+
14+
var _ provider.Provider = (*coderProvider)(nil)
15+
16+
func NewFrameworkProvider() provider.Provider {
17+
return &coderProvider{}
18+
}
19+
20+
func (p *coderProvider) Resources(_ context.Context) []func() resource.Resource {
21+
return []func() resource.Resource{}
22+
}
23+
24+
func (p *coderProvider) DataSources(_ context.Context) []func() datasource.DataSource {
25+
return []func() datasource.DataSource{}
26+
}
27+
28+
func (p *coderProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) {
29+
resp.Schema = schema.Schema{
30+
Attributes: map[string]schema.Attribute{},
31+
}
32+
}
33+
34+
func (p *coderProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) {
35+
resp.TypeName = "coder"
36+
}
37+
38+
func (p *coderProvider) Configure(_ context.Context, _ provider.ConfigureRequest, resp *provider.ConfigureResponse) {
39+
40+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy