Compare commits

...

2 commits

9 changed files with 44 additions and 10 deletions

View file

@ -56,6 +56,28 @@ Note: Adjust the path based on your OS and architecture (e.g., `linux_amd64`, `d
### Provider Configuration
As the provider is currently not officially registered for public download, terraform must be configured to use a locally built version.
To generate the binary run `go install .` from the repository root. This installs the provider binary to `$HOME/go/bin` and means that `terraform init` is not necessary.
You will also need a `~/.terraformrc` file with the following contents. `<home>` should refer to your `$HOME` directory.
```hcl
provider_installation {
dev_overrides {
"local/edge-connect" = "<home>/go/bin"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
```
You can then reference the local provider in your `.tf` files as follows:
```hcl
provider "edge-connect" {
base_url = "https://edp.buildth.ing"

4
go.mod
View file

@ -1,9 +1,9 @@
module github.com/DevFW-CICD/terraform-provider-edge-connect
module edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect
go 1.25.3
require (
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.1
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.2
github.com/hashicorp/terraform-plugin-framework v1.16.1
github.com/hashicorp/terraform-plugin-log v0.9.0
)

4
go.sum
View file

@ -1,5 +1,5 @@
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.1 h1:4UqNkRb0d7kpsCpj6b+U4zZD8EEMi7AMspMrxstHcjE=
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.1/go.mod h1:nPZ4K4BB7eXyeSrcHXvSPkNZbs+XgmxbDJOM4KhbI1A=
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.2 h1:g1iY/8Au4T6UV6cFm8/SQXAAF+DvFcjR6Hb0TqTF064=
edp.buildth.ing/DevFW-CICD/edge-connect-client/v2 v2.1.2/go.mod h1:nPZ4K4BB7eXyeSrcHXvSPkNZbs+XgmxbDJOM4KhbI1A=
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

View file

@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ datasource.DataSource = &AppDataSource{}

View file

@ -3,6 +3,7 @@ package provider
import (
"context"
"encoding/json"
"errors"
"fmt"
"github.com/hashicorp/terraform-plugin-framework/path"
@ -14,7 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ resource.Resource = &AppResource{}
@ -266,6 +267,11 @@ func (r *AppResource) Read(ctx context.Context, req resource.ReadRequest, resp *
app, err := r.client.ShowApp(ctx, appKey, data.Region.ValueString())
if err != nil {
if errors.Is(err, edgeclient.ErrResourceNotFound) {
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app %s, got error: %s", data.Id.ValueString(), err))
return
}

View file

@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ datasource.DataSource = &AppInstanceDataSource{}

View file

@ -2,6 +2,7 @@ package provider
import (
"context"
"errors"
"fmt"
"github.com/hashicorp/terraform-plugin-framework/path"
@ -12,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ resource.Resource = &AppInstanceResource{}
@ -226,6 +227,11 @@ func (r *AppInstanceResource) Read(ctx context.Context, req resource.ReadRequest
appInstance, err := r.client.ShowAppInstance(ctx, appInstKey, appKey, data.Region.ValueString())
if err != nil {
if errors.Is(err, edgeclient.ErrResourceNotFound) {
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read app instance %s, got error: %s", data.Id.ValueString(), err))
return
}

View file

@ -15,7 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect"
edgeclient "edp.buildth.ing/DevFW-CICD/edge-connect-client/v2/sdk/edgeconnect/v2"
)
var _ provider.Provider = &EdgeConnectProvider{}

View file

@ -5,7 +5,7 @@ import (
"flag"
"log"
"github.com/DevFW-CICD/terraform-provider-edge-connect/internal/provider"
"edp.buildth.ing/DevFW-CICD/terraform-provider-edge-connect/internal/provider"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
)