Create ACME Provider
This commit is contained in:
parent
bf43149d7e
commit
8380de1bd9
41 changed files with 1672 additions and 657 deletions
50
types/domains.go
Normal file
50
types/domains.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Domain holds a domain name with SANs
|
||||
type Domain struct {
|
||||
Main string
|
||||
SANs []string
|
||||
}
|
||||
|
||||
// Domains parse []Domain
|
||||
type Domains []Domain
|
||||
|
||||
// Set []Domain
|
||||
func (ds *Domains) Set(str string) error {
|
||||
fargs := func(c rune) bool {
|
||||
return c == ',' || c == ';'
|
||||
}
|
||||
|
||||
// get function
|
||||
slice := strings.FieldsFunc(str, fargs)
|
||||
if len(slice) < 1 {
|
||||
return fmt.Errorf("parse error ACME.Domain. Unable to parse %s", str)
|
||||
}
|
||||
|
||||
d := Domain{
|
||||
Main: slice[0],
|
||||
}
|
||||
|
||||
if len(slice) > 1 {
|
||||
d.SANs = slice[1:]
|
||||
}
|
||||
|
||||
*ds = append(*ds, d)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get []Domain
|
||||
func (ds *Domains) Get() interface{} { return []Domain(*ds) }
|
||||
|
||||
// String returns []Domain in string
|
||||
func (ds *Domains) String() string { return fmt.Sprintf("%+v", *ds) }
|
||||
|
||||
// SetValue sets []Domain into the parser
|
||||
func (ds *Domains) SetValue(val interface{}) {
|
||||
*ds = val.([]Domain)
|
||||
}
|
|
@ -309,7 +309,7 @@ func (c *Constraint) MatchConstraintWithAtLeastOneTag(tags []string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
//Set []*Constraint
|
||||
// Set []*Constraint
|
||||
func (cs *Constraints) Set(str string) error {
|
||||
exps := strings.Split(str, ",")
|
||||
if len(exps) == 0 {
|
||||
|
@ -328,13 +328,13 @@ func (cs *Constraints) Set(str string) error {
|
|||
// Constraints holds a Constraint parser
|
||||
type Constraints []*Constraint
|
||||
|
||||
//Get []*Constraint
|
||||
// Get []*Constraint
|
||||
func (cs *Constraints) Get() interface{} { return []*Constraint(*cs) }
|
||||
|
||||
//String returns []*Constraint in string
|
||||
// String returns []*Constraint in string
|
||||
func (cs *Constraints) String() string { return fmt.Sprintf("%+v", *cs) }
|
||||
|
||||
//SetValue sets []*Constraint into the parser
|
||||
// SetValue sets []*Constraint into the parser
|
||||
func (cs *Constraints) SetValue(val interface{}) {
|
||||
*cs = val.(Constraints)
|
||||
}
|
||||
|
@ -432,8 +432,8 @@ type InfluxDB struct {
|
|||
// Buckets holds Prometheus Buckets
|
||||
type Buckets []float64
|
||||
|
||||
//Set adds strings elem into the the parser
|
||||
//it splits str on "," and ";" and apply ParseFloat to string
|
||||
// Set adds strings elem into the the parser
|
||||
// it splits str on "," and ";" and apply ParseFloat to string
|
||||
func (b *Buckets) Set(str string) error {
|
||||
fargs := func(c rune) bool {
|
||||
return c == ',' || c == ';'
|
||||
|
@ -450,13 +450,13 @@ func (b *Buckets) Set(str string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//Get []float64
|
||||
// Get []float64
|
||||
func (b *Buckets) Get() interface{} { return *b }
|
||||
|
||||
//String return slice in a string
|
||||
// String return slice in a string
|
||||
func (b *Buckets) String() string { return fmt.Sprintf("%v", *b) }
|
||||
|
||||
//SetValue sets []float64 into the parser
|
||||
// SetValue sets []float64 into the parser
|
||||
func (b *Buckets) SetValue(val interface{}) {
|
||||
*b = val.(Buckets)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue