-
Notifications
You must be signed in to change notification settings - Fork 221
NE-969: Add IBM DNS Services provider support for private clusters #796
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
Merged
openshift-merge-robot
merged 1 commit into
openshift:master
from
SzucsAti:ibm-dnssvc-support
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package common | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "regexp" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
| kerrors "k8s.io/apimachinery/pkg/util/errors" | ||
|
|
||
| iov1 "github.com/openshift/api/operatoringress/v1" | ||
| ) | ||
|
|
||
| var ( | ||
| // IBMResourceCRNRegexp is a regular expression of IBM resource CRNs | ||
| // See: https://cloud.ibm.com/docs/account?topic=account-crn | ||
| IBMResourceCRNRegexp = regexp.MustCompile(`^crn:v[0-9]:(?P<cloudName>[^:]*):(?P<cloudType>[^:]*):(?P<serviceName>[^:]*):(?P<location>[^:]*):(?P<scope>[^:]*):(?P<guid>[^:]*):(?P<resourceType>[^:]*):(?P<resourceID>[^:]*)$`) | ||
| ) | ||
|
|
||
| // Config holds common configuration of IBM DNS providers. | ||
| type Config struct { | ||
| // APIKey is the IBM Cloud API key that the provider will use. | ||
| APIKey string | ||
| // InstanceID is GUID in case of dns svcs and CRN in case of cis. | ||
| InstanceID string | ||
| // UserAgent is the user-agent identifier that the client will use in | ||
| // HTTP requests to the IBM Cloud API. | ||
| UserAgent string | ||
| // Zones is a list of DNS zones in which the DNS provider manages DNS records. | ||
| Zones []string | ||
| } | ||
|
|
||
| // ValidateInputDNSData validates the given record and zone. | ||
| func ValidateInputDNSData(record *iov1.DNSRecord, zone configv1.DNSZone) error { | ||
| var errs []error | ||
| if record == nil { | ||
| errs = append(errs, fmt.Errorf("validateInputDNSData: dns record is nil")) | ||
| } else { | ||
| if len(record.Spec.DNSName) == 0 { | ||
| errs = append(errs, fmt.Errorf("validateInputDNSData: dns record name is empty")) | ||
| } | ||
| if len(record.Spec.RecordType) == 0 { | ||
| errs = append(errs, fmt.Errorf("validateInputDNSData: dns record type is empty")) | ||
| } | ||
| if len(record.Spec.Targets) == 0 { | ||
| errs = append(errs, fmt.Errorf("validateInputDNSData: dns record content is empty")) | ||
| } | ||
| } | ||
| if len(zone.ID) == 0 { | ||
| errs = append(errs, fmt.Errorf("validateInputDNSData: dns zone id is empty")) | ||
| } | ||
| return kerrors.NewAggregate(errs) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package client | ||
|
|
||
| import ( | ||
| "github.com/IBM/go-sdk-core/v5/core" | ||
| "github.com/IBM/networking-go-sdk/dnssvcsv1" | ||
| ) | ||
|
|
||
| // DnsClient is an interface to describe the methods defined in dnssvcsv1 | ||
| // for the purpose of having an interface that we can use in the implementation and test code for cluster-ingress-operator's provider logic. | ||
| type DnsClient interface { | ||
| NewListResourceRecordsOptions(instanceID string, dnszoneID string) *dnssvcsv1.ListResourceRecordsOptions | ||
| ListResourceRecords(listResourceRecordsOptions *dnssvcsv1.ListResourceRecordsOptions) (result *dnssvcsv1.ListResourceRecords, response *core.DetailedResponse, err error) | ||
| NewDeleteResourceRecordOptions(instanceID string, dnszoneID string, recordID string) *dnssvcsv1.DeleteResourceRecordOptions | ||
| DeleteResourceRecord(deleteResourceRecordOptions *dnssvcsv1.DeleteResourceRecordOptions) (response *core.DetailedResponse, err error) | ||
| NewUpdateResourceRecordOptions(instanceID string, dnszoneID string, recordID string) *dnssvcsv1.UpdateResourceRecordOptions | ||
| NewResourceRecordUpdateInputRdataRdataCnameRecord(cname string) (_model *dnssvcsv1.ResourceRecordUpdateInputRdataRdataCnameRecord, err error) | ||
| NewResourceRecordUpdateInputRdataRdataARecord(ip string) (_model *dnssvcsv1.ResourceRecordUpdateInputRdataRdataARecord, err error) | ||
| UpdateResourceRecord(updateResourceRecordOptions *dnssvcsv1.UpdateResourceRecordOptions) (result *dnssvcsv1.ResourceRecord, response *core.DetailedResponse, err error) | ||
| NewCreateResourceRecordOptions(instanceID string, dnszoneID string) *dnssvcsv1.CreateResourceRecordOptions | ||
| NewResourceRecordInputRdataRdataCnameRecord(cname string) (_model *dnssvcsv1.ResourceRecordInputRdataRdataCnameRecord, err error) | ||
| NewResourceRecordInputRdataRdataARecord(ip string) (_model *dnssvcsv1.ResourceRecordInputRdataRdataARecord, err error) | ||
| CreateResourceRecord(createResourceRecordOptions *dnssvcsv1.CreateResourceRecordOptions) (result *dnssvcsv1.ResourceRecord, response *core.DetailedResponse, err error) | ||
| NewGetDnszoneOptions(instanceID string, dnszoneID string) *dnssvcsv1.GetDnszoneOptions | ||
| GetDnszone(getDnszoneOptions *dnssvcsv1.GetDnszoneOptions) (result *dnssvcsv1.Dnszone, response *core.DetailedResponse, err error) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this interface should be defined in
"github.com/IBM/networking-go-sdk/dnssvcsv1", but I guess we can't do anything about that. Maybe add a comment to say that we're defining this interface to describe the methods defined indnssvcsv1for the purpose of having an interface that we can use in the implementation and test code for cluster-ingress-operator's provider logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. Added a comment.