Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into feature/update-connector
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfmnk committed Jul 26, 2024
2 parents c617a61 + b4ff2f4 commit 55a7fd8
Show file tree
Hide file tree
Showing 12 changed files with 580 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v5
uses: golangci/golangci-lint-action@v6.0.1
with:
version: latest
version: v1.55.2
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ issues:
- linters:
- errcheck
text: "Error return value of `d.Set` is not checked"
output:
formats:
- format: colored-line-number
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NAMESPACE=openvpn
NAME=cloudconnexa
VERSION=0.0.12
BINARY=terraform-provider-${NAME}
OS_ARCH=darwin_arm64
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)

default: install

Expand Down
58 changes: 58 additions & 0 deletions cloudconnexa/data_source_application.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package cloudconnexa

import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa"
)

func dataSourceApplication() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceApplicationRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"description": {
Type: schema.TypeString,
Computed: true,
},
"routes": {
Type: schema.TypeList,
Computed: true,
Elem: resourceApplicationRoute(),
},
"config": {
Type: schema.TypeList,
Computed: true,
Elem: resourceApplicationConfig(),
},
"network_item_type": {
Type: schema.TypeString,
Computed: true,
},
"network_item_id": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

func dataSourceApplicationRead(ctx context.Context, data *schema.ResourceData, i interface{}) diag.Diagnostics {
c := i.(*cloudconnexa.Client)
var diags diag.Diagnostics
var name = data.Get("name").(string)
application, err := c.Applications.GetByName(name)

if err != nil {
return diag.FromErr(err)
}
if application == nil {
return append(diags, diag.Errorf("Application with name %s was not found", name)...)
}
setApplicationData(data, application)
return nil
}
6 changes: 6 additions & 0 deletions cloudconnexa/data_source_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func dataSourceHost() *schema.Resource {
Description: "Use an `cloudconnexa_host` data source to read an existing CloudConnexa connector.",
ReadContext: dataSourceHostRead,
Schema: map[string]*schema.Schema{
"host_id": {
Type: schema.TypeString,
Computed: true,
Description: "The host ID.",
},
"name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -88,6 +93,7 @@ func dataSourceHostRead(ctx context.Context, d *schema.ResourceData, m interface
if err != nil {
return append(diags, diag.FromErr(err)...)
}
d.Set("host_id", host.Id)
d.Set("name", host.Name)
d.Set("internet_access", host.InternetAccess)
d.Set("system_subnets", host.SystemSubnets)
Expand Down
18 changes: 10 additions & 8 deletions cloudconnexa/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ func Provider() *schema.Provider {
},
},
ResourcesMap: map[string]*schema.Resource{
"cloudconnexa_network": resourceNetwork(),
"cloudconnexa_connector": resourceConnector(),
"cloudconnexa_route": resourceRoute(),
"cloudconnexa_dns_record": resourceDnsRecord(),
"cloudconnexa_user": resourceUser(),
"cloudconnexa_host": resourceHost(),
"cloudconnexa_user_group": resourceUserGroup(),
"cloudconnexa_ip_service": resourceIPService(),
"cloudconnexa_network": resourceNetwork(),
"cloudconnexa_connector": resourceConnector(),
"cloudconnexa_route": resourceRoute(),
"cloudconnexa_dns_record": resourceDnsRecord(),
"cloudconnexa_user": resourceUser(),
"cloudconnexa_host": resourceHost(),
"cloudconnexa_user_group": resourceUserGroup(),
"cloudconnexa_ip_service": resourceIPService(),
"cloudconnexa_application": resourceApplication(),
},

DataSourcesMap: map[string]*schema.Resource{
Expand All @@ -64,6 +65,7 @@ func Provider() *schema.Provider {
"cloudconnexa_network_routes": dataSourceNetworkRoutes(),
"cloudconnexa_host": dataSourceHost(),
"cloudconnexa_ip_service": dataSourceIPService(),
"cloudconnexa_application": dataSourceApplication(),
},
ConfigureContextFunc: providerConfigure,
}
Expand Down
Loading

0 comments on commit 55a7fd8

Please sign in to comment.