Updates of Lego.
This commit is contained in:
parent
5f4d440493
commit
2b2cfdfb32
102 changed files with 8355 additions and 902 deletions
53
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/client.go
generated
vendored
53
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/client.go
generated
vendored
|
@ -6,8 +6,11 @@ import (
|
|||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
|
@ -16,7 +19,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
libraryVersion = "0.6.0"
|
||||
libraryVersion = "0.6.2"
|
||||
// UserAgent is the User-Agent value sent for all requests
|
||||
UserAgent = "Akamai-Open-Edgegrid-golang/" + libraryVersion + " golang/" + strings.TrimPrefix(runtime.Version(), "go")
|
||||
// Client is the *http.Client to use
|
||||
|
@ -61,13 +64,21 @@ func NewRequest(config edgegrid.Config, method, path string, body io.Reader) (*h
|
|||
// NewJSONRequest creates an HTTP request that can be sent to the Akamai APIs with a JSON body
|
||||
// The JSON body is encoded and the Content-Type/Accept headers are set automatically.
|
||||
func NewJSONRequest(config edgegrid.Config, method, path string, body interface{}) (*http.Request, error) {
|
||||
jsonBody, err := jsonhooks.Marshal(body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var req *http.Request
|
||||
var err error
|
||||
|
||||
if body != nil {
|
||||
jsonBody, err := jsonhooks.Marshal(body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buf := bytes.NewReader(jsonBody)
|
||||
req, err = NewRequest(config, method, path, buf)
|
||||
} else {
|
||||
req, err = NewRequest(config, method, path, nil)
|
||||
}
|
||||
|
||||
buf := bytes.NewReader(jsonBody)
|
||||
req, err := NewRequest(config, method, path, buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -78,6 +89,36 @@ func NewJSONRequest(config edgegrid.Config, method, path string, body interface{
|
|||
return req, nil
|
||||
}
|
||||
|
||||
// NewMultiPartFormDataRequest creates an HTTP request that uploads a file to the Akamai API
|
||||
func NewMultiPartFormDataRequest(config edgegrid.Config, uriPath, filePath string, otherFormParams map[string]string) (*http.Request, error) {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
body := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(body)
|
||||
// TODO: make this field name configurable
|
||||
part, err := writer.CreateFormFile("importFile", filepath.Base(filePath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = io.Copy(part, file)
|
||||
|
||||
for key, val := range otherFormParams {
|
||||
_ = writer.WriteField(key, val)
|
||||
}
|
||||
err = writer.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req, err := NewRequest(config, "POST", uriPath, body)
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
return req, err
|
||||
}
|
||||
|
||||
// Do performs a given HTTP Request, signed with the Akamai OPEN Edgegrid
|
||||
// Authorization header. An edgegrid.Response or an error is returned.
|
||||
func Do(config edgegrid.Config, req *http.Request) (*http.Response, error) {
|
||||
|
|
47
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/errors.go
generated
vendored
47
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/errors.go
generated
vendored
|
@ -12,22 +12,42 @@ import (
|
|||
// APIError exposes an Akamai OPEN Edgegrid Error
|
||||
type APIError struct {
|
||||
error
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Status int `json:"status"`
|
||||
Detail string `json:"detail"`
|
||||
Instance string `json:"instance"`
|
||||
Method string `json:"method"`
|
||||
ServerIP string `json:"serverIp"`
|
||||
ClientIP string `json:"clientIp"`
|
||||
RequestID string `json:"requestId"`
|
||||
RequestTime string `json:"requestTime"`
|
||||
Response *http.Response `json:"-"`
|
||||
RawBody string `json:"-"`
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Status int `json:"status"`
|
||||
Detail string `json:"detail"`
|
||||
Errors []APIErrorDetail `json:"errors"`
|
||||
Problems []APIErrorDetail `json:"problems"`
|
||||
Instance string `json:"instance"`
|
||||
Method string `json:"method"`
|
||||
ServerIP string `json:"serverIp"`
|
||||
ClientIP string `json:"clientIp"`
|
||||
RequestID string `json:"requestId"`
|
||||
RequestTime string `json:"requestTime"`
|
||||
Response *http.Response `json:"-"`
|
||||
RawBody string `json:"-"`
|
||||
}
|
||||
|
||||
type APIErrorDetail struct {
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Detail string `json:"detail"`
|
||||
RejectedValue string `json:"rejectedValue"`
|
||||
}
|
||||
|
||||
func (error APIError) Error() string {
|
||||
return strings.TrimSpace(fmt.Sprintf("API Error: %d %s %s More Info %s", error.Status, error.Title, error.Detail, error.Type))
|
||||
var errorDetails string
|
||||
if len(error.Errors) > 0 {
|
||||
for _, e := range error.Errors {
|
||||
errorDetails = fmt.Sprintf("%s \n %s", errorDetails, e)
|
||||
}
|
||||
}
|
||||
if len(error.Problems) > 0 {
|
||||
for _, e := range error.Problems {
|
||||
errorDetails = fmt.Sprintf("%s \n %s", errorDetails, e)
|
||||
}
|
||||
}
|
||||
return strings.TrimSpace(fmt.Sprintf("API Error: %d %s %s More Info %s\n %s", error.Status, error.Title, error.Detail, error.Type, errorDetails))
|
||||
}
|
||||
|
||||
// NewAPIError creates a new API error based on a Response,
|
||||
|
@ -45,7 +65,6 @@ func NewAPIError(response *http.Response) APIError {
|
|||
// other purposes.
|
||||
func NewAPIErrorFromBody(response *http.Response, body []byte) APIError {
|
||||
error := APIError{}
|
||||
|
||||
if err := jsonhooks.Unmarshal(body, &error); err == nil {
|
||||
error.Status = response.StatusCode
|
||||
error.Title = response.Status
|
||||
|
|
19
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/record.go
generated
vendored
19
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/record.go
generated
vendored
|
@ -1323,15 +1323,16 @@ func (record *RrsigRecord) ToMap() map[string]interface{} {
|
|||
}
|
||||
|
||||
type SoaRecord struct {
|
||||
fieldMap []string `json:"-"`
|
||||
TTL int `json:"ttl,omitempty"`
|
||||
Originserver string `json:"originserver,omitempty"`
|
||||
Contact string `json:"contact,omitempty"`
|
||||
Serial uint `json:"serial,omitempty"`
|
||||
Refresh int `json:"refresh,omitempty"`
|
||||
Retry int `json:"retry,omitempty"`
|
||||
Expire int `json:"expire,omitempty"`
|
||||
Minimum uint `json:"minimum,omitempty"`
|
||||
fieldMap []string `json:"-"`
|
||||
originalSerial uint `json:"-"`
|
||||
TTL int `json:"ttl,omitempty"`
|
||||
Originserver string `json:"originserver,omitempty"`
|
||||
Contact string `json:"contact,omitempty"`
|
||||
Serial uint `json:"serial,omitempty"`
|
||||
Refresh int `json:"refresh,omitempty"`
|
||||
Retry int `json:"retry,omitempty"`
|
||||
Expire int `json:"expire,omitempty"`
|
||||
Minimum uint `json:"minimum,omitempty"`
|
||||
}
|
||||
|
||||
func NewSoaRecord() *SoaRecord {
|
||||
|
|
34
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/zone.go
generated
vendored
34
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/zone.go
generated
vendored
|
@ -82,7 +82,7 @@ func GetZone(hostname string) (*Zone, error) {
|
|||
} else if res.StatusCode == 404 {
|
||||
return nil, &ZoneError{zoneName: hostname}
|
||||
} else {
|
||||
err = client.BodyJSON(res, &zone)
|
||||
err = client.BodyJSON(res, zone)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -762,11 +762,18 @@ func (zone *Zone) removeTxtRecord(record *TxtRecord) error {
|
|||
return errors.New("Txt Record not found")
|
||||
}
|
||||
|
||||
func (zone *Zone) PreMarshalJSON() error {
|
||||
func (zone *Zone) PostUnmarshalJSON() error {
|
||||
if zone.Zone.Soa.Serial > 0 {
|
||||
zone.Zone.Soa.Serial = zone.Zone.Soa.Serial + 1
|
||||
} else {
|
||||
zone.Zone.Soa.originalSerial = zone.Zone.Soa.Serial
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (zone *Zone) PreMarshalJSON() error {
|
||||
if zone.Zone.Soa.Serial == 0 {
|
||||
zone.Zone.Soa.Serial = uint(time.Now().Unix())
|
||||
} else if zone.Zone.Soa.Serial == zone.Zone.Soa.originalSerial {
|
||||
zone.Zone.Soa.Serial = zone.Zone.Soa.Serial + 1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -786,21 +793,24 @@ func (zone *Zone) validateCnames() (bool, []name) {
|
|||
}
|
||||
|
||||
func (zone *Zone) removeCnameName(host string) {
|
||||
for i, v := range cnameNames {
|
||||
if v.name == host {
|
||||
r := cnameNames[:i]
|
||||
cnameNames = append(r, cnameNames[i+1:]...)
|
||||
var ncn []name
|
||||
for _, v := range cnameNames {
|
||||
if v.name != host {
|
||||
ncn =append(ncn, v)
|
||||
}
|
||||
}
|
||||
cnameNames = ncn
|
||||
}
|
||||
|
||||
|
||||
func (zone *Zone) removeNonCnameName(host string) {
|
||||
for i, v := range nonCnameNames {
|
||||
if v.name == host {
|
||||
r := nonCnameNames[:i]
|
||||
nonCnameNames = append(r, nonCnameNames[i+1:]...)
|
||||
var ncn []name
|
||||
for _, v := range nonCnameNames {
|
||||
if v.name != host {
|
||||
ncn =append(ncn, v)
|
||||
}
|
||||
}
|
||||
nonCnameNames = ncn
|
||||
}
|
||||
|
||||
func (zone *Zone) FindRecords(recordType string, options map[string]interface{}) []DNSRecord {
|
||||
|
|
4
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/config.go
generated
vendored
4
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/config.go
generated
vendored
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/go-ini/ini"
|
||||
"gopkg.in/mattes/go-expand-tilde.v1"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
// Config struct provides all the necessary fields to
|
||||
|
@ -86,7 +86,7 @@ func InitEdgeRc(filepath string, section string) (Config, error) {
|
|||
// Tilde seems to be not working when passing ~/.edgerc as file
|
||||
// Takes current user and use home dir instead
|
||||
|
||||
path, err := tilde.Expand(filepath)
|
||||
path, err := homedir.Expand(filepath)
|
||||
|
||||
if err != nil {
|
||||
return c, fmt.Errorf(errorMap[ErrHomeDirNotFound], err)
|
||||
|
|
6
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/signer.go
generated
vendored
6
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/signer.go
generated
vendored
|
@ -14,8 +14,8 @@ import (
|
|||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/google/uuid"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tuvistavie/securerandom"
|
||||
)
|
||||
|
||||
const defaultSection = "DEFAULT"
|
||||
|
@ -49,12 +49,12 @@ func makeEdgeTimeStamp() string {
|
|||
// It is a random string used to detect replayed request messages.
|
||||
// A GUID is recommended.
|
||||
func createNonce() string {
|
||||
uuid, err := securerandom.Uuid()
|
||||
uuid, err := uuid.NewRandom()
|
||||
if err != nil {
|
||||
log.Errorf(errorMap[ErrUUIDGenerateFailed], err)
|
||||
return ""
|
||||
}
|
||||
return uuid
|
||||
return uuid.String()
|
||||
}
|
||||
|
||||
func stringMinifier(in string) (out string) {
|
||||
|
|
2
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/jsonhooks.go
generated
vendored
2
vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/jsonhooks.go
generated
vendored
|
@ -44,7 +44,7 @@ type PreJSONMarshaler interface {
|
|||
// ImplementsPreJSONMarshaler checks for support for the PreMarshalJSON pre-hook
|
||||
func ImplementsPreJSONMarshaler(v interface{}) bool {
|
||||
value := reflect.ValueOf(v)
|
||||
if value.Kind() == reflect.Ptr && value.IsNil() {
|
||||
if !value.IsValid() {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue