-
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]>
- Loading branch information
Showing
9 changed files
with
729 additions
and
0 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,27 @@ | ||
/* | ||
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 ResponseStatus = "Success" | ||
|
||
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,86 @@ | ||
/* | ||
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" | ||
) | ||
|
||
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 causes the admission to fail. | ||
FailurePolicyFail FailurePolicy = "Fail" | ||
) | ||
|
||
type Hook struct { | ||
// APIVersion is the Version of the Hook | ||
APIVersion string `json:"apiVersion"` | ||
|
||
// Name is the name of the hook | ||
Name string `json:"name"` | ||
} | ||
|
||
type RuntimeExtension struct { | ||
// Name is the name of the RuntimeExtension | ||
Name string `json:"name"` | ||
|
||
// Hook defines the specific runtime event for which this RuntimeExtension calls. | ||
Hook Hook `json:"hook"` | ||
|
||
// TimeoutSeconds defines the timeout duration for client calls to the Hook | ||
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"` | ||
|
||
// FailurePolicy defines how failures in calls to the Hook should be handled by a client. | ||
FailurePolicy *FailurePolicy `json:"failurePolicy,omitempty"` | ||
} | ||
|
||
// DiscoveryHookRequest foo bar baz. | ||
// +kubebuilder:object:root=true | ||
type DiscoveryHookRequest struct { | ||
metav1.TypeMeta `json:",inline"` | ||
} | ||
|
||
// DiscoveryHookResponse foo bar baz. | ||
// +kubebuilder:object:root=true | ||
type DiscoveryHookResponse 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"` | ||
|
||
Extensions []RuntimeExtension `json:"extensions"` | ||
} | ||
|
||
func Discovery(*DiscoveryHookRequest, *DiscoveryHookResponse) {} | ||
|
||
func init() { | ||
catalogBuilder.RegisterHook(Discovery, &catalog.HookMeta{ | ||
Tags: []string{"Discovery"}, | ||
Summary: "Discovery endpoint", | ||
Description: "Discovery endpoint discovers the supported hook of a runtime extension", | ||
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,21 @@ | ||
/* | ||
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 idl implementation for extension1. | ||
// +k8s:conversion-gen=sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha3 | ||
// +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,43 @@ | ||
/* | ||
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 rpc services 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 rpc services and their request and response types | ||
// to a Catalog. | ||
catalogBuilder = &catalog.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToCatalog adds rpc services defined in this package and their request and | ||
// response types to a catalog. | ||
AddToCatalog = catalogBuilder.AddToCatalog | ||
|
||
// localSchemeBuilder provide access to the SchemeBuilder used for managing rpc | ||
// method's request and response types defined in this package. | ||
// NOTE: this object is required to allow registration of automatically generated | ||
// conversions func. | ||
localSchemeBuilder = catalogBuilder | ||
) |
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.
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.