forked from TrueCloudLab/lego
42941ccea6
- Packages - Isolate code used by the CLI into the package `cmd` - (experimental) Add e2e tests for HTTP01, TLS-ALPN-01 and DNS-01, use [Pebble](https://github.com/letsencrypt/pebble) and [challtestsrv](https://github.com/letsencrypt/boulder/tree/master/test/challtestsrv) - Support non-ascii domain name (punnycode) - Check all challenges in a predictable order - No more global exported variables - Archive revoked certificates - Fixes revocation for subdomains and non-ascii domains - Disable pending authorizations - use pointer for RemoteError/ProblemDetails - Poll authz URL instead of challenge URL - The ability for a DNS provider to solve the challenge sequentially - Check all nameservers in a predictable order - Option to disable the complete propagation Requirement - CLI, support for renew with CSR - CLI, add SAN on renew - Add command to list certificates. - Logs every iteration of waiting for the propagation - update DNSimple client - update github.com/miekg/dns
86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/url"
|
|
"strings"
|
|
|
|
"github.com/sacloud/libsacloud/sacloud"
|
|
)
|
|
|
|
// Reset 検索条件のリセット
|
|
func (api *WebAccelAPI) Reset() *WebAccelAPI {
|
|
api.SetEmpty()
|
|
return api
|
|
}
|
|
|
|
// SetEmpty 検索条件のリセット
|
|
func (api *WebAccelAPI) SetEmpty() {
|
|
api.reset()
|
|
}
|
|
|
|
// FilterBy 指定キーでのフィルター
|
|
func (api *WebAccelAPI) FilterBy(key string, value interface{}) *WebAccelAPI {
|
|
api.filterBy(key, value, false)
|
|
return api
|
|
}
|
|
|
|
// WithNameLike 名称条件
|
|
func (api *WebAccelAPI) WithNameLike(name string) *WebAccelAPI {
|
|
return api.FilterBy("Name", name)
|
|
}
|
|
|
|
// SetFilterBy 指定キーでのフィルター
|
|
func (api *WebAccelAPI) SetFilterBy(key string, value interface{}) {
|
|
api.filterBy(key, value, false)
|
|
}
|
|
|
|
// SetNameLike 名称条件
|
|
func (api *WebAccelAPI) SetNameLike(name string) {
|
|
api.FilterBy("Name", name)
|
|
}
|
|
|
|
// Find サイト一覧取得
|
|
func (api *WebAccelAPI) Find() (*sacloud.SearchResponse, error) {
|
|
|
|
uri := fmt.Sprintf("%s/site", api.getResourceURL())
|
|
|
|
data, err := api.client.newRequest("GET", uri, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var res sacloud.SearchResponse
|
|
if err := json.Unmarshal(data, &res); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// handle filter(API側がFilterに対応していないためここでフィルタリング)
|
|
for key, filter := range api.getSearchState().Filter {
|
|
if key != "Name" {
|
|
continue
|
|
}
|
|
strNames, ok := filter.(string)
|
|
if !ok {
|
|
continue
|
|
}
|
|
|
|
names := strings.Split(strNames, " ")
|
|
filtered := []sacloud.WebAccelSite{}
|
|
for _, site := range res.WebAccelSites {
|
|
for _, name := range names {
|
|
|
|
u, _ := url.Parse(name)
|
|
|
|
if strings.Contains(site.Name, u.Path) {
|
|
filtered = append(filtered, site)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
res.WebAccelSites = filtered
|
|
}
|
|
|
|
return &res, nil
|
|
}
|