Skip to content
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

Droplet resource additional printer columns #61

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apis/compute/v1alpha1/droplet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ type DropletObservation struct {
// ID for the resource. This identifier is defined by the server.
ID int `json:"id,omitempty"`

// Private IPv4 address of the resource.
PrivateIPv4 string `json:"privateIPv4,omitempty"`

// Public IPv4 address of the resource.
PublicIPv4 string `json:"publicIPv4,omitempty"`

// Resource region slug.
Region string `json:"region,omitempty"`

// Resource size slug.
Size string `json:"size,omitempty"`

// A Status string indicating the state of the Droplet instance.
//
// Possible values:
Expand All @@ -148,7 +160,11 @@ type DropletStatus struct {
// +kubebuilder:object:root=true

// A Droplet is a managed resource that represents a DigitalOcean Droplet.
// +kubebuilder:printcolumn:name="PRIVATE IPv4",type="string",JSONPath=".status.atProvider.privateIPv4"
// +kubebuilder:printcolumn:name="PUBLIC IPv4",type="string",JSONPath=".status.atProvider.publicIPv4"
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="REGION",type="string",JSONPath=".status.atProvider.region"
// +kubebuilder:printcolumn:name="SIZE",type="string",JSONPath=".status.atProvider.size"
// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,do}
Expand Down
24 changes: 24 additions & 0 deletions package/crds/compute.do.crossplane.io_droplets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@ spec:
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .status.atProvider.privateIPv4
name: PRIVATE IPv4
type: string
- jsonPath: .status.atProvider.publicIPv4
name: PUBLIC IPv4
type: string
- jsonPath: .status.conditions[?(@.type=='Ready')].status
name: READY
type: string
- jsonPath: .status.atProvider.region
name: REGION
type: string
- jsonPath: .status.atProvider.size
name: SIZE
type: string
- jsonPath: .status.conditions[?(@.type=='Synced')].status
name: SYNCED
type: string
Expand Down Expand Up @@ -195,6 +207,18 @@ spec:
description: ID for the resource. This identifier is defined by
the server.
type: integer
privateIPv4:
description: Private IPv4 address of the resource.
type: string
publicIPv4:
description: Public IPv4 address of the resource.
type: string
region:
description: Resource region slug.
type: string
size:
description: Resource size slug.
type: string
status:
description: "A Status string indicating the state of the Droplet
instance. \n Possible values: \"new\" \"active\" \"off\"
Expand Down
6 changes: 6 additions & 0 deletions pkg/controller/compute/droplet.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ func (c *dropletExternal) Observe(ctx context.Context, mg resource.Managed) (man

currentSpec := cr.Spec.ForProvider.DeepCopy()
docompute.LateInitializeSpec(&cr.Spec.ForProvider, *observed)
observedPrivateIPv4, _ := observed.PrivateIPv4()
observedPublicIPv4, _ := observed.PublicIPv4()

cr.Status.AtProvider = v1alpha1.DropletObservation{
CreationTimestamp: observed.Created,
ID: observed.ID,
PrivateIPv4: observedPrivateIPv4,
PublicIPv4: observedPublicIPv4,
Region: observed.Region.Slug,
Size: observed.SizeSlug,
Status: observed.Status,
}
if err := c.kube.Status().Update(ctx, cr); err != nil {
Expand Down