Skip to content

Commit

Permalink
Add first data_source using terraform-plugin-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed Dec 15, 2023
1 parent 0a7f43c commit 95dfae2
Show file tree
Hide file tree
Showing 11 changed files with 1,035 additions and 57 deletions.
55 changes: 51 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,59 @@
package main

import (
"github.com/hashicorp/terraform-plugin-sdk/plugin"
"context"
"flag"
"log"

"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server"
"github.com/hashicorp/terraform-plugin-mux/tf5muxserver"
"github.com/terraform-providers/terraform-provider-outscale/outscale"
vers "github.com/terraform-providers/terraform-provider-outscale/version"
)

var (
version string = vers.GetVersion()
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: outscale.Provider,
})

var debug bool

flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()

providers := []func() tfprotov5.ProviderServer{
providerserver.NewProtocol5(outscale.New(version)), // Example terraform-plugin-framework provider
outscale.Provider().GRPCProvider, // Example terraform-plugin-sdk provider
}

//using muxer
muxServer, err := tf5muxserver.NewMuxServer(context.Background(), providers...)

if err != nil {
log.Fatal(err)
}

var serveOpts []tf5server.ServeOpt

if debug {
serveOpts = append(serveOpts, tf5server.WithManagedDebug())
}

err = tf5server.Serve(
"registry.terraform.io/providers/outscale/outscale/",
muxServer.ProviderServer,
serveOpts...,
)

if err != nil {
log.Fatal(err)
}
}

// plugin.Serve(&plugin.ServeOpts{
// ProviderFunc: outscale.Provider,
// })
//}
3 changes: 1 addition & 2 deletions outscale/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"net/http"

"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
oscgo "github.com/outscale/osc-sdk-go/v2"
"github.com/terraform-providers/terraform-provider-outscale/version"
)
Expand Down Expand Up @@ -65,6 +65,5 @@ func (c *Config) Client() (*OutscaleClient, error) {
client := &OutscaleClient{
OSCAPI: oscClient,
}

return client, nil
}
30 changes: 0 additions & 30 deletions outscale/data_source_outscale_quota_test.go

This file was deleted.

Loading

0 comments on commit 95dfae2

Please sign in to comment.