Skip to content

Commit c4d11b6

Browse files
authored
Merge pull request #124 from SumoLogic/ssain-gh-action-test
Switch to GitHub Actions
2 parents 3b7cf30 + a09d022 commit c4d11b6

File tree

5 files changed

+115
-32
lines changed

5 files changed

+115
-32
lines changed

.github/workflows/test.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# This GitHub action runs your tests for each commit push and/or PR. Optionally
2+
# you can turn it on using a cron schedule for regular testing.
3+
#
4+
name: Tests
5+
on:
6+
pull_request:
7+
branches: [ master ]
8+
paths-ignore:
9+
- 'README.md'
10+
push:
11+
branches: [ master ]
12+
paths-ignore:
13+
- 'README.md'
14+
# For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.),
15+
# we recommend testing at a regular interval not necessarily tied to code changes. This will
16+
# ensure you are alerted to something breaking due to an API change, even if the code did not
17+
# change.
18+
# schedule:
19+
# - cron: '0 13 * * *'
20+
jobs:
21+
# ensure the code builds...
22+
build:
23+
name: Build
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 5
26+
steps:
27+
28+
- name: Set up Go
29+
uses: actions/[email protected]
30+
with:
31+
go-version: '1.15'
32+
id: go
33+
34+
- name: Check out code into the Go module directory
35+
uses: actions/[email protected]
36+
37+
- name: Get dependencies
38+
run: |
39+
go mod download
40+
- name: Build
41+
run: |
42+
go build -v .
43+
# run acceptance tests in a matrix with Terraform core versions
44+
test:
45+
name: Matrix Test
46+
needs: build
47+
runs-on: ubuntu-latest
48+
timeout-minutes: 15
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
# list whatever Terraform versions here you would like to support
53+
terraform:
54+
# - '0.12.29'
55+
- '0.13.4'
56+
# - '0.14.0-beta2'
57+
steps:
58+
59+
- name: Set up Go
60+
uses: actions/[email protected]
61+
with:
62+
go-version: '1.15'
63+
id: go
64+
65+
- name: Check out code into the Go module directory
66+
uses: actions/[email protected]
67+
68+
- name: Get dependencies
69+
run: |
70+
go mod download
71+
72+
- name: TF acceptance tests
73+
timeout-minutes: 10
74+
env:
75+
TF_ACC: "1"
76+
TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform }}
77+
78+
# Set whatever additional acceptance test env vars here. You can
79+
# optionally use data from your repository secrets using the
80+
# following syntax:
81+
# SOME_VAR: ${{ secrets.SOME_VAR }}
82+
SUMOLOGIC_ACCESSID: ${{ secrets.SUMOLOGIC_ACCESSID }}
83+
SUMOLOGIC_ACCESSKEY: ${{ secrets.SUMOLOGIC_ACCESSKEY }}
84+
SUMOLOGIC_ENVIRONMENT: ${{ secrets.SUMOLOGIC_ENVIRONMENT }}
85+
SUMOLOGIC_TEST_AWS_ID: ${{ secrets.SUMOLOGIC_TEST_AWS_ID }}
86+
SUMOLOGIC_TEST_AWS_KEY: ${{ secrets.SUMOLOGIC_TEST_AWS_KEY }}
87+
SUMOLOGIC_TEST_BUCKET_NAME: ${{ secrets.SUMOLOGIC_TEST_BUCKET_NAME }}
88+
89+
run: |
90+
go test -v -cover ./sumologic/

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

sumologic/resource_sumologic_subdomain.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package sumologic
1313

1414
import (
1515
"log"
16+
"strings"
1617

1718
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
1819
)
@@ -66,7 +67,19 @@ func resourceSumologicSubdomainCreate(d *schema.ResourceData, meta interface{})
6667
id, err := c.CreateSubdomain(subdomain)
6768

6869
if err != nil {
69-
return err
70+
if strings.Contains(err.Error(), "subdomain:already_configured") {
71+
updatedID, updateErr := c.UpdateSubdomain(subdomain)
72+
if updateErr != nil {
73+
if updatedID == "" {
74+
id = subdomain.Subdomain
75+
} else {
76+
return updateErr
77+
}
78+
}
79+
id = updatedID
80+
} else {
81+
return err
82+
}
7083
}
7184

7285
d.SetId(id)
@@ -86,7 +99,7 @@ func resourceSumologicSubdomainUpdate(d *schema.ResourceData, meta interface{})
8699

87100
subdomain := resourceToSubdomain(d)
88101

89-
err := c.UpdateSubdomain(subdomain)
102+
_, err := c.UpdateSubdomain(subdomain)
90103
if err != nil {
91104
return err
92105
}

sumologic/sumologic_subdomain.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,18 @@ func (s *Client) DeleteSubdomain() error {
5959
return err
6060
}
6161

62-
func (s *Client) UpdateSubdomain(subdomain Subdomain) error {
62+
func (s *Client) UpdateSubdomain(subdomain Subdomain) (string, error) {
6363
urlWithoutParams := "v1/account/subdomain"
6464

65-
_, err := s.Put(urlWithoutParams, subdomain)
66-
return err
65+
data, err := s.Put(urlWithoutParams, subdomain)
66+
67+
var updatedSubdomain Subdomain
68+
err = json.Unmarshal(data, &updatedSubdomain)
69+
if err != nil {
70+
return "", err
71+
}
72+
73+
return updatedSubdomain.Subdomain, err
6774
}
6875

6976
type Subdomain struct {

travis/run_on_non_pull_requests

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)