Skip to content

Commit

Permalink
Updated Loopia-Go that had a bug and made some clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Identitry committed Jun 8, 2021
1 parent 5026b48 commit fb687f2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/jetstack/cert-manager v1.2.0
github.com/jonlil/loopia-go v0.0.0-20210331190659-ff1ae8413d68
github.com/jonlil/loopia-go v0.0.0-20210527200300-23293e4c6c36
github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b // indirect
k8s.io/apiextensions-apiserver v0.20.4
k8s.io/apimachinery v0.20.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jonlil/loopia-go v0.0.0-20210331190659-ff1ae8413d68 h1:L0laboa/xuoWRYXoLF7Pizn28J88rTASOVeVTygLnrU=
github.com/jonlil/loopia-go v0.0.0-20210331190659-ff1ae8413d68/go.mod h1:Vkp4MTf4Pb8Lu5zPQSQB777pyKa2AJcJPBd7lLp/aNY=
github.com/jonlil/loopia-go v0.0.0-20210527200300-23293e4c6c36 h1:dDla7M09HPLLoRomdOO9ATz0tSZS/ADjEI9ZU3REPhs=
github.com/jonlil/loopia-go v0.0.0-20210527200300-23293e4c6c36/go.mod h1:Vkp4MTf4Pb8Lu5zPQSQB777pyKa2AJcJPBd7lLp/aNY=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down
14 changes: 1 addition & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ func (c *loopiaDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {
creds, err := c.getCredentials(&cfg, ch.ResourceNamespace)
if err != nil {
return fmt.Errorf("unable to get credential: %v", err)
} else if creds.Username != "" && creds.Password != "" {
klog.V(2).Infof("Successfully extracted Loopia API credentials.")
}

// Initialize new Loopia client.
Expand All @@ -102,16 +100,6 @@ func (c *loopiaDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {
zoneRecords, err := loopiaClient.GetZoneRecords(domain, subdomain)
if err != nil {
klog.V(2).Infof("Subdomain %s is not present, needs to be created", subdomain)

// Subdomain not present, create it.
status, err := loopiaClient.AddSubdomain(domain, subdomain)
if err != nil {
return fmt.Errorf("unexpected error: unable to create subdomain: %v", err)
} else if status.Status == "failed" {
return fmt.Errorf("unable to create subdomain: %s %v", status.Cause, err)
} else if status.Status == "success" {
klog.V(2).Infof("Subdomain %s successfully created.", subdomain)
}
} else {
klog.V(2).Infof("Subdomain %s is already present, checking if txt-record is present.", subdomain)

Expand Down Expand Up @@ -140,7 +128,7 @@ func (c *loopiaDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {

// Verify the record has been created by checking it's id.
if record.ID != 0 {
klog.V(2).Infof("Successfully created txt-record in %s subdomain with id $i", subdomain, record.ID)
klog.V(2).Infof("Successfully created txt-record in %s subdomain", subdomain)
} else {
return fmt.Errorf("unexpected error: txt-record was not created: %v", err)
}
Expand Down

0 comments on commit fb687f2

Please sign in to comment.