-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: chrischdi <[email protected]> Co-authored-by: sbueringer <[email protected]>
- Loading branch information
1 parent
f07e0d7
commit cff9b2d
Showing
16 changed files
with
1,157 additions
and
7 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,29 @@ | ||
/* | ||
Copyright 2022 The Kubernetes 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 | ||
|
||
// ResponseStatus represents the status of the hook response. | ||
// +enum | ||
type ResponseStatus string | ||
|
||
const ( | ||
// ResponseStatusSuccess represents the success response. | ||
ResponseStatusSuccess ResponseStatus = "Success" | ||
|
||
// ResponseStatusFailure represents a failure response. | ||
ResponseStatusFailure ResponseStatus = "Failure" | ||
) |
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,92 @@ | ||
/* | ||
Copyright 2022 The Kubernetes 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" | ||
|
||
"sigs.k8s.io/cluster-api/internal/runtime/catalog" | ||
) | ||
|
||
// DiscoveryRequest represents the object of a discovery request. | ||
// +kubebuilder:object:root=true | ||
type DiscoveryRequest struct { | ||
metav1.TypeMeta `json:",inline"` | ||
} | ||
|
||
// DiscoveryResponse represents the object received as a discovery response. | ||
// +kubebuilder:object:root=true | ||
type DiscoveryResponse struct { | ||
metav1.TypeMeta `json:",inline"` | ||
|
||
// Status of the call. One of "Success" or "Failure". | ||
Status ResponseStatus `json:"status"` | ||
|
||
// A human-readable description of the status of the call. | ||
Message string `json:"message"` | ||
|
||
// Handlers defines the current ExtensionHandlers supported by an Extension. | ||
Handlers []ExtensionHandler `json:"handlers"` | ||
} | ||
|
||
// ExtensionHandler represents the discovery information of the extension which includes | ||
// the hook it supports. | ||
type ExtensionHandler struct { | ||
// Name is the name of the ExtensionHandler. | ||
Name string `json:"name"` | ||
|
||
// RequestHook defines the versioned runtime hook which this ExtensionHandler serves. | ||
RequestHook GroupVersionHook `json:"requestHook"` | ||
|
||
// TimeoutSeconds defines the timeout duration for client calls to the ExtensionHandler. | ||
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"` | ||
|
||
// FailurePolicy defines how failures in calls to the ExtensionHandler should be handled by a client. | ||
FailurePolicy *FailurePolicy `json:"failurePolicy,omitempty"` | ||
} | ||
|
||
// GroupVersionHook defines the runtime hook when the ExtensionHandler is called. | ||
type GroupVersionHook struct { | ||
// APIVersion is the Version of the Hook | ||
APIVersion string `json:"apiVersion"` | ||
|
||
// Hook is the name of the hook | ||
Hook string `json:"hook"` | ||
} | ||
|
||
// FailurePolicy is the type of a extension failure policy. | ||
type FailurePolicy string | ||
|
||
const ( | ||
// FailurePolicyIgnore means that an error calling the extension is ignored. | ||
FailurePolicyIgnore FailurePolicy = "Ignore" | ||
|
||
// FailurePolicyFail means that an error calling the extension is not ignored. | ||
FailurePolicyFail FailurePolicy = "Fail" | ||
) | ||
|
||
// Discovery represents the discovery hook. | ||
func Discovery(*DiscoveryRequest, *DiscoveryResponse) {} | ||
|
||
func init() { | ||
catalogBuilder.RegisterHook(Discovery, &catalog.HookMeta{ | ||
Tags: []string{"Discovery"}, | ||
Summary: "Discovery endpoint", | ||
Description: "Discovery endpoint discovers the supported hooks of a RuntimeExtension", | ||
Singleton: true, | ||
}) | ||
} |
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,20 @@ | ||
/* | ||
Copyright 2022 The Kubernetes 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 RuntimeHooks. | ||
// +kubebuilder:object:generate=true | ||
// +k8s:openapi-gen=true | ||
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,37 @@ | ||
/* | ||
Copyright 2022 The Kubernetes 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 ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
|
||
"sigs.k8s.io/cluster-api/internal/runtime/catalog" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version identifying RuntimeHooks defined in this package | ||
// and their request and response types. | ||
GroupVersion = schema.GroupVersion{Group: "hooks.runtime.cluster.x-k8s.io", Version: "v1alpha1"} | ||
|
||
// catalogBuilder is used to add RuntimeHooks and their request and response types | ||
// to a Catalog. | ||
catalogBuilder = &catalog.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToCatalog adds RuntimeHooks defined in this package and their request and | ||
// response types to a catalog. | ||
AddToCatalog = catalogBuilder.AddToCatalog | ||
) |
122 changes: 122 additions & 0 deletions
122
exp/runtime/hooks/api/v1alpha1/zz_generated.deepcopy.go
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.