Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from OpenVPN/support-user-create-roles
Browse files Browse the repository at this point in the history
Actualize imports, role for users and descriptions for route
  • Loading branch information
arslanbekov authored Nov 7, 2022
2 parents 77ecc68 + 69f520f commit 4dd021c
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 92 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
HOSTNAME=patoarvizu.dev
HOSTNAME=openvpncloud.dev
NAMESPACE=openvpn
NAME=openvpncloud
VERSION=0.0.4
VERSION=0.0.6
BINARY=terraform-provider-${NAME}
OS_ARCH=darwin_amd64

Expand Down
1 change: 1 addition & 0 deletions client/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Route struct {
Domain string `json:"domain"`
Value string `json:"value"`
NetworkItemId string `json:"networkItemId"`
Description string `json:"description"`
}

const (
Expand Down
41 changes: 37 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
module github.com/patoarvizu/terraform-provider-openvpn-cloud
module github.com/OpenVPN/terraform-provider-openvpn-cloud

go 1.16
go 1.19

require github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0

require (
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v12 v12.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v0.15.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.4.1 // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/hcl/v2 v2.8.2 // indirect
github.com/hashicorp/terraform-plugin-go v0.4.0 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.4 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.8.4 // indirect
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect
google.golang.org/grpc v1.32.0 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)
83 changes: 14 additions & 69 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/patoarvizu/terraform-provider-openvpn-cloud/openvpncloud"
"github.com/OpenVPN/terraform-provider-openvpn-cloud/openvpncloud"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/data_source_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
"time"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func dataSourceConnector() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/data_source_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
"time"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func dataSourceHost() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/data_source_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
"time"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func dataSourceNetwork() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/data_source_network_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
"time"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func dataSourceNetworkRoutes() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/data_source_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
"time"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func dataSourceUser() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/data_source_user_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
"time"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func dataSourceUserGroup() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/data_source_vpn_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
"time"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func dataSourceVpnRegion() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"fmt"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

type Token struct {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/resource_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package openvpncloud
import (
"context"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func resourceConnector() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/resource_dns_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package openvpncloud
import (
"context"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func resourceDnsRecord() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/resource_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"hash/fnv"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func resourceHost() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion openvpncloud/resource_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package openvpncloud
import (
"context"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func resourceNetwork() *schema.Resource {
Expand Down
13 changes: 10 additions & 3 deletions openvpncloud/resource_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package openvpncloud
import (
"context"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func resourceRoute() *schema.Resource {
return &schema.Resource{
Description: "Use `openvpncloud_route` to create a route on an OpenVPN Cloud network.",
CreateContext: resourceRouteCreate,
UpdateContext: resourceRouteCreate,
ReadContext: resourceRouteRead,
DeleteContext: resourceRouteDelete,
Importer: &schema.ResourceImporter{
Expand All @@ -38,6 +39,10 @@ func resourceRoute() *schema.Resource {
ForceNew: true,
Description: "The id of the network on which to create the route.",
},
"description": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand All @@ -48,9 +53,11 @@ func resourceRouteCreate(ctx context.Context, d *schema.ResourceData, m interfac
networkItemId := d.Get("network_item_id").(string)
routeType := d.Get("type").(string)
routeValue := d.Get("value").(string)
descriptionValue := d.Get("description").(string)
r := client.Route{
Type: routeType,
Value: routeValue,
Type: routeType,
Value: routeValue,
Description: descriptionValue,
}
route, err := c.CreateRoute(networkItemId, r)
if err != nil {
Expand Down
11 changes: 10 additions & 1 deletion openvpncloud/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package openvpncloud
import (
"context"

"github.com/OpenVPN/terraform-provider-openvpn-cloud/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/patoarvizu/terraform-provider-openvpn-cloud/client"
)

func resourceUser() *schema.Resource {
Expand Down Expand Up @@ -53,6 +53,12 @@ func resourceUser() *schema.Resource {
ForceNew: true,
Description: "The UUID of a user's group.",
},
"role": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: "The type of user role. Valid values are `ADMIN`, `MEMBER`, or `OWNER`.",
},
"devices": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -98,6 +104,7 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface
firstName := d.Get("first_name").(string)
lastName := d.Get("last_name").(string)
groupId := d.Get("group_id").(string)
role := d.Get("role").(string)
configDevices := d.Get("devices").([]interface{})
var devices []client.Device
for _, d := range configDevices {
Expand All @@ -120,6 +127,7 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface
LastName: lastName,
GroupId: groupId,
Devices: devices,
Role: role,
}
user, err := c.CreateUser(u)
if err != nil {
Expand Down Expand Up @@ -150,6 +158,7 @@ func resourceUserRead(ctx context.Context, d *schema.ResourceData, m interface{}
d.Set("last_name", u.LastName)
d.Set("group_id", u.GroupId)
d.Set("devices", u.Devices)
d.Set("role", u.Role)
}
return diags
}
Expand Down

0 comments on commit 4dd021c

Please sign in to comment.