Skip to content

Commit

Permalink
dns: add missing filters for type and UID (#1429)
Browse files Browse the repository at this point in the history
  • Loading branch information
BeryJu authored Jan 10, 2025
1 parent ad68c86 commit 3f9f244
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/roles/dns/api_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
type APIRecordsGetInput struct {
Zone string `query:"zone"`
Hostname string `query:"hostname" description:"Optionally get DNS Records for hostname"`
Type string `query:"type"`
UID string `query:"uid"`
}
type APIRecord struct {
UID string `json:"uid" required:"true"`
Expand Down Expand Up @@ -52,11 +54,18 @@ func (r *Role) APIRecordsGet() usecase.Interactor {
types.KeyZones,
zone.Name,
)
if input.Hostname == "" {
recordKey = recordKey.Prefix(true)
} else {
if input.Hostname != "" {
recordKey = recordKey.Add(input.Hostname).Prefix(true)
}
if input.Type != "" {
recordKey = recordKey.Add(strings.ToUpper(input.Type)).Prefix(true)
}
if input.UID != "" {
recordKey = recordKey.Add(input.UID).Prefix(true)
}
if input.Hostname == "" && input.Type == "" && input.UID == "" {
recordKey = recordKey.Prefix(true)
}
rawRecords, err := r.i.KV().Get(ctx, recordKey.String(), clientv3.WithPrefix())
if err != nil {
return status.Wrap(err, status.Internal)
Expand Down

0 comments on commit 3f9f244

Please sign in to comment.