-
Notifications
You must be signed in to change notification settings - Fork 2
π€ Update module github.com/stackitcloud/stackit-sdk-go/services/dns to v0.21.0 #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,12 @@ func (c *dnsClient) ListZones(ctx context.Context) ([]DNSZone, error) { | |
| func (c *dnsClient) CreateOrUpdateRecordSet(ctx context.Context, | ||
| zoneID, name, recordType string, wantedRecords []string, ttl int64, | ||
| ) error { | ||
| recordSet, err := c.findRecordSet(ctx, zoneID, name, recordType) | ||
| recordSetType, err := dns.NewRecordSetTypeFromValue(recordType) | ||
| if err != nil || recordSetType == nil { | ||
| return fmt.Errorf("invalid DNS record type %q: %w", recordType, err) | ||
| } | ||
|
|
||
| recordSet, err := c.findRecordSet(ctx, zoneID, name, recordSetType) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to find record set: %w", err) | ||
| } | ||
|
|
@@ -88,11 +93,16 @@ func (c *dnsClient) CreateOrUpdateRecordSet(ctx context.Context, | |
| return err | ||
| } | ||
|
|
||
| payloadType, err := dns.NewCreateRecordSetPayloadTypeFromValue(recordType) | ||
| if err != nil || payloadType == nil { | ||
| return fmt.Errorf("invalid DNS record type %q for create payload: %w", recordType, err) | ||
| } | ||
|
|
||
| if recordSet == nil { | ||
| _, err := c.api.CreateRecordSet(ctx, c.projectID, zoneID).CreateRecordSetPayload(dns.CreateRecordSetPayload{ | ||
| Name: name, | ||
| Records: wantedRecordsPayload, | ||
| Type: recordType, | ||
| Type: *payloadType, | ||
| Ttl: new(cacheTTL), | ||
| }).Execute() | ||
| if err != nil { | ||
|
|
@@ -119,7 +129,12 @@ func (c *dnsClient) CreateOrUpdateRecordSet(ctx context.Context, | |
| } | ||
|
|
||
| func (c *dnsClient) DeleteRecordSet(ctx context.Context, zoneID, name, recordType string) error { | ||
| recordSet, err := c.findRecordSet(ctx, zoneID, name, recordType) | ||
| recordSetType, err := dns.NewRecordSetTypeFromValue(recordType) | ||
| if err != nil || recordSetType == nil { | ||
| return fmt.Errorf("invalid DNS record type %q: %w", recordType, err) | ||
| } | ||
|
|
||
| recordSet, err := c.findRecordSet(ctx, zoneID, name, recordSetType) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to find record set: %w", err) | ||
| } | ||
|
|
@@ -134,7 +149,7 @@ func (c *dnsClient) DeleteRecordSet(ctx context.Context, zoneID, name, recordTyp | |
| return nil | ||
| } | ||
|
|
||
| func (c *dnsClient) findRecordSet(ctx context.Context, zoneID, name, recordType string) (*dns.RecordSet, error) { | ||
| func (c *dnsClient) findRecordSet(ctx context.Context, zoneID, name string, recordType *dns.RecordSetType) (*dns.RecordSet, error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Is there a reason why dns.RecordSetType is ptr to string? Seems overkill
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems easier to just have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then i have to create an explicit nil check in the other function. |
||
| resp, err := c.api.ListRecordSets(ctx, c.projectID, zoneID).Execute() | ||
| if err != nil { | ||
| return nil, err | ||
|
|
@@ -148,7 +163,7 @@ func (c *dnsClient) findRecordSet(ctx context.Context, zoneID, name, recordType | |
| if strings.TrimSuffix(recordSet.GetName(), ".") != name { | ||
| continue | ||
| } | ||
| if recordSet.GetType() != recordType { | ||
| if recordType == nil || recordSet.GetType() != *recordType { | ||
| continue | ||
| } | ||
| return &recordSet, nil | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.