forked from TrueCloudLab/lego
Adjust naming of webroot provider to be in line with DNS providers.
This commit is contained in:
parent
325db78c91
commit
118d9d5ec9
3 changed files with 10 additions and 10 deletions
|
@ -55,7 +55,7 @@ func setup(c *cli.Context) (*Configuration, *Account, *acme.Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.GlobalIsSet("webroot") {
|
if c.GlobalIsSet("webroot") {
|
||||||
provider, err := webroot.NewHTTPProviderWebroot(c.GlobalString("webroot"))
|
provider, err := webroot.NewHTTPProvider(c.GlobalString("webroot"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger().Fatal(err)
|
logger().Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,18 +10,18 @@ import (
|
||||||
"github.com/xenolf/lego/acme"
|
"github.com/xenolf/lego/acme"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTTPProviderWebroot implements ChallengeProvider for `http-01` challenge
|
// HTTPProvider implements ChallengeProvider for `http-01` challenge
|
||||||
type HTTPProviderWebroot struct {
|
type HTTPProvider struct {
|
||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHTTPProviderWebroot returns a HTTPProviderWebroot instance with a configured webroot path
|
// NewHTTPProvider returns a HTTPProvider instance with a configured webroot path
|
||||||
func NewHTTPProviderWebroot(path string) (*HTTPProviderWebroot, error) {
|
func NewHTTPProvider(path string) (*HTTPProvider, error) {
|
||||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||||
return nil, fmt.Errorf("Webroot path does not exist")
|
return nil, fmt.Errorf("Webroot path does not exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &HTTPProviderWebroot{
|
c := &HTTPProvider{
|
||||||
path: path,
|
path: path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ func NewHTTPProviderWebroot(path string) (*HTTPProviderWebroot, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present makes the token available at `HTTP01ChallengePath(token)` by creating a file in the given webroot path
|
// Present makes the token available at `HTTP01ChallengePath(token)` by creating a file in the given webroot path
|
||||||
func (w *HTTPProviderWebroot) Present(domain, token, keyAuth string) error {
|
func (w *HTTPProvider) Present(domain, token, keyAuth string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
challengeFilePath := path.Join(w.path, acme.HTTP01ChallengePath(token))
|
challengeFilePath := path.Join(w.path, acme.HTTP01ChallengePath(token))
|
||||||
|
@ -47,7 +47,7 @@ func (w *HTTPProviderWebroot) Present(domain, token, keyAuth string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp removes the file created for the challenge
|
// CleanUp removes the file created for the challenge
|
||||||
func (w *HTTPProviderWebroot) CleanUp(domain, token, keyAuth string) error {
|
func (w *HTTPProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
var err error
|
var err error
|
||||||
err = os.Remove(path.Join(w.path, acme.HTTP01ChallengePath(token)))
|
err = os.Remove(path.Join(w.path, acme.HTTP01ChallengePath(token)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHTTPProviderWebRoot(t *testing.T) {
|
func TestHTTPProvider(t *testing.T) {
|
||||||
webroot := "webroot"
|
webroot := "webroot"
|
||||||
domain := "domain"
|
domain := "domain"
|
||||||
token := "token"
|
token := "token"
|
||||||
|
@ -16,7 +16,7 @@ func TestHTTPProviderWebRoot(t *testing.T) {
|
||||||
os.MkdirAll(webroot+"/.well-known/acme-challenge", 0777)
|
os.MkdirAll(webroot+"/.well-known/acme-challenge", 0777)
|
||||||
defer os.RemoveAll(webroot)
|
defer os.RemoveAll(webroot)
|
||||||
|
|
||||||
provider, err := NewHTTPProviderWebroot(webroot)
|
provider, err := NewHTTPProvider(webroot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Webroot provider error: got %v, want nil", err)
|
t.Errorf("Webroot provider error: got %v, want nil", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue