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 committed 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 git@github.com:terraform-providers/terraform-provider-librato
$ git clone git@github.com: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.