-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create V1 API * Update tests to v1 * Update project file * Add v1 sample to CSV * use kubectl create
- Loading branch information
Showing
188 changed files
with
21,346 additions
and
721 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
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
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,36 @@ | ||
/* | ||
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 v1 contains API Schema definitions for the rc.app.stacks v1beta2 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=rc.app.stacks | ||
package v1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "rc.app.stacks", Version: "v1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
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,58 @@ | ||
package v1 | ||
|
||
import ( | ||
"time" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// OperationStatusCondition ... | ||
// +k8s:openapi-gen=true | ||
type OperationStatusCondition struct { | ||
LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` | ||
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` | ||
Reason string `json:"reason,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
Status corev1.ConditionStatus `json:"status,omitempty"` | ||
Type OperationStatusConditionType `json:"type,omitempty"` | ||
} | ||
|
||
// OperationStatusConditionType ... | ||
type OperationStatusConditionType string | ||
|
||
const ( | ||
// OperationStatusConditionTypeStarted indicates whether operation has been started | ||
OperationStatusConditionTypeStarted OperationStatusConditionType = "Started" | ||
// OperationStatusConditionTypeCompleted indicates whether operation has been completed | ||
OperationStatusConditionTypeCompleted OperationStatusConditionType = "Completed" | ||
) | ||
|
||
// GetOperationCondition returns condition of specific type | ||
func GetOperationCondition(c []OperationStatusCondition, t OperationStatusConditionType) *OperationStatusCondition { | ||
for i := range c { | ||
if c[i].Type == t { | ||
return &c[i] | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// SetOperationCondition set condition of specific type or appends if not present | ||
func SetOperationCondition(c []OperationStatusCondition, oc OperationStatusCondition) []OperationStatusCondition { | ||
condition := GetOperationCondition(c, oc.Type) | ||
|
||
if condition != nil { | ||
if condition.Status != oc.Status { | ||
condition.LastTransitionTime = &metav1.Time{Time: time.Now()} | ||
} | ||
condition.Status = oc.Status | ||
condition.LastUpdateTime = metav1.Time{Time: time.Now()} | ||
condition.Reason = oc.Reason | ||
condition.Message = oc.Message | ||
return c | ||
} | ||
oc.LastUpdateTime = metav1.Time{Time: time.Now()} | ||
c = append(c, oc) | ||
return c | ||
} |
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
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 v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// Defines the desired state of RuntimeOperation | ||
type RuntimeOperationSpec struct { | ||
// Name of the Pod to perform runtime operation on. Pod must be from the same namespace as the RuntimeOperation instance. | ||
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Pod Name",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text" | ||
PodName string `json:"podName"` | ||
|
||
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Container Name",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text" | ||
ContainerName string `json:"containerName,omitempty"` | ||
|
||
// Command to execute. Not executed within a shell. | ||
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Command",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text" | ||
Command []string `json:"command"` | ||
} | ||
|
||
// Defines the observed state of RuntimeOperation. | ||
type RuntimeOperationStatus struct { | ||
// +listType=atomic | ||
Conditions []OperationStatusCondition `json:"conditions,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:storageversion | ||
//+operator-sdk:csv:customresourcedefinitions:displayName="RuntimeOperation" | ||
|
||
// Day-2 operation to execute on an instance of runtime component | ||
type RuntimeOperation struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec RuntimeOperationSpec `json:"spec,omitempty"` | ||
Status RuntimeOperationStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// RuntimeOperationList contains a list of RuntimeOperation. | ||
type RuntimeOperationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []RuntimeOperation `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&RuntimeOperation{}, &RuntimeOperationList{}) | ||
} |
Oops, something went wrong.