-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
882 additions
and
11 deletions.
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 |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"time" | ||
|
||
console "github.com/pluralsh/console/go/client" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/meta" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func init() { | ||
SchemeBuilder.Register(&UpgradeInsights{}, &UpgradeInsightsList{}) | ||
} | ||
|
||
const ( | ||
defaultReconcileInterval = 10 * time.Minute | ||
) | ||
|
||
// UpgradeInsightsList contains a list of UpgradeInsights | ||
// +kubebuilder:object:root=true | ||
type UpgradeInsightsList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []UpgradeInsights `json:"items"` | ||
} | ||
|
||
// UpgradeInsights is the Schema for the UpgradeInsights API | ||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:scope=Cluster | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:name="ID",type="string",JSONPath=".status.id",description="ID of the UpgradeInsights in the Console API." | ||
type UpgradeInsights struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec UpgradeInsightsSpec `json:"spec,omitempty"` | ||
Status Status `json:"status,omitempty"` | ||
} | ||
|
||
func (in *UpgradeInsights) SetCondition(condition metav1.Condition) { | ||
meta.SetStatusCondition(&in.Status.Conditions, condition) | ||
} | ||
|
||
type UpgradeInsightsDistro string | ||
|
||
type UpgradeInsightsSpec struct { | ||
// Distro defines which provider API should be used to fetch latest upgrade insights. | ||
// If not provided, we get the distro from the Plural API cluster tied to this operator deploy token. | ||
// +kubebuilder:validation:Enum=EKS | ||
// +kubebuilder:validation:Optional | ||
Distro *console.ClusterDistro `json:"distro,omitempty"` | ||
|
||
// ClusterName is your cloud provider cluster identifier (usually name) that is used | ||
// to fetch latest upgrade insights information from the cloud provider API. | ||
// If not provided, we get the cluster name from the Plural API cluster tied to this | ||
// operator deploy token and assume that it is the same as the cluster name in your cloud provider. | ||
// +kubebuilder:validation:Optional | ||
ClusterName *string `json:"clusterName,omitempty"` | ||
|
||
// Interval defines how often should the upgrade insights information be fetched. | ||
// +kubebuilder:default="10m" | ||
// +kubebuilder:validation:Optional | ||
Interval *string `json:"interval,omitempty"` | ||
|
||
// Credentials allow overriding default provider credentials bound to the operator. | ||
// +kubebuilder:validation:Optional | ||
Credentials *ProviderCredentials `json:"credentials,omitempty"` | ||
} | ||
|
||
func (in *UpgradeInsightsSpec) GetDistro(defaultDistro *console.ClusterDistro) *console.ClusterDistro { | ||
if in.Distro != nil { | ||
return in.Distro | ||
} | ||
|
||
return defaultDistro | ||
} | ||
func (in *UpgradeInsightsSpec) GetClusterName(defaultClusterName string) string { | ||
if in.ClusterName != nil { | ||
return *in.ClusterName | ||
} | ||
|
||
return defaultClusterName | ||
} | ||
|
||
func (in *UpgradeInsightsSpec) GetInterval() time.Duration { | ||
if in.Interval == nil { | ||
return defaultReconcileInterval | ||
} | ||
|
||
interval, err := time.ParseDuration(*in.Interval) | ||
if err != nil { | ||
return defaultReconcileInterval | ||
} | ||
|
||
return interval | ||
} | ||
|
||
type ProviderCredentials struct { | ||
// AWS defines attributes required to auth with AWS API. | ||
// +kubebuilder:validation:Optional | ||
AWS *AWSProviderCredentials `json:"aws,omitempty"` | ||
} | ||
|
||
type AWSProviderCredentials struct { | ||
// Region ... | ||
// +kubebuilder:validation:Required | ||
Region string `json:"region"` | ||
|
||
// AccessKeyID ... | ||
// +kubebuilder:validation:Required | ||
AccessKeyID string `json:"accessKeyID"` | ||
|
||
// SecretAccessKeyRef ... | ||
// +kubebuilder:validation:Required | ||
SecretAccessKeyRef corev1.SecretReference `json:"secretAccessKeyRef"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.