-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add TestRun CRD with shared logic with K6 CRD
- Loading branch information
Showing
37 changed files
with
5,903 additions
and
608 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
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,76 @@ | ||
/* | ||
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" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:printcolumn:name="Stage",type="string",JSONPath=".status.stage",description="Stage" | ||
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" | ||
//+kubebuilder:printcolumn:name="TestRunID",type="string",JSONPath=".status.testRunId" | ||
|
||
// TestRun is the Schema for the testruns API | ||
type TestRun struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec TestRunSpec `json:"spec,omitempty"` | ||
Status TestRunStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// TestRunList contains a list of TestRun | ||
type TestRunList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []TestRun `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&TestRun{}, &TestRunList{}) | ||
} | ||
|
||
// TestRunI implementation for TestRun | ||
func (k6 *TestRun) GetStatus() *TestRunStatus { | ||
return &k6.Status | ||
} | ||
|
||
func (k6 *TestRun) GetSpec() *TestRunSpec { | ||
return &k6.Spec | ||
} | ||
|
||
func (k6 *TestRun) NamespacedName() types.NamespacedName { | ||
return types.NamespacedName{Namespace: k6.Namespace, Name: k6.Name} | ||
} | ||
|
||
// TestRunI implementation for TestRun | ||
func (k6 *K6) GetStatus() *TestRunStatus { | ||
return &k6.Status | ||
} | ||
|
||
func (k6 *K6) GetSpec() *TestRunSpec { | ||
return &k6.Spec | ||
} | ||
|
||
func (k6 *K6) NamespacedName() types.NamespacedName { | ||
return types.NamespacedName{Namespace: k6.Namespace, Name: k6.Name} | ||
} |
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,22 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
runtime "k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// TestRunI is meant as abstraction over both TestRun and K6 while | ||
// both types are supported. Consider removing it, when K6 is deprecated. | ||
// +kubebuilder:object:generate=false | ||
|
||
type TestRunI interface { | ||
runtime.Object | ||
metav1.Object | ||
client.Object | ||
|
||
GetStatus() *TestRunStatus | ||
GetSpec() *TestRunSpec | ||
NamespacedName() types.NamespacedName | ||
} |
Oops, something went wrong.