kuberc: add v1beta1 types
Signed-off-by: Maciej Szulik <soltysh@gmail.com> Kubernetes-commit: 39195f9a463cce6b3ce4e3d9f648c2915407596d
This commit is contained in:
parent
6096dfa3cf
commit
2be4847754
|
@ -23,10 +23,12 @@ import (
|
|||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/kubectl/pkg/config"
|
||||
"k8s.io/kubectl/pkg/config/v1alpha1"
|
||||
"k8s.io/kubectl/pkg/config/v1beta1"
|
||||
)
|
||||
|
||||
// Install registers the API group and adds types to a scheme
|
||||
func Install(scheme *runtime.Scheme) {
|
||||
utilruntime.Must(config.AddToScheme(scheme))
|
||||
utilruntime.Must(v1beta1.AddToScheme(scheme))
|
||||
utilruntime.Must(v1alpha1.AddToScheme(scheme))
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
Copyright 2025 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.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:openapi-gen=true
|
||||
// +groupName=kubectl.config.k8s.io
|
||||
// +k8s:conversion-gen=k8s.io/kubectl/pkg/config
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
|
||||
package v1beta1 // Package v1beta1 import "k8s.io/kubectl/pkg/config/v1beta1"
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Copyright 2025 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 v1beta1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
// GroupName is the group name used in this package
|
||||
const GroupName = "kubectl.config.k8s.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}
|
||||
|
||||
var (
|
||||
SchemeBuilder runtime.SchemeBuilder
|
||||
localSchemeBuilder = &SchemeBuilder
|
||||
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)
|
||||
}
|
||||
|
||||
// addKnownTypes registers known types to the given scheme
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&Preference{},
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Copyright 2025 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 v1beta1
|
||||
|
||||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// Preference stores elements of KubeRC configuration file
|
||||
type Preference struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// defaults allow changing default option values of commands.
|
||||
// This is especially useful, when user doesn't want to explicitly
|
||||
// set options each time.
|
||||
// +listType=atomic
|
||||
Defaults []CommandDefaults `json:"defaults"`
|
||||
|
||||
// aliases allow defining command aliases for existing kubectl commands, with optional default option values.
|
||||
// If the alias name collides with a built-in command, built-in command always takes precedence.
|
||||
// Option overrides defined in the defaults section do NOT apply to aliases for the same command.
|
||||
// kubectl [ALIAS NAME] [USER_OPTIONS] [USER_EXPLICIT_ARGS] expands to
|
||||
// kubectl [COMMAND] # built-in command alias points to
|
||||
// [KUBERC_PREPEND_ARGS]
|
||||
// [USER_OPTIONS]
|
||||
// [KUBERC_OPTIONS] # rest of the options that are not passed by user in [USER_OPTIONS]
|
||||
// [USER_EXPLICIT_ARGS]
|
||||
// [KUBERC_APPEND_ARGS]
|
||||
// e.g.
|
||||
// - name: runx
|
||||
// command: run
|
||||
// options:
|
||||
// - name: image
|
||||
// default: nginx
|
||||
// appendArgs:
|
||||
// - --
|
||||
// - custom-arg1
|
||||
// For example, if user invokes "kubectl runx test-pod" command,
|
||||
// this will be expanded to "kubectl run --image=nginx test-pod -- custom-arg1"
|
||||
// - name: getn
|
||||
// command: get
|
||||
// options:
|
||||
// - name: output
|
||||
// default: wide
|
||||
// prependArgs:
|
||||
// - node
|
||||
// "kubectl getn control-plane-1" expands to "kubectl get node control-plane-1 --output=wide"
|
||||
// "kubectl getn control-plane-1 --output=json" expands to "kubectl get node --output=json control-plane-1"
|
||||
// +listType=atomic
|
||||
Aliases []AliasOverride `json:"aliases"`
|
||||
}
|
||||
|
||||
// AliasOverride stores the alias definitions.
|
||||
type AliasOverride struct {
|
||||
// name is the name of alias that can only include alphabetical characters
|
||||
// If the alias name conflicts with the built-in command,
|
||||
// built-in command will be used.
|
||||
Name string `json:"name"`
|
||||
// command is the single or set of commands to execute, such as "set env" or "create"
|
||||
Command string `json:"command"`
|
||||
// prependArgs stores the arguments such as resource names, etc.
|
||||
// These arguments are inserted after the alias name.
|
||||
// +listType=atomic
|
||||
PrependArgs []string `json:"prependArgs,omitempty"`
|
||||
// appendArgs stores the arguments such as resource names, etc.
|
||||
// These arguments are appended to the USER_ARGS.
|
||||
// +listType=atomic
|
||||
AppendArgs []string `json:"appendArgs,omitempty"`
|
||||
// options is allocated to store the option definitions of alias.
|
||||
// options only modify the default value of the option and if
|
||||
// user explicitly passes a value, explicit one is used.
|
||||
// +listType=atomic
|
||||
Options []CommandOptionDefault `json:"options,omitempty"`
|
||||
}
|
||||
|
||||
// CommandDefaults stores the commands and their associated option's
|
||||
// default values.
|
||||
type CommandDefaults struct {
|
||||
// command refers to a command whose option's default value is changed.
|
||||
Command string `json:"command"`
|
||||
// options is a list of options storing different default values.
|
||||
// +listType=atomic
|
||||
Options []CommandOptionDefault `json:"options"`
|
||||
}
|
||||
|
||||
// CommandOptionDefault stores the name and the specified default
|
||||
// value of an option.
|
||||
type CommandOptionDefault struct {
|
||||
// Option name (long form, without dashes).
|
||||
Name string `json:"name"`
|
||||
|
||||
// In a string format of a default value. It will be parsed
|
||||
// by kubectl to the compatible value of the option.
|
||||
Default string `json:"default"`
|
||||
}
|
Loading…
Reference in New Issue