Skip to content

Commit

Permalink
Release v1.60.2 (#75)
Browse files Browse the repository at this point in the history
* unmark spans as deprecated

* allow api_key to be set using a regular var, update docs

* update acceptance test env
  • Loading branch information
Clay Smith committed Mar 9, 2022
1 parent 6242204 commit 303eaf7
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.60.1
1.60.2
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ lint:

.PHONY: acc-test
acc-test:
@TF_ACC=true LIGHTSTEP_API_KEY=${LIGHTSTEP_API_KEY_STAGING} LIGHTSTEP_ORG="LightStep" LIGHTSTEP_ENV="staging" go test -v ./lightstep
@TF_ACC=true LIGHTSTEP_API_KEY=${LIGHTSTEP_API_KEY_PUBLIC} LIGHTSTEP_ORG="LightStep" LIGHTSTEP_ENV="public" go test -v ./lightstep

.PHONY: ensure-clean-repo
ensure-clean-repo:
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,20 @@ terraform {
required_providers {
lightstep = {
source = "lightstep/lightstep"
version = "1.60.1"
version = "1.60.2"
}
}
}
provider "lightstep" {
# Name of the *environment variable* where the API key is set
api_key_env_var = "LIGHTSTEP_API_KEY"
api_key = "your-lightstep-org-api-key"
organization = "your-lightstep-organization"
}
# Example: Create AWS EC2 Dashboard
module "aws-dashboards" {
source = "lightstep/aws-dashboards/lightstep//modules/ec2-dashboard"
version = "1.60.0"
version = "1.60.2"
lightstep_project = "your-lightstep-project"
lightstep_oranization = "your-lightstep-organization"
}
Expand Down
7 changes: 4 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ The [Lightstep](https://lightstep.com) Provider is for Terraform to manage Light

```
provider "lightstep" {
api_key_env_var = (environment variable where your LS API key is stored)
organization = (organization name)
api_key = "Lightstep organization API key"
organization = "Lightstep organization name"
}
```

Expand All @@ -28,5 +28,6 @@ provider "lightstep" {

### Optional

- **api_key_env_var** (String) Environment variable for Lightstep api key.
- **api_key** (String) Lightstep organization api key. If not set, the provider will use the environment variable set in `api_key_env_var`.
- **api_key_env_var** (String) Environment variable to use when looking up the API Key.
- **environment** (String) The name of the Lightstep environment, must be one of: staging, meta, public.
24 changes: 19 additions & 5 deletions docs/resources/metric_dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ resource "lightstep_metric_dashboard" "customer_charges" {
rank = 1
type = "timeseries"
y_axis {
min = 0.4
max = 5.0
}
query {
hidden = false
query_name = "a"
Expand All @@ -48,6 +43,25 @@ resource "lightstep_metric_dashboard" "customer_charges" {
}
}
}
chart {
name = "Public API Latency"
rank = "2"
type = "timeseries"
query {
query_name = "a"
display = "line"
hidden = false
spans {
query = "service IN (\"public_api\")"
operator = "latency"
group_by_keys = []
latency_percentiles = [50,95,99,99.9,]
}
}
}
}
```

Expand Down
5 changes: 5 additions & 0 deletions examples/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ variable "project" {
type = string
}

variable "lightstep_api_key" {
description = "Lightstep organization API Key"
type = string
}

variable "lightstep_organization" {
description = "Name of Lightstep organization"
type = string
Expand Down
6 changes: 3 additions & 3 deletions examples/versions.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
provider "lightstep" {
api_key_env_var = "LIGHTSTEP_API_KEY"
organization = var.lightstep_organization
api_key = var.lightstep_api_key
organization = var.lightstep_organization
}

terraform {
required_providers {
lightstep = {
source = "lightstep/lightstep"
version = "1.51.6"
version = "1.60.2"
}
}
required_version = "~> 1.1.0"
Expand Down
8 changes: 7 additions & 1 deletion exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func Run(args ...string) error {
log.Fatalf("error: LIGHTSTEP_ORG env variable must be set")
}

// default to public API environment
lightstepEnv := "public"
if len(os.Getenv("LIGHTSTEP_ENV")) > 0 {
lightstepEnv = os.Getenv("LIGHTSTEP_ENV")
}

if len(args) < 4 {
log.Fatalf("usage: %s export [resource-type] [project-name] [resource-id]", args[0])
}
Expand All @@ -78,7 +84,7 @@ func Run(args ...string) error {
log.Fatalf("error: only dashboard resources are supported at this time")
}

c := client.NewClient(os.Getenv("LIGHTSTEP_API_KEY"), os.Getenv("LIGHTSTEP_ORG"), os.Getenv("LIGHTSTEP_ENV"))
c := client.NewClient(os.Getenv("LIGHTSTEP_API_KEY"), os.Getenv("LIGHTSTEP_ORG"), lightstepEnv)
d, err := c.GetMetricDashboard(context.Background(), args[3], args[4])

if err != nil {
Expand Down
34 changes: 22 additions & 12 deletions lightstep/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package lightstep
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/meta"
"github.com/lightstep/terraform-provider-lightstep/version"
"os"
"regexp"

"github.com/hashicorp/terraform-plugin-sdk/v2/meta"
"github.com/lightstep/terraform-provider-lightstep/version"

"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"
Expand All @@ -30,6 +31,11 @@ func Provider() *schema.Provider {
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^(staging|meta|public)$`), "Must be one of: staging, meta, public"),
Description: "The name of the Lightstep environment, must be one of: staging, meta, public.",
},
"api_key": {
Type: schema.TypeString,
Optional: true,
Description: "The API Key for a Lightstep organization.",
},
// in order to support our internal use of lightstep in staging, meta, public
// and avoid resetting LIGHTSTEP_API_KEY when switching environments
// allow the user to specify where to look for the key
Expand Down Expand Up @@ -64,16 +70,20 @@ func Provider() *schema.Provider {

func configureProvider(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
var diags diag.Diagnostics
envVar := d.Get("api_key_env_var").(string)

apiKey, ok := os.LookupEnv(envVar)
if !ok {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "No api key found",
Detail: fmt.Sprintf("'api_key_env_var' is set to %v - but no api key found.", envVar),
})
return apiKey, diags
var apiKey string
apiKey = d.Get("api_key").(string)
if len(apiKey) == 0 {
envVar := d.Get("api_key_env_var").(string)
apiKeyEnv, ok := os.LookupEnv(envVar)
if !ok {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "No api key found",
Detail: fmt.Sprintf("'api_key_env_var' is set to %v - but no api key found.", envVar),
})
return apiKey, diags
}
apiKey = apiKeyEnv
}

client := client.NewClientWithUserAgent(
Expand Down
8 changes: 4 additions & 4 deletions lightstep/resource_metric_condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package lightstep
import (
"context"
"fmt"
"github.com/hashicorp/go-cty/cty"
"net/http"
"strconv"
"strings"

"github.com/hashicorp/go-cty/cty"

"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"
Expand Down Expand Up @@ -132,9 +133,8 @@ func getAlertingRuleSchema() map[string]*schema.Schema {

func getSpansQuerySchema() *schema.Schema {
sma := schema.Schema{
Type: schema.TypeList,
MaxItems: 1,
Deprecated: "Spans charts are not supported by the Lightstep API.",
Type: schema.TypeList,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"query": {
Expand Down

0 comments on commit 303eaf7

Please sign in to comment.