Skip to content

Commit 5875579

Browse files
committed
Flatten packages
1 parent 8613794 commit 5875579

File tree

7 files changed

+31
-37
lines changed

7 files changed

+31
-37
lines changed

creds/creds.go renamed to creds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package creds
1+
package transip
22

33
import (
44
"crypto/rsa"

soap/decode.go renamed to decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Package soap implements SOAP-logic for the TransIP API.
22
// decode.go contains the logic to convert the XML to the corresponding
33
// datastructures
4-
package soap
4+
package transip
55

66
import (
77
"bytes"

domainservice.go

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,30 @@ import (
44
"bytes"
55
"errors"
66
"fmt"
7-
"github.com/mpdroog/transip/creds"
8-
"github.com/mpdroog/transip/soap"
9-
"github.com/mpdroog/transip/soap/signature"
107
"strconv"
118
)
129

1310
const domainService = "DomainService"
1411

1512
type DomainService struct {
16-
Creds creds.Client
13+
Creds Client
1714
}
1815

19-
func (c *DomainService) DomainNames() (*soap.DomainNames, error) {
20-
rawbody, e := soap.Lookup(c.Creds, soap.Request{Service: domainService, Method: "getDomainNames", Body: `<ns1:getDomainNames/>`})
16+
func (c *DomainService) DomainNames() (*DomainNames, error) {
17+
rawbody, e := Lookup(c.Creds, Request{Service: domainService, Method: "getDomainNames", Body: `<ns1:getDomainNames/>`})
2118
if e != nil {
2219
return nil, e
2320
}
2421

25-
domains := &soap.DomainNames{}
26-
e = soap.Decode(rawbody, &domains)
22+
domains := &DomainNames{}
23+
e = Decode(rawbody, &domains)
2724
return domains, e
2825
}
2926

30-
func (c *DomainService) Domain(name string) (*soap.Domain, error) {
31-
rawbody, e := soap.Lookup(c.Creds, soap.Request{
27+
func (c *DomainService) Domain(name string) (*Domain, error) {
28+
rawbody, e := Lookup(c.Creds, Request{
3229
Service: domainService,
33-
ExtraParams: []signature.KV{
30+
ExtraParams: []KV{
3431
{Key: "0", Value: name},
3532
},
3633
Method: "getInfo",
@@ -40,24 +37,24 @@ func (c *DomainService) Domain(name string) (*soap.Domain, error) {
4037
return nil, e
4138
}
4239

43-
domain := &soap.Domain{}
44-
e = soap.Decode(rawbody, &domain)
40+
domain := &Domain{}
41+
e = Decode(rawbody, &domain)
4542
return domain, e
4643
}
4744

48-
func (c *DomainService) Domains(names []string) ([]soap.Domain, error) {
45+
func (c *DomainService) Domains(names []string) ([]Domain, error) {
4946
entryTemplate := `<item xsi:type="xsd:string">%s</item>`
50-
params := []signature.KV{}
47+
params := []KV{}
5148
xml := ``
5249

5350
for idx, v := range names {
5451
xml = xml + fmt.Sprintf(entryTemplate, v)
55-
params = append(params, []signature.KV{
52+
params = append(params, []KV{
5653
{Key: fmt.Sprintf("0[%d]", idx), Value: v},
5754
}...)
5855
}
5956

60-
rawbody, e := soap.Lookup(c.Creds, soap.Request{
57+
rawbody, e := Lookup(c.Creds, Request{
6158
Service: domainService,
6259
ExtraParams: params,
6360
Method: "batchGetInfo",
@@ -67,30 +64,30 @@ func (c *DomainService) Domains(names []string) ([]soap.Domain, error) {
6764
return nil, e
6865
}
6966

70-
domains := &soap.Domains{}
71-
e = soap.Decode(rawbody, &domains)
67+
domains := &Domains{}
68+
e = Decode(rawbody, &domains)
7269
return domains.Domains, e
7370
}
7471

75-
func (c *DomainService) SetDNSEntries(domain string, entries []soap.DomainDNSentry) error {
72+
func (c *DomainService) SetDNSEntries(domain string, entries []DomainDNSentry) error {
7673
entryTemplate := `<item xsi:type="ns1:DnsEntry"><name xsi:type="xsd:string">%s</name><expire xsi:type="xsd:int">%d</expire><type xsi:type="xsd:string">%s</type><content xsi:type="xsd:string">%s</content></item>`
7774

78-
params := []signature.KV{
75+
params := []KV{
7976
{Key: "0", Value: domain},
8077
}
8178
xml := ``
8279

8380
for idx, entry := range entries {
8481
xml = xml + fmt.Sprintf(entryTemplate, entry.Name, entry.Expire, entry.Type, entry.Content)
85-
params = append(params, []signature.KV{
82+
params = append(params, []KV{
8683
{fmt.Sprintf("1[%d][name]", idx), entry.Name},
8784
{fmt.Sprintf("1[%d][expire]", idx), strconv.Itoa(entry.Expire)},
8885
{fmt.Sprintf("1[%d][type]", idx), entry.Type},
8986
{fmt.Sprintf("1[%d][content]", idx), entry.Content},
9087
}...)
9188
}
9289

93-
rawbody, e := soap.Lookup(c.Creds, soap.Request{
90+
rawbody, e := Lookup(c.Creds, Request{
9491
Service: domainService,
9592
ExtraParams: params,
9693
Method: "setDnsEntries",

soap/signature/signature.go renamed to signature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Package signature creates a cookie signature to validate
22
// a request for the TransIP API
3-
package signature
3+
package transip
44

55
import (
66
"crypto"

soap/signature/signature_test.go renamed to signature_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package signature
1+
package transip
22

33
import (
44
"bytes"
@@ -115,4 +115,4 @@ u7Isy/Q8xjHsJG6KP2/pMvMG42lhB3b+GKSmxVM999U30SdgorE3Kw==
115115
block, _ := pem.Decode(keyContents)
116116
privKey,_ := x509.ParsePKCS1PrivateKey(block.Bytes)
117117
return privKey
118-
}
118+
}

soap/soap.go renamed to soap.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Package soap implements SOAP-logic for the TransIP API.
2-
package soap
2+
package transip
33

44
import (
55
"crypto/tls"
@@ -9,10 +9,7 @@ import (
99
"net/http"
1010
"strings"
1111
"time"
12-
1312
"fmt"
14-
"github.com/mpdroog/transip/creds"
15-
"github.com/mpdroog/transip/soap/signature"
1613
"strconv"
1714
)
1815

@@ -33,12 +30,12 @@ func uniqid() string {
3330

3431
type Request struct {
3532
Service string // Service to call on TransIP side
36-
ExtraParams []signature.KV // Additional params for the signature-code
33+
ExtraParams []KV // Additional params for the signature-code
3734
Body string // XML body to send in envelope
3835
Method string // Method to call on service
3936
}
4037

41-
func Lookup(c creds.Client, in Request) ([]byte, error) {
38+
func Lookup(c Client, in Request) ([]byte, error) {
4239
raw := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?>
4340
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4441
xmlns:ns1="%s" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -86,14 +83,14 @@ func Lookup(c creds.Client, in Request) ([]byte, error) {
8683
})
8784

8885
kv := in.ExtraParams
89-
kv = append(kv, []signature.KV{
86+
kv = append(kv, []KV{
9087
{"__method", in.Method},
9188
{"__service", in.Service},
9289
{"__hostname", API_URL},
9390
{"__timestamp", now},
9491
{"__nonce", nonce}}...,
9592
)
96-
sig, e := signature.Sign(c.PrivateKey, kv)
93+
sig, e := Sign(c.PrivateKey, kv)
9794
if e != nil {
9895
return []byte{}, e
9996
}

soap/signature/urlencode.go renamed to urlencode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package signature
1+
package transip
22

33
import (
44
"bytes"

0 commit comments

Comments
 (0)