-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
f2276ab
commit a731a3d
Showing
8 changed files
with
465 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
Copyright The Karbour 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. | ||
*/ | ||
|
||
// +k8s:openapi-gen=true | ||
// +k8s:deepcopy-gen=package | ||
// +k8s:conversion-gen=github.com/KusionStack/karbour/pkg/kubernetes/apis/cluster | ||
// +k8s:defaulter-gen=TypeMeta | ||
// +groupName=cluster.karbour.com | ||
|
||
// Package v1beta1 Package v1beta1 is the v1beta1 version of the API. | ||
package v1beta1 // import "github.com/KusionStack/karbour/pkg/kubernetes/apis/cluster/v1beta1" |
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,63 @@ | ||
/* | ||
Copyright The Karbour 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 v1beta1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// GroupName holds the API group name. | ||
const GroupName = "cluster.karbour.com" | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} | ||
|
||
var ( | ||
// SchemeBuilder allows to add this group to a scheme. | ||
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. | ||
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. | ||
SchemeBuilder runtime.SchemeBuilder | ||
localSchemeBuilder = &SchemeBuilder | ||
|
||
// AddToScheme adds this group to a scheme. | ||
AddToScheme = localSchemeBuilder.AddToScheme | ||
) | ||
|
||
func init() { | ||
// We only register manually written functions here. The registration of the | ||
// generated functions takes place in the generated files. The separation | ||
// makes the code compile even when the generated files are missing. | ||
localSchemeBuilder.Register(addKnownTypes) | ||
} | ||
|
||
// Adds the list of known types to the given scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&Cluster{}, | ||
&ClusterList{}, | ||
&ClusterProxyOptions{}, | ||
) | ||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} | ||
|
||
// Resource takes an unqualified resource and returns a Group qualified GroupResource | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} |
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,101 @@ | ||
/* | ||
Copyright The Karbour 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 v1beta1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type CredentialType string | ||
|
||
const ( | ||
CredentialTypeServiceAccountToken CredentialType = "ServiceAccountToken" | ||
CredentialTypeX509Certificate CredentialType = "X509Certificate" | ||
) | ||
|
||
// +genclient | ||
// +genclient:nonNamespaced | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// Cluster is an extension type to access a cluster | ||
type Cluster struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` //nolint:tagliatelle | ||
|
||
Spec ClusterSpec `json:"spec"` | ||
// +optional | ||
Status ClusterStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// ClusterList is a list of Cluster objects. | ||
type ClusterList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` //nolint:tagliatelle | ||
|
||
Items []Cluster `json:"items"` | ||
} | ||
|
||
type ClusterSpec struct { | ||
Provider string `json:"provider"` | ||
Access ClusterAccess `json:"access"` | ||
// +optional | ||
Description string `json:"description"` | ||
DisplayName string `json:"displayName"` | ||
Finalized *bool `json:"finalized,omitempty"` | ||
} | ||
|
||
type ClusterStatus struct { | ||
// +optional | ||
Healthy bool `json:"healthy,omitempty"` | ||
} | ||
|
||
type ClusterAccess struct { | ||
Endpoint string `json:"endpoint"` | ||
// +optional | ||
CABundle []byte `json:"caBundle,omitempty"` | ||
// +optional | ||
Insecure *bool `json:"insecure,omitempty"` | ||
// +optional | ||
Credential *ClusterAccessCredential `json:"credential,omitempty"` | ||
} | ||
|
||
type ClusterAccessCredential struct { | ||
Type CredentialType `json:"type"` | ||
// +optional | ||
ServiceAccountToken string `json:"serviceAccountToken,omitempty"` | ||
// +optional | ||
X509 *X509 `json:"x509,omitempty"` | ||
} | ||
|
||
type X509 struct { | ||
Certificate []byte `json:"certificate"` | ||
PrivateKey []byte `json:"privateKey"` | ||
} | ||
|
||
// +k8s:conversion-gen:explicit-from=net/url.Values | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
type ClusterProxyOptions struct { | ||
metav1.TypeMeta `json:",inline"` | ||
|
||
// Path is the target api path of the proxy request. | ||
// e.g. "/healthz", "/api/v1" | ||
// +optional | ||
Path string `json:"path,omitempty"` | ||
} |
Oops, something went wrong.