Skip to content

Commit

Permalink
also enable older Go versions (>=1.16)
Browse files Browse the repository at this point in the history
  • Loading branch information
aellwein committed Apr 13, 2022
1 parent 0a170f0 commit fa8e1b7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 37 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@ name: Go

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.16", "1.17", "1.18"]
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

- name: Build
run: go build ./...
- name: Build
run: go build ./...

- name: Test
run: go test ./...
- name: Test
run: go test ./...
8 changes: 1 addition & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
module github.com/aellwein/netcup-dns-api

go 1.18
go 1.16

require github.com/stretchr/testify v1.7.1

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
2 changes: 1 addition & 1 deletion pkg/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func (d *DnsRecord) String() string {
}

// internal helper for doing HTTP post with given payload.
func doPost(endpoint string, payload any) (*bytes.Buffer, error) {
func doPost(endpoint string, payload interface{}) (*bytes.Buffer, error) {
var buf bytes.Buffer

enc := json.NewEncoder(&buf)
Expand Down
32 changes: 16 additions & 16 deletions pkg/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ func TestStringerImplsAreReturningValidJson(t *testing.T) {
DeleteRecord: false,
State: "yes",
}
output := make(map[string]any)
output := make(map[string]interface{})
err := json.NewDecoder(strings.NewReader(dnsZone.String())).Decode(&output)
assert.NoError(t, err)
output = make(map[string]any)
output = make(map[string]interface{})
err = json.NewDecoder(strings.NewReader(nbr.String())).Decode(&output)
assert.NoError(t, err)
output = make(map[string]any)
output = make(map[string]interface{})
err = json.NewDecoder(strings.NewReader(sess.String())).Decode(&output)
assert.NoError(t, err)
output = make(map[string]any)
output = make(map[string]interface{})
err = json.NewDecoder(strings.NewReader(dnsRecord.String())).Decode(&output)
assert.NoError(t, err)
}
Expand All @@ -153,12 +153,12 @@ func withTestServer() *httptest.Server {
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
dec := json.NewDecoder(r.Body)
type UniBody struct {
Action string `json:"action"`
Params map[string]any `json:"param"`
Action string `json:"action"`
Params map[string]interface{} `json:"param"`
}
// we use a map as "uni-body" payload receiver to cope with any possible request type.
ub := &UniBody{
Params: make(map[string]any),
Params: make(map[string]interface{}),
}
err := dec.Decode(ub)
if err != nil {
Expand Down Expand Up @@ -248,13 +248,13 @@ func withTestServer() *httptest.Server {
http.Error(w, "not found", 404)
}
dnsZoneResp := &DnsZoneData{
DomainName: ub.Params["dnszone"].(map[string]any)["name"].(string),
Ttl: ub.Params["dnszone"].(map[string]any)["ttl"].(string),
Serial: ub.Params["dnszone"].(map[string]any)["serial"].(string),
Refresh: ub.Params["dnszone"].(map[string]any)["refresh"].(string),
Retry: ub.Params["dnszone"].(map[string]any)["retry"].(string),
Expire: ub.Params["dnszone"].(map[string]any)["expire"].(string),
DnsSecStatus: ub.Params["dnszone"].(map[string]any)["dnssecstatus"].(bool),
DomainName: ub.Params["dnszone"].(map[string]interface{})["name"].(string),
Ttl: ub.Params["dnszone"].(map[string]interface{})["ttl"].(string),
Serial: ub.Params["dnszone"].(map[string]interface{})["serial"].(string),
Refresh: ub.Params["dnszone"].(map[string]interface{})["refresh"].(string),
Retry: ub.Params["dnszone"].(map[string]interface{})["retry"].(string),
Expire: ub.Params["dnszone"].(map[string]interface{})["expire"].(string),
DnsSecStatus: ub.Params["dnszone"].(map[string]interface{})["dnssecstatus"].(bool),
}
resp := &UpdateDnsZoneResponsePayload{
ResponseData: dnsZoneResp,
Expand All @@ -269,7 +269,7 @@ func withTestServer() *httptest.Server {
if ub.Params["domainname"] != "example.org" {
http.Error(w, "not found", 404)
}
recs := castToDnsRecords(ub.Params["dnsrecordset"].(map[string]any)["dnsrecords"].([]interface{}))
recs := castToDnsRecords(ub.Params["dnsrecordset"].(map[string]interface{})["dnsrecords"].([]interface{}))

resp := &UpdateDnsRecordsResponsePayload{
ResponseData: &UpdateDnsRecordsResponseData{
Expand All @@ -293,7 +293,7 @@ func withTestServer() *httptest.Server {
func castToDnsRecords(r []interface{}) *[]DnsRecord {
res := make([]DnsRecord, 0)
for _, i := range r {
m := i.(map[string]any)
m := i.(map[string]interface{})
rec := DnsRecord{
Id: m["id"].(string),
Hostname: m["hostname"].(string),
Expand Down

0 comments on commit fa8e1b7

Please sign in to comment.