Skip to content

Commit

Permalink
Add new fields to the example manifest
Browse files Browse the repository at this point in the history
- Remove "FQDN" from spec.atProvider's DNS settings as
  it's a read-only property

Signed-off-by: Alper Rifat Ulucinar <[email protected]>
  • Loading branch information
ulucinar committed Dec 1, 2021
1 parent 2a6da58 commit 4515f75
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 38 deletions.
37 changes: 30 additions & 7 deletions apis/network/v1alpha3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,15 @@ type PublicIPAddressDNSSettings struct {
// the public IP address. If a domain name label is specified,
// an A DNS record is created for the public IP in
// the Microsoft Azure DNS system.
DomainNameLabel *string `json:"domainNameLabel,omitempty"`
// FQDN - Gets the FQDN, Fully qualified domain name of
// the A DNS record associated with the public IP.
// This is the concatenation of the domainNameLabel
// and the regionalized DNS zone.
FQDN *string `json:"fqdn,omitempty"`
// +kubebuilder:validation:MinLength:=1
DomainNameLabel string `json:"domainNameLabel"`
// ReverseFQDN - Gets or Sets the Reverse FQDN.
// A user-visible, fully qualified domain name that
// resolves to this public IP address. If the reverseFqdn
// is specified, then a PTR DNS record is created pointing
// from the IP address in the in-addr.arpa domain to
// the reverse FQDN.
// +optional
ReverseFQDN *string `json:"reverseFqdn,omitempty"`
}

Expand Down Expand Up @@ -342,6 +339,32 @@ type IPConfiguration struct {
ProvisioningState string `json:"provisioningState"`
}

// PublicIPAddressDNSSettingsObservation represents observed DNS settings of
// a public IP resource
type PublicIPAddressDNSSettingsObservation struct {
// DomainNameLabel -the Domain name label.
// The concatenation of the domain name label and the regionalized DNS zone
// make up the fully qualified domain name associated with
// the public IP address. If a domain name label is specified,
// an A DNS record is created for the public IP in
// the Microsoft Azure DNS system.
// +optional
DomainNameLabel *string `json:"domainNameLabel,omitempty"`
// ReverseFQDN - Gets or Sets the Reverse FQDN.
// A user-visible, fully qualified domain name that
// resolves to this public IP address. If the reverseFqdn
// is specified, then a PTR DNS record is created pointing
// from the IP address in the in-addr.arpa domain to
// the reverse FQDN.
// +optional
ReverseFQDN *string `json:"reverseFqdn,omitempty"`
// FQDN - Gets the FQDN, Fully qualified domain name of
// the A DNS record associated with the public IP.
// This is the concatenation of the domainNameLabel
// and the regionalized DNS zone.
FQDN *string `json:"fqdn,omitempty"`
}

// A PublicIPAddressObservation represents the observed state of a PublicIPAddress.
type PublicIPAddressObservation struct {
// State of this PublicIPAddress.
Expand All @@ -363,7 +386,7 @@ type PublicIPAddressObservation struct {
Version string `json:"version"`

// DNSSettings observed DNS settings of the IP address
DNSSettings *PublicIPAddressDNSSettings `json:"dnsSettings,omitempty"`
DNSSettings *PublicIPAddressDNSSettingsObservation `json:"dnsSettings,omitempty"`

// IPConfiguration - The IP configuration associated with the public IP address
IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"`
Expand Down
36 changes: 28 additions & 8 deletions apis/network/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/network/publicipaddress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ spec:
sku:
name: Standard
location: West US 2
tcpIdleTimeoutInMinutes: 5
dnsSettings:
domainNameLabel: crossplane-example
# Looks like the following requires the feature "Microsoft.Network/AllowBringYourOwnPublicIpAddress" to be registered for the subscription
# ipTags:
# - ipTagType: FirstPartyUsage
# tag: Storage
tags:
application: crossplane
providerConfigRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ spec:
properties:
domainNameLabel:
description: DomainNameLabel -the Domain name label. The concatenation of the domain name label and the regionalized DNS zone make up the fully qualified domain name associated with the public IP address. If a domain name label is specified, an A DNS record is created for the public IP in the Microsoft Azure DNS system.
type: string
fqdn:
description: FQDN - Gets the FQDN, Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.
minLength: 1
type: string
reverseFqdn:
description: ReverseFQDN - Gets or Sets the Reverse FQDN. A user-visible, fully qualified domain name that resolves to this public IP address. If the reverseFqdn is specified, then a PTR DNS record is created pointing from the IP address in the in-addr.arpa domain to the reverse FQDN.
type: string
required:
- domainNameLabel
type: object
ipTags:
description: IPTags - IP tags to be assigned to this public IP address
Expand Down
13 changes: 6 additions & 7 deletions pkg/clients/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ func newDNSSettings(s *v1alpha3.PublicIPAddressDNSSettings) *networkmgmt.PublicI
return nil
}
return &networkmgmt.PublicIPAddressDNSSettings{
DomainNameLabel: s.DomainNameLabel,
Fqdn: s.FQDN,
DomainNameLabel: &s.DomainNameLabel,
ReverseFqdn: s.ReverseFQDN,
}
}
Expand Down Expand Up @@ -190,7 +189,7 @@ func UpdatePublicIPAddressStatusFromAzure(v *v1alpha3.PublicIPAddress, az networ
}
}
if az.DNSSettings != nil {
v.Status.AtProvider.DNSSettings = &v1alpha3.PublicIPAddressDNSSettings{
v.Status.AtProvider.DNSSettings = &v1alpha3.PublicIPAddressDNSSettingsObservation{
DomainNameLabel: az.DNSSettings.DomainNameLabel,
FQDN: az.DNSSettings.Fqdn,
ReverseFQDN: az.DNSSettings.ReverseFqdn,
Expand Down Expand Up @@ -236,8 +235,9 @@ func lateInitializeDNSSettings(d *v1alpha3.PublicIPAddressDNSSettings, in *netwo
if d == nil {
d = &v1alpha3.PublicIPAddressDNSSettings{}
}
d.DomainNameLabel = azure.LateInitializeStringPtrFromPtr(d.DomainNameLabel, in.DomainNameLabel)
d.FQDN = azure.LateInitializeStringPtrFromPtr(d.FQDN, in.Fqdn)
if d.DomainNameLabel == "" {
d.DomainNameLabel = azure.ToString(in.DomainNameLabel)
}
d.ReverseFQDN = azure.LateInitializeStringPtrFromPtr(d.ReverseFQDN, in.ReverseFqdn)
return d
}
Expand Down Expand Up @@ -275,8 +275,7 @@ func checkDNSSettings(d *v1alpha3.PublicIPAddressDNSSettings, in *networkmgmt.Pu
if in == nil {
in = &networkmgmt.PublicIPAddressDNSSettings{}
}
return azure.ToString(d.DomainNameLabel) == azure.ToString(in.DomainNameLabel) &&
azure.ToString(d.FQDN) == azure.ToString(in.Fqdn) &&
return d.DomainNameLabel == azure.ToString(in.DomainNameLabel) &&
azure.ToString(d.ReverseFQDN) == azure.ToString(in.ReverseFqdn)
}

Expand Down
19 changes: 6 additions & 13 deletions pkg/clients/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ func TestNewPublicIPAddressParameters(t *testing.T) {
},
PublicIPPrefixID: &prefixID,
PublicIPAddressDNSSettings: &v1alpha3.PublicIPAddressDNSSettings{
DomainNameLabel: &dnsLabel,
FQDN: &fqdn,
DomainNameLabel: dnsLabel,
ReverseFQDN: &reverseFQDN,
},
TCPIdleTimeoutInMinutes: &timeout,
Expand All @@ -452,7 +451,6 @@ func TestNewPublicIPAddressParameters(t *testing.T) {
},
DNSSettings: &networkmgmt.PublicIPAddressDNSSettings{
DomainNameLabel: &dnsLabel,
Fqdn: &fqdn,
ReverseFqdn: &reverseFQDN,
},
IdleTimeoutInMinutes: &timeout,
Expand Down Expand Up @@ -893,8 +891,7 @@ func TestIsPublicIPAddressUpToDate(t *testing.T) {
args: args{
p: v1alpha3.PublicIPAddressProperties{
PublicIPAddressDNSSettings: &v1alpha3.PublicIPAddressDNSSettings{
DomainNameLabel: &dnsLabel,
FQDN: &fqdn,
DomainNameLabel: dnsLabel,
ReverseFQDN: &reverseFQDN,
},
},
Expand All @@ -906,8 +903,7 @@ func TestIsPublicIPAddressUpToDate(t *testing.T) {
args: args{
p: v1alpha3.PublicIPAddressProperties{
PublicIPAddressDNSSettings: &v1alpha3.PublicIPAddressDNSSettings{
DomainNameLabel: &dnsLabel,
FQDN: &fqdn,
DomainNameLabel: dnsLabel,
ReverseFQDN: &reverseFQDN,
},
},
Expand Down Expand Up @@ -1051,8 +1047,7 @@ func TestLateInitializePublicIPAddress(t *testing.T) {
want: v1alpha3.PublicIPAddressProperties{
PublicIPPrefixID: &prefixID,
PublicIPAddressDNSSettings: &v1alpha3.PublicIPAddressDNSSettings{
DomainNameLabel: &dnsLabel,
FQDN: &fqdn,
DomainNameLabel: dnsLabel,
ReverseFQDN: &reverseFQDN,
},
TCPIdleTimeoutInMinutes: &timeout,
Expand All @@ -1076,8 +1071,7 @@ func TestLateInitializePublicIPAddress(t *testing.T) {
// SKU: nil,
PublicIPPrefixID: &prefixID,
PublicIPAddressDNSSettings: &v1alpha3.PublicIPAddressDNSSettings{
DomainNameLabel: &dnsLabel,
FQDN: &fqdn,
DomainNameLabel: dnsLabel,
ReverseFQDN: &reverseFQDN,
},
TCPIdleTimeoutInMinutes: &timeout,
Expand Down Expand Up @@ -1111,8 +1105,7 @@ func TestLateInitializePublicIPAddress(t *testing.T) {
// SKU: nil,
PublicIPPrefixID: &prefixID,
PublicIPAddressDNSSettings: &v1alpha3.PublicIPAddressDNSSettings{
DomainNameLabel: &dnsLabel,
FQDN: &fqdn,
DomainNameLabel: dnsLabel,
ReverseFQDN: &reverseFQDN,
},
TCPIdleTimeoutInMinutes: &timeout,
Expand Down

0 comments on commit 4515f75

Please sign in to comment.