Skip to content

Commit

Permalink
Merge pull request #8 from RunnerM/feature/1.10.1_upgrading
Browse files Browse the repository at this point in the history
fix cleanup bug
  • Loading branch information
RunnerM authored Jan 3, 2023
2 parents 1eac538 + 7347a79 commit 11e0c49
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func (c *SimplyClient) AddTxtRecord(FQDNName string, Value string, credentials C

// RemoveTxtRecord Remove TXT record from symply
func (c *SimplyClient) RemoveTxtRecord(RecordId int, DnsName string, credentials Credentials) bool {
req, err := http.NewRequest("DELETE", apiUrl+"/my/products/"+DnsName+"/dns/records/"+strconv.Itoa(RecordId), nil)
dnsName := cutTrailingDotIfExist(DnsName)
req, err := http.NewRequest("DELETE", apiUrl+"/my/products/"+domainutil.Domain(dnsName)+"/dns/records/"+strconv.Itoa(RecordId), nil)
req.SetBasicAuth(credentials.AccountName, credentials.ApiKey)
client := &http.Client{}
response, err := client.Do(req)
Expand Down
3 changes: 1 addition & 2 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type testData struct {
// Plot in your own api details for testing.
func TestAll(t *testing.T) {
data := testData{ //add your credentials here to test.
basedomain: "foo.com",
domain: "_acme-challenge.foo.com",
data: "test_txt_data",
data2: "test_txt_data_2",
Expand Down Expand Up @@ -71,7 +70,7 @@ func testRemove(t *testing.T, data testData, id int) {
t.Fail()
}

res := fixture.RemoveTxtRecord(id, data.basedomain, Credentials{
res := fixture.RemoveTxtRecord(id, data.domain, Credentials{
AccountName: data.accountname,
ApiKey: data.apikey,
})
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ func (e *SimplyDnsSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error {
res := e.client.RemoveTxtRecord(id, ch.DNSName, cred)
if res == true {
fmt.Println("Record(", id, ") have been cleaned up.")
return nil
} else {
_ = fmt.Errorf("record(%d) have no tbeen cleaned up", id)
return err
}
return nil

}

func (e *SimplyDnsSolver) Initialize(kubeClientConfig *rest.Config, stopCh <-chan struct{}) error {
Expand Down

0 comments on commit 11e0c49

Please sign in to comment.