Skip to content

Commit c00d499

Browse files
authored
Merge pull request #9 from sumo-drosiek/drosiek-content-type
Add support for contentType
2 parents 03528be + ed1ace8 commit c00d499

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

sumologic/resource_sumologic_http_source_test.go

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,43 @@ import (
1212

1313
func TestAccSumologicHTTPSource_create(t *testing.T) {
1414
var httpSource HTTPSource
15+
var httpTraceSource HTTPSource
1516
var collector Collector
1617
cName := acctest.RandomWithPrefix("tf-acc-test")
1718
cDescription := acctest.RandomWithPrefix("tf-acc-test")
1819
cCategory := acctest.RandomWithPrefix("tf-acc-test")
1920
sName := acctest.RandomWithPrefix("tf-acc-test")
2021
sDescription := acctest.RandomWithPrefix("tf-acc-test")
2122
sCategory := acctest.RandomWithPrefix("tf-acc-test")
23+
tName := acctest.RandomWithPrefix("tf-acc-test")
24+
tDescription := acctest.RandomWithPrefix("tf-acc-test")
25+
tCategory := acctest.RandomWithPrefix("tf-acc-test")
2226
resource.Test(t, resource.TestCase{
2327
PreCheck: func() { testAccPreCheck(t) },
2428
Providers: testAccProviders,
2529
CheckDestroy: testAccCheckHTTPSourceDestroy,
2630
Steps: []resource.TestStep{
2731
{
28-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory),
32+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory),
2933
Check: resource.ComposeTestCheckFunc(
3034
testAccCheckHTTPSourceExists("sumologic_http_source.http", &httpSource),
3135
testAccCheckHTTPSourceValues(&httpSource, sName, sDescription, sCategory),
3236
testAccCheckCollectorExists("sumologic_collector.test", &collector),
3337
testAccCheckCollectorValues(&collector, cName, cDescription, cCategory, "Etc/UTC", ""),
38+
testAccCheckHTTPSourceExists("sumologic_http_source.traces", &httpTraceSource),
39+
testAccCheckHTTPSourceValues(&httpTraceSource, tName, tDescription, tCategory),
3440
resource.TestCheckResourceAttrSet("sumologic_http_source.http", "id"),
3541
resource.TestCheckResourceAttrSet("sumologic_http_source.http", "url"),
3642
resource.TestCheckResourceAttr("sumologic_http_source.http", "name", sName),
3743
resource.TestCheckResourceAttr("sumologic_http_source.http", "description", sDescription),
3844
resource.TestCheckResourceAttr("sumologic_http_source.http", "message_per_request", "false"),
3945
resource.TestCheckResourceAttr("sumologic_http_source.http", "category", sCategory),
46+
resource.TestCheckResourceAttrSet("sumologic_http_source.traces", "id"),
47+
resource.TestCheckResourceAttrSet("sumologic_http_source.traces", "url"),
48+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "name", tName),
49+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "description", tDescription),
50+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "category", tCategory),
51+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "content_type", "Zipkin"),
4052
),
4153
},
4254
},
@@ -45,12 +57,16 @@ func TestAccSumologicHTTPSource_create(t *testing.T) {
4557

4658
func TestAccSumologicHTTPSource_update(t *testing.T) {
4759
var httpSource HTTPSource
60+
var httpTraceSource HTTPSource
4861
cName := acctest.RandomWithPrefix("tf-acc-test")
4962
cDescription := acctest.RandomWithPrefix("tf-acc-test")
5063
cCategory := acctest.RandomWithPrefix("tf-acc-test")
5164
sName := acctest.RandomWithPrefix("tf-acc-test")
5265
sDescription := acctest.RandomWithPrefix("tf-acc-test")
5366
sCategory := acctest.RandomWithPrefix("tf-acc-test")
67+
tName := acctest.RandomWithPrefix("tf-acc-test")
68+
tDescription := acctest.RandomWithPrefix("tf-acc-test")
69+
tCategory := acctest.RandomWithPrefix("tf-acc-test")
5470
sNameUpdated := acctest.RandomWithPrefix("tf-acc-test")
5571
sDescriptionUpdated := acctest.RandomWithPrefix("tf-acc-test")
5672
sCategoryUpdated := acctest.RandomWithPrefix("tf-acc-test")
@@ -60,20 +76,28 @@ func TestAccSumologicHTTPSource_update(t *testing.T) {
6076
CheckDestroy: testAccCheckHTTPSourceDestroy,
6177
Steps: []resource.TestStep{
6278
{
63-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory),
79+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory),
6480
Check: resource.ComposeTestCheckFunc(
6581
testAccCheckHTTPSourceExists("sumologic_http_source.http", &httpSource),
6682
testAccCheckHTTPSourceValues(&httpSource, sName, sDescription, sCategory),
83+
testAccCheckHTTPSourceExists("sumologic_http_source.traces", &httpTraceSource),
84+
testAccCheckHTTPSourceValues(&httpTraceSource, tName, tDescription, tCategory),
6785
resource.TestCheckResourceAttrSet("sumologic_http_source.http", "id"),
6886
resource.TestCheckResourceAttrSet("sumologic_http_source.http", "url"),
6987
resource.TestCheckResourceAttr("sumologic_http_source.http", "name", sName),
7088
resource.TestCheckResourceAttr("sumologic_http_source.http", "description", sDescription),
7189
resource.TestCheckResourceAttr("sumologic_http_source.http", "message_per_request", "false"),
7290
resource.TestCheckResourceAttr("sumologic_http_source.http", "category", sCategory),
91+
resource.TestCheckResourceAttrSet("sumologic_http_source.traces", "id"),
92+
resource.TestCheckResourceAttrSet("sumologic_http_source.traces", "url"),
93+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "name", tName),
94+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "description", tDescription),
95+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "category", tCategory),
96+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "content_type", "Zipkin"),
7397
),
7498
},
7599
{
76-
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sNameUpdated, sDescriptionUpdated, sCategoryUpdated),
100+
Config: testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sNameUpdated, sDescriptionUpdated, sCategoryUpdated, tName, tDescription, tCategory),
77101
Check: resource.ComposeTestCheckFunc(
78102
testAccCheckHTTPSourceExists("sumologic_http_source.http", &httpSource),
79103
testAccCheckHTTPSourceValues(&httpSource, sNameUpdated, sDescriptionUpdated, sCategoryUpdated),
@@ -82,6 +106,7 @@ func TestAccSumologicHTTPSource_update(t *testing.T) {
82106
resource.TestCheckResourceAttr("sumologic_http_source.http", "name", sNameUpdated),
83107
resource.TestCheckResourceAttr("sumologic_http_source.http", "description", sDescriptionUpdated),
84108
resource.TestCheckResourceAttr("sumologic_http_source.http", "category", sCategoryUpdated),
109+
resource.TestCheckResourceAttr("sumologic_http_source.traces", "content_type", "Zipkin"),
85110
),
86111
},
87112
},
@@ -169,7 +194,7 @@ func testAccCheckHTTPSourceValues(httpSource *HTTPSource, name, description, cat
169194
}
170195
}
171196

172-
func testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory string) string {
197+
func testAccSumologicHTTPSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory string) string {
173198
return fmt.Sprintf(`
174199
resource "sumologic_collector" "test" {
175200
name = "%s"
@@ -184,5 +209,13 @@ resource "sumologic_http_source" "http" {
184209
category = "%s"
185210
collector_id = "${sumologic_collector.test.id}"
186211
}
187-
`, cName, cDescription, cCategory, sName, sDescription, sCategory)
212+
213+
resource "sumologic_http_source" "traces" {
214+
name = "%s"
215+
description = "%s"
216+
category = "%s"
217+
content_type = "Zipkin"
218+
collector_id = "${sumologic_collector.test.id}"
219+
}
220+
`, cName, cDescription, cCategory, sName, sDescription, sCategory, tName, tDescription, tCategory)
188221
}

sumologic/sumologic_sources.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Source struct {
2929
CutoffRelativeTime string `json:"cutoffRelativeTime,omitempty"`
3030
Fields map[string]interface{} `json:"fields,omitempty"`
3131
Url string `json:"url,omitempty"`
32+
ContentType string `json:"contentType,omitempty"`
3233
}
3334

3435
type DefaultDateFormat struct {
@@ -193,6 +194,11 @@ func resourceSumologicSource() *schema.Resource {
193194
ForceNew: false,
194195
Default: true,
195196
},
197+
"content_type": {
198+
Type: schema.TypeString,
199+
Optional: true,
200+
Default: nil,
201+
},
196202
},
197203
}
198204
}
@@ -262,6 +268,7 @@ func resourceToSource(d *schema.ResourceData) Source {
262268
source.CutoffTimestamp = d.Get("cutoff_timestamp").(int)
263269
source.CutoffRelativeTime = d.Get("cutoff_relative_time").(string)
264270
source.Fields = d.Get("fields").(map[string]interface{})
271+
source.ContentType = d.Get("content_type").(string)
265272

266273
return source
267274
}
@@ -288,6 +295,7 @@ func resourceSumologicSourceRead(d *schema.ResourceData, source Source) error {
288295
if err := d.Set("fields", source.Fields); err != nil {
289296
return fmt.Errorf("error setting fields for resource %s: %s", d.Id(), err)
290297
}
298+
d.Set("content_type", source.ContentType)
291299
return nil
292300
}
293301

0 commit comments

Comments
 (0)