Skip to content

Commit

Permalink
Merge pull request #22 from appoptics/chore/AO-11606/use-official-cli…
Browse files Browse the repository at this point in the history
…ent-chad

Bring in the new updates for the Client with related fixes
  • Loading branch information
trevrosen authored Nov 8, 2019
2 parents a471ef9 + 073cef4 commit f53f291
Show file tree
Hide file tree
Showing 2,064 changed files with 578,947 additions and 106,656 deletions.
756 changes: 756 additions & 0 deletions Gopkg.lock

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
branch = "master"
name = "github.com/akahn/go-librato"

[[constraint]]
name = "github.com/appoptics/appoptics-api-go"
version = ">=0.3.0"

[[constraint]]
name = "github.com/hashicorp/terraform"
version = "0.11.13"

[prune]
go-tests = true
unused-packages = true
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ Requirements
Building The Provider
---------------------

Clone repository to: `$GOPATH/src/github.com/terraform-providers/terraform-provider-librato`
Clone repository to: `$GOPATH/src/github.com/terraform-providers/terraform-provider-appoptics`

```sh
$ mkdir -p $GOPATH/src/github.com/terraform-providers; cd $GOPATH/src/github.com/terraform-providers
$ git clone [email protected]:terraform-providers/terraform-provider-librato
$ git clone [email protected]:terraform-providers/terraform-provider-appoptics
```

Enter the provider directory and build the provider

```sh
$ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-librato
$ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-appoptics
$ make build
```

Expand All @@ -44,7 +44,7 @@ To compile the provider, run `make build`. This will build the provider and put
```sh
$ make bin
...
$ $GOPATH/bin/terraform-provider-librato
$ $GOPATH/bin/terraform-provider-appoptics
...
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package librato
package appoptics

import (
"log"
Expand Down
45 changes: 45 additions & 0 deletions appoptics/provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package appoptics

import (
"os"

"github.com/appoptics/appoptics-api-go"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)

// Provider returns a schema.Provider for Librato.
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"token": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("APPOPTICS_TOKEN", nil),
Description: "The auth token for the AppOptics account.",
},
},

ResourcesMap: map[string]*schema.Resource{
"appoptics_space": resourceAppOpticsSpace(),
"appoptics_space_chart": resourceAppOpticsSpaceChart(),
"appoptics_metric": resourceAppOpticsMetric(),
"appoptics_alert": resourceAppOpticsAlert(),
"appoptics_service": resourceAppOpticsService(),
},

ConfigureFunc: providerConfigure,
}
}

func providerConfigure(d *schema.ResourceData) (interface{}, error) {
var url string
if appOpticsURL := os.Getenv("APPOPTICS_URL"); appOpticsURL != "" {
url = appOpticsURL
} else {
url = "https://api.appoptics.com/v1/"
}

client := appoptics.NewClient(d.Get("token").(string), appoptics.BaseURLClientOption(url))
return client, nil
}
36 changes: 36 additions & 0 deletions appoptics/provider_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package appoptics

import (
"os"
"testing"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)

var testAccProviders map[string]terraform.ResourceProvider
var testAccProvider *schema.Provider

func init() {
testAccProvider = Provider().(*schema.Provider)
testAccProviders = map[string]terraform.ResourceProvider{
"appoptics": testAccProvider,
}
}

func TestProvider(t *testing.T) {
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
t.Fatalf("err: %s", err)
}
}

func TestProvider_impl(t *testing.T) {
var _ terraform.ResourceProvider = Provider()
}

func testAccPreCheck(t *testing.T) {
v, ok := os.LookupEnv("APPOPTICS_TOKEN")
if !ok || v == "" {
t.Fatal("APPOPTICS_TOKEN must be set for acceptance tests")
}
}
Loading

0 comments on commit f53f291

Please sign in to comment.