Skip to content

Commit

Permalink
PublicIPAddress support
Browse files Browse the repository at this point in the history
Signed-off-by: vaspahomov <[email protected]>
Signed-off-by: vaspahomov <[email protected]>
  • Loading branch information
vaspahomov authored and vaspahomov committed Jun 21, 2021
1 parent 9e64a76 commit 1baed27
Show file tree
Hide file tree
Showing 14 changed files with 1,174 additions and 0 deletions.
21 changes: 21 additions & 0 deletions apis/network/v1alpha3/referencers.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,24 @@ func (mg *Subnet) ResolveReferences(ctx context.Context, c client.Reader) error

return nil
}

// ResolveReferences of this PublicIPAddress
func (mg *PublicIPAddress) ResolveReferences(ctx context.Context, c client.Reader) error {
r := reference.NewAPIResolver(c, mg)

// Resolve spec.resourceGroupName
rsp, err := r.Resolve(ctx, reference.ResolutionRequest{
CurrentValue: mg.Spec.ResourceGroupName,
Reference: mg.Spec.ResourceGroupNameRef,
Selector: mg.Spec.ResourceGroupNameSelector,
To: reference.To{Managed: &v1alpha3.ResourceGroup{}, List: &v1alpha3.ResourceGroupList{}},
Extract: reference.ExternalName(),
})
if err != nil {
return errors.Wrap(err, "spec.resourceGroupName")
}
mg.Spec.ResourceGroupName = rsp.ResolvedValue
mg.Spec.ResourceGroupNameRef = rsp.ResolvedReference

return nil
}
9 changes: 9 additions & 0 deletions apis/network/v1alpha3/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ var (
SubnetGroupVersionKind = SchemeGroupVersion.WithKind(SubnetKind)
)

// PublicIpAddress type metadata.
var (
PublicIPAddressKind = reflect.TypeOf(PublicIPAddress{}).Name()
PublicIPAddressGroupKind = schema.GroupKind{Group: Group, Kind: PublicIPAddressKind}.String()
PublicIPAddressKindAPIVersion = PublicIPAddressKind + "." + SchemeGroupVersion.String()
PublicIPAddressGroupVersionKind = SchemeGroupVersion.WithKind(PublicIPAddressKind)
)

func init() {
SchemeBuilder.Register(&VirtualNetwork{}, &VirtualNetworkList{})
SchemeBuilder.Register(&Subnet{}, &SubnetList{})
SchemeBuilder.Register(&PublicIPAddress{}, &PublicIPAddressList{})
}
92 changes: 92 additions & 0 deletions apis/network/v1alpha3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,95 @@ type SubnetList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []Subnet `json:"items"`
}

// A PublicIPAddressSpec defines the desired state of a PublicIPAddress.
type PublicIPAddressSpec struct {
xpv1.ResourceSpec `json:",inline"`

// ResourceGroupName - Name of the Public IP address's resource group.
ResourceGroupName string `json:"resourceGroupName,omitempty"`

// ResourceGroupNameRef - A reference to the the Public IP address's resource
// group.
ResourceGroupNameRef *xpv1.Reference `json:"resourceGroupNameRef,omitempty"`

// ResourceGroupNameSelector - Select a reference to the the Public IP address's
// resource group.
ResourceGroupNameSelector *xpv1.Selector `json:"resourceGroupNameSelector,omitempty"`

// PublicIPAddressFormat - Properties of the PublicIPAddress.
PublicIPAddressFormat PublicIPAddressFormat `json:"properties"`

// Tags - Resource tags.
// +optional
Tags map[string]*string `json:"tags,omitempty"`
}

// PublicIPAddressFormat defines properties of the PublicIPAddress.
type PublicIPAddressFormat struct {
// PublicIPAllocationMethod - The public IP address allocation method. Possible values include: 'Static', 'Dynamic'
PublicIPAllocationMethod string `json:"allocationMethod"`

// PublicIPAllocationMethod - The public IP address version. Possible values include: 'IPV4', 'IPV6'
PublicIPAddressVersion string `json:"version"`

// Location - Resource location.
Location string `json:"location"`

// SKU of PublicIPAddress
SKU SKU `json:"sku"`
}

// SKU of PublicIPAddress
type SKU struct {
// Name - Name of sku. Possible values include: 'Standard'
Name string `json:"name"`
}

// A PublicIPAddressStatus represents the observed state of a PublicIPAddress.
type PublicIPAddressStatus struct {
xpv1.ResourceStatus `json:",inline"`

// State of this PublicIPAddress.
State string `json:"state,omitempty"`

// A Message providing detail about the state of this PublicIPAddress, if any.
Message string `json:"message,omitempty"`

// Etag - A unique string that changes whenever the resource is updated.
Etag string `json:"etag,omitempty"`

// ID of this PublicIPAddress.
ID string `json:"id,omitempty"`

// Address - A string identifying address of PublicIPAddress resource
Address string `json:"address"`
}

// +kubebuilder:object:root=true

// A PublicIPAddress is a managed resource that represents an Azure PublicIPAddress.
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
// +kubebuilder:printcolumn:name="STATE",type="string",JSONPath=".status.state"
// +kubebuilder:printcolumn:name="LOCATION",type="string",JSONPath=".spec.properties.location"
// +kubebuilder:printcolumn:name="ADDRESS",type="string",JSONPath=".status.address"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,azure}
type PublicIPAddress struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec PublicIPAddressSpec `json:"spec"`
Status PublicIPAddressStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// PublicIPAddressList contains a list of PublicIPAddress items
type PublicIPAddressList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PublicIPAddress `json:"items"`
}
148 changes: 148 additions & 0 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.

56 changes: 56 additions & 0 deletions apis/network/v1alpha3/zz_generated.managed.go

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

9 changes: 9 additions & 0 deletions apis/network/v1alpha3/zz_generated.managedlist.go

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

15 changes: 15 additions & 0 deletions examples/network/publiipaddress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: network.azure.crossplane.io/v1alpha3
kind: PublicIPAddress
metadata:
name: example-public-ip-address
spec:
resourceGroupNameRef:
name: example-rg
properties:
allocationMethod: static
version: IPV4
sku:
name: Standard
location: West US 2
providerConfigRef:
name: example
Loading

0 comments on commit 1baed27

Please sign in to comment.