Skip to content

Commit

Permalink
Clean up linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Rosen committed Jan 14, 2020
1 parent 2c770f8 commit 202fa2c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion appoptics/resource_appoptics_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func resourceAppOpticsAlertRead(d *schema.ResourceData, meta interface{}) error
}
log.Printf("[INFO] Received AppOptics Alert: %s", alert.Name)

d.Set("name", alert.Name)
d.Set("name", alert.Name) //nolint

if err := d.Set("description", alert.Description); err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions appoptics/resource_appoptics_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,23 @@ func resourceAppOpticsMetricRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Error reading AppOptics Metric %s: %s", id, err)
}

d.Set("name", metric.Name)
d.Set("type", metric.Type)
d.Set("name", metric.Name) //nolint
d.Set("type", metric.Type) //nolint

if metric.Description != "" {
d.Set("description", metric.Description)
d.Set("description", metric.Description) //nolint
}

if metric.DisplayName != "" {
d.Set("display_name", metric.DisplayName)
d.Set("display_name", metric.DisplayName) //nolint
}

if metric.Period != 0 {
d.Set("period", metric.Period)
d.Set("period", metric.Period) //nolint
}

if metric.Composite != "" {
d.Set("composite", metric.Composite)
d.Set("composite", metric.Composite) //nolint
}

attributes := metricAttributesGather(d, &metric.Attributes)
Expand Down
22 changes: 14 additions & 8 deletions appoptics/resource_appoptics_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ func resourceAppOpticsService() *schema.Resource {
// Takes JSON in a string. Decodes JSON into
// settings hash
func resourceAppOpticsServicesExpandSettings(rawSettings string) (map[string]string, error) {
var settings map[string]string

settings = make(map[string]string)
settings := make(map[string]string)
err := json.Unmarshal([]byte(rawSettings), &settings)
if err != nil {
return nil, fmt.Errorf("Error decoding JSON: %s", err)
Expand Down Expand Up @@ -103,7 +101,7 @@ func resourceAppOpticsServiceCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error creating AppOptics service: %s", err)
}

resource.Retry(1*time.Minute, func() *resource.RetryError {
retryErr := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := client.ServicesService().Retrieve(serviceResult.ID)
if err != nil {
if errResp, ok := err.(*appoptics.ErrorResponse); ok && errResp.Response.StatusCode == 404 {
Expand All @@ -114,6 +112,10 @@ func resourceAppOpticsServiceCreate(d *schema.ResourceData, meta interface{}) er
return nil
})

if retryErr != nil {
return retryErr
}

d.SetId(strconv.Itoa(serviceResult.ID))
return resourceAppOpticsServiceReadResult(d, *serviceResult)
}
Expand Down Expand Up @@ -141,10 +143,10 @@ func resourceAppOpticsServiceRead(d *schema.ResourceData, meta interface{}) erro

func resourceAppOpticsServiceReadResult(d *schema.ResourceData, service appoptics.Service) error {
d.SetId(strconv.FormatUint(uint64(service.ID), 10))
d.Set("type", service.Type)
d.Set("title", service.Title)
d.Set("type", service.Type) //nolint
d.Set("title", service.Title) //nolint
settings, _ := resourceAppOpticsServicesFlatten(service.Settings)
d.Set("settings", settings)
d.Set("settings", settings) //nolint

return nil
}
Expand Down Expand Up @@ -223,7 +225,7 @@ func resourceAppOpticsServiceDelete(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error deleting Service: %s", err)
}

resource.Retry(1*time.Minute, func() *resource.RetryError {
retryErr := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := client.ServicesService().Retrieve(int(id))
if err != nil {
if errResp, ok := err.(*appoptics.ErrorResponse); ok && errResp.Response.StatusCode == 404 {
Expand All @@ -234,6 +236,10 @@ func resourceAppOpticsServiceDelete(d *schema.ResourceData, meta interface{}) er
return resource.RetryableError(fmt.Errorf("service still exists"))
})

if retryErr != nil {
return retryErr
}

d.SetId("")
return nil
}
12 changes: 10 additions & 2 deletions appoptics/resource_appoptics_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func resourceAppOpticsSpaceCreate(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error creating AppOptics space %s: %s", name, err)
}

resource.Retry(1*time.Minute, func() *resource.RetryError {
retryErr := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := client.SpacesService().Retrieve(space.ID)
if err != nil {
if errResp, ok := err.(*appoptics.ErrorResponse); ok && errResp.Response.StatusCode == 404 {
Expand All @@ -49,6 +49,10 @@ func resourceAppOpticsSpaceCreate(d *schema.ResourceData, meta interface{}) erro
return nil
})

if retryErr != nil {
return retryErr
}

d.SetId(strconv.Itoa(space.ID))
return resourceAppOpticsSpaceReadResult(d, space)
}
Expand Down Expand Up @@ -116,7 +120,7 @@ func resourceAppOpticsSpaceDelete(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error deleting space: %s", err)
}

resource.Retry(1*time.Minute, func() *resource.RetryError {
retryErr := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := client.SpacesService().Retrieve(int(id))
if err != nil {
if errResp, ok := err.(*appoptics.ErrorResponse); ok && errResp.Response.StatusCode == 404 {
Expand All @@ -127,6 +131,10 @@ func resourceAppOpticsSpaceDelete(d *schema.ResourceData, meta interface{}) erro
return resource.RetryableError(fmt.Errorf("space still exists"))
})

if retryErr != nil {
return retryErr
}

d.SetId("")
return nil
}
16 changes: 12 additions & 4 deletions appoptics/resource_librato_space_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func resourceAppOpticsSpaceChartCreate(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error creating AppOptics space chart %s: %s", spaceChart.Name, err)
}

resource.Retry(1*time.Minute, func() *resource.RetryError {
retryErr := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := client.ChartsService().Retrieve(spaceChartResult.ID, spaceID)
if err != nil {
if errResp, ok := err.(*appoptics.ErrorResponse); ok && errResp.Response.StatusCode == 404 {
Expand All @@ -269,6 +269,10 @@ func resourceAppOpticsSpaceChartCreate(d *schema.ResourceData, meta interface{})
return nil
})

if retryErr != nil {
return retryErr
}

return resourceAppOpticsSpaceChartReadResult(d, spaceChartResult)
}

Expand Down Expand Up @@ -443,10 +447,10 @@ func resourceAppOpticsSpaceChartUpdate(d *schema.ResourceData, meta interface{})
if v, ok := streamData["units_longs"].(string); ok && v != "" {
stream.UnitsLong = v
}
if v, ok := streamData["min"].(int); ok && !math.IsNaN(float64(v)) {
if v, ok := streamData["min"].(int); ok {
stream.Min = v
}
if v, ok := streamData["max"].(int); ok && !math.IsNaN(float64(v)) {
if v, ok := streamData["max"].(int); ok {
stream.Max = v
}
streams[i] = stream
Expand Down Expand Up @@ -503,7 +507,7 @@ func resourceAppOpticsSpaceChartDelete(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error deleting space: %s", err)
}

resource.Retry(1*time.Minute, func() *resource.RetryError {
retryErr := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := client.ChartsService().Retrieve(id, spaceID)
if err != nil {
if errResp, ok := err.(*appoptics.ErrorResponse); ok && errResp.Response.StatusCode == 404 {
Expand All @@ -514,6 +518,10 @@ func resourceAppOpticsSpaceChartDelete(d *schema.ResourceData, meta interface{})
return resource.RetryableError(fmt.Errorf("space chart still exists"))
})

if err != nil {
return retryErr
}

d.SetId("")
return nil
}

0 comments on commit 202fa2c

Please sign in to comment.