From fb0fdbcfe91022611a002e462f31ff5880d7a0b9 Mon Sep 17 00:00:00 2001 From: Scott McAllister Date: Mon, 10 Feb 2020 16:17:19 -0800 Subject: [PATCH 1/5] adding User-Agent header to identify library in API requests --- client.go | 1 + event_v2.go | 1 + 2 files changed, 2 insertions(+) diff --git a/client.go b/client.go index 6594f8bc..e25ed010 100644 --- a/client.go +++ b/client.go @@ -140,6 +140,7 @@ func (c *Client) do(method, path string, body io.Reader, headers *map[string]str req.Header.Set(k, v) } } + req.Header.Set("User-Agent", "go-pagerduty") req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "Token token="+c.authToken) diff --git a/event_v2.go b/event_v2.go index 1051cf79..d0974a05 100644 --- a/event_v2.go +++ b/event_v2.go @@ -48,6 +48,7 @@ func ManageEvent(e V2Event) (*V2EventResponse, error) { return nil, err } req, _ := http.NewRequest("POST", v2eventEndPoint, bytes.NewBuffer(data)) + req.Header.Set("User-Agent", "go-pagerduty") req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { From a2e63c3bf3f5815d74b5963db0528fca555aa306 Mon Sep 17 00:00:00 2001 From: Scott McAllister Date: Tue, 11 Feb 2020 15:25:34 -0800 Subject: [PATCH 2/5] removing oncall from escalation_policies --- escalation_policy.go | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/escalation_policy.go b/escalation_policy.go index bf249db6..74befc66 100644 --- a/escalation_policy.go +++ b/escalation_policy.go @@ -21,22 +21,13 @@ type EscalationRule struct { // EscalationPolicy is a collection of escalation rules. type EscalationPolicy struct { APIObject - Name string `json:"name,omitempty"` - EscalationRules []EscalationRule `json:"escalation_rules,omitempty"` - Services []APIObject `json:"services,omitempty"` - NumLoops uint `json:"num_loops,omitempty"` - Teams []APIReference `json:"teams"` - OnCall []EscalationPolicyOnCall `json:"on_call"` - Description string `json:"description,omitempty"` - RepeatEnabled bool `json:"repeat_enabled,omitempty"` -} - -// -type EscalationPolicyOnCall struct { - Level uint `json:"level"` - Start string `json:"start,omitempty"` - End string `json:"end,omitempty"` - User User `json:"user,omitempty"` + Name string `json:"name,omitempty"` + EscalationRules []EscalationRule `json:"escalation_rules,omitempty"` + Services []APIObject `json:"services,omitempty"` + NumLoops uint `json:"num_loops,omitempty"` + Teams []APIReference `json:"teams"` + Description string `json:"description,omitempty"` + RepeatEnabled bool `json:"repeat_enabled,omitempty"` } // ListEscalationPoliciesResponse is the data structure returned from calling the ListEscalationPolicies API endpoint. From 759b14a3f2e36b6776ec907abe9739424412bf52 Mon Sep 17 00:00:00 2001 From: Scott McAllister Date: Thu, 13 Feb 2020 09:48:59 -0800 Subject: [PATCH 3/5] adding version to useragent headers --- constants.go | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 constants.go diff --git a/constants.go b/constants.go new file mode 100644 index 00000000..b58d8cd7 --- /dev/null +++ b/constants.go @@ -0,0 +1,5 @@ +package pagerduty + +const ( + Version = "1.1.1" +) From 9a4844782b444aaedb33482a73ee2ffd79385d13 Mon Sep 17 00:00:00 2001 From: Scott McAllister Date: Thu, 13 Feb 2020 11:17:51 -0800 Subject: [PATCH 4/5] adding version to useragent headers and updating goreleaser --- .goreleaser.yml | 61 +++++++++++++++++++++++-------------------------- client.go | 2 +- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 4ecd2cbe..165254eb 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,33 +1,30 @@ -project_name: go-pagerduty -release: - github: - owner: PagerDuty - name: go-pagerduty - draft: false - prerelease: true - name_template: "{{.ProjectName}}-v{{.Version}}" +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +before: + hooks: + # you may remove this if you don't use vgo + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... builds: -- goos: - - linux - - darwin - - windows - goarch: - - amd64 - - 386 - main: ./command/*.go - binary: pd -archive: - format: tar.gz - format_overrides: - - goos: windows - format: zip - replacements: - amd64: 64-bit - darwin: macOS - linux: Tux - name_template: "{{.Binary}}_{{.Version}}_{{.Os}}-{{.Arch}}" - files: - - LICENSE.txt - - README.md - - examples/* - - CHANGELOG.md \ No newline at end of file +- env: + - CGO_ENABLED=0 +- ldflags: + - -s -w -X pagerduty.Version={{.Version}}s +archives: +- replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' \ No newline at end of file diff --git a/client.go b/client.go index 69391257..2b568934 100644 --- a/client.go +++ b/client.go @@ -140,7 +140,7 @@ func (c *Client) do(method, path string, body io.Reader, headers *map[string]str req.Header.Set(k, v) } } - req.Header.Set("User-Agent", "go-pagerduty") + req.Header.Set("User-Agent", "go-pagerduty/"+Version) req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "Token token="+c.authToken) From 828c78322bb5e086cf2b37eb0c9e6f72d0a76ed7 Mon Sep 17 00:00:00 2001 From: Scott McAllister Date: Thu, 13 Feb 2020 12:05:48 -0800 Subject: [PATCH 5/5] adding version to event_v2 useragent header --- event_v2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event_v2.go b/event_v2.go index d0974a05..a93a66bc 100644 --- a/event_v2.go +++ b/event_v2.go @@ -48,7 +48,7 @@ func ManageEvent(e V2Event) (*V2EventResponse, error) { return nil, err } req, _ := http.NewRequest("POST", v2eventEndPoint, bytes.NewBuffer(data)) - req.Header.Set("User-Agent", "go-pagerduty") + req.Header.Set("User-Agent", "go-pagerduty/"+Version) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil {