-
Notifications
You must be signed in to change notification settings - Fork 22
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
Volume support #58
Merged
Merged
Volume support #58
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
865255a
civogo version bump
uzaxirr df4bfbc
specs define
uzaxirr 70f0a88
rm cluster with volume
uzaxirr 7ed0ff7
CivoVolume in register.go
uzaxirr 2da7364
Add volume controllers
uzaxirr edbb401
Polish
uzaxirr 72d6e05
Attach Volume to instance
uzaxirr 07090fb
Tidy observation struct
uzaxirr a6a2737
size lowercase
uzaxirr 0ba4c9a
linting
uzaxirr 429d994
update example
uzaxirr a0d1700
refactor update function
uzaxirr 5420309
rm unused error
uzaxirr 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 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
/.vendor-new | ||
.vscode | ||
temp | ||
.idea/ |
This file contains 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,21 @@ | ||
/* | ||
Copyright 2024 The Crossplane Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package v1alpha1 contains the v1alpha1 group Sample resources of the Template provider. | ||
// +kubebuilder:object:generate=true | ||
// +groupName=volume.civo.crossplane.io | ||
// +versionName=v1alpha1 | ||
package v1alpha1 |
This file contains 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,50 @@ | ||
/* | ||
Copyright 2024 The Crossplane Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"reflect" | ||
|
||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
// Package type metadata. | ||
const ( | ||
Group = "volume.civo.crossplane.io" | ||
Version = "v1alpha1" | ||
) | ||
|
||
var ( | ||
// SchemeGroupVersion is group version used to register these objects | ||
SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} | ||
) | ||
|
||
// CivoVolume type metadata. | ||
var ( | ||
CivoVolumeKind = reflect.TypeOf(CivoVolume{}).Name() | ||
CivoVolumeGroupKind = schema.GroupKind{Group: Group, Kind: CivoVolumeKind}.String() | ||
CivoVolumeKindAPIVersion = CivoVolumeKind + "." + SchemeGroupVersion.String() | ||
CivoVolumeGroupVersionKind = SchemeGroupVersion.WithKind(CivoVolumeKind) | ||
) | ||
|
||
func init() { | ||
SchemeBuilder.Register(&CivoVolume{}, &CivoVolumeList{}) | ||
} |
This file contains 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,119 @@ | ||
/* | ||
Copyright 2024 The Crossplane Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" | ||
) | ||
|
||
// CivoVolumeObservation are the observable fields of a CivoVolume. | ||
type CivoVolumeObservation struct { | ||
ID string `json:"id"` | ||
InstanceID string `json:"instance_id"` | ||
Size int `json:"size"` | ||
Status string `json:"status"` | ||
} | ||
|
||
// CivoVolumeSpec defines schema for a CivoVolume resource. | ||
type CivoVolumeSpec struct { | ||
xpv1.ResourceSpec `json:",inline"` | ||
|
||
// Name that you wish to use to refer to this volume. | ||
// +required | ||
// +immutable | ||
// +kubebuilder:validation:Required | ||
Name string `json:"name"` | ||
|
||
// Size for the volume a minimum of 1 and a maximum of your available disk space from your quota specifies the size of the volume in gigabytes | ||
// +required | ||
// +immutable | ||
// +kubebuilder:validation:Required | ||
Size int `json:"size"` | ||
|
||
// NetworkID for the network in which you wish to create the volume. | ||
// +required | ||
// +immutable | ||
// +kubebuilder:validation:Required | ||
NetworkID string `json:"network_id"` | ||
|
||
// ClusterID is the identifier for the cluster to which this volume belongs, if applicable. | ||
// +optional | ||
ClusterID string `json:"cluster_id,omitempty"` | ||
|
||
// InstanceID is the identifier for the instance to which this volume is attached, if applicable. | ||
// +optional | ||
InstanceID string `json:"instance_id,omitempty"` | ||
|
||
// Bootable specifies whether the volume is bootable or not. | ||
// +optional | ||
Bootable bool `json:"bootable,omitempty"` | ||
|
||
// ProviderReference holds configs (region, API key etc.) for the crossplane provider that is being used. | ||
ProviderReference *xpv1.Reference `json:"providerReference"` | ||
} | ||
|
||
// A CivoVolumeStatus represents the observed state of a CivoVolume. | ||
type CivoVolumeStatus struct { | ||
xpv1.ResourceStatus `json:",inline"` | ||
AtProvider *CivoVolumeObservation `json:"atProvider,omitempty"` | ||
} | ||
|
||
// SetManagementPolicies sets up management policies. | ||
func (mg *CivoVolume) SetManagementPolicies(r xpv1.ManagementPolicies) {} | ||
|
||
// GetManagementPolicies gets management policies. | ||
func (mg *CivoVolume) GetManagementPolicies() xpv1.ManagementPolicies { | ||
// Note: Crossplane runtime reconciler should leave handling of | ||
// ManagementPolicies to the provider controller. This is a temporary hack | ||
// until we remove the ManagementPolicy field from the Provider Kubernetes | ||
// Object in favor of the one in the ResourceSpec. | ||
return []xpv1.ManagementAction{xpv1.ManagementActionAll} | ||
} | ||
|
||
// SetPublishConnectionDetailsTo sets up connection details. | ||
func (mg *CivoVolume) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { | ||
mg.Spec.PublishConnectionDetailsTo = r | ||
} | ||
|
||
// GetPublishConnectionDetailsTo gets publish connection details. | ||
func (mg *CivoVolume) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { | ||
return mg.Spec.PublishConnectionDetailsTo | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:resource:shortName="cos" | ||
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.atProvider.status",description="State of the Bucket" | ||
// +kubebuilder:printcolumn:name="Bucket",type="string",JSONPath=".spec.name",description="Name of the Bucket which can be used against S3 API" | ||
// +kubebuilder:printcolumn:name="Size",type="string",JSONPath=".spec.maxSize",description="Size of the Bucket in GB" | ||
|
||
// CivoVolume is the Schema for the CivoVolume API | ||
type CivoVolume struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec CivoVolumeSpec `json:"spec"` | ||
Status CivoVolumeStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// CivoVolumeList contains a list of CivoVolumeList | ||
type CivoVolumeList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []CivoVolume `json:"items"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
Missing instance id in spec
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.
2c14722