diff --git a/cmd/kubeadm/app/apis/output/v1alpha2/doc.go b/cmd/kubeadm/app/apis/output/v1alpha2/doc.go new file mode 100644 index 00000000000..4dacf725f7e --- /dev/null +++ b/cmd/kubeadm/app/apis/output/v1alpha2/doc.go @@ -0,0 +1,26 @@ +/* +Copyright 2021 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. +*/ + +// +groupName=output.kubeadm.k8s.io +// +k8s:deepcopy-gen=package +// +k8s:conversion-gen=k8s.io/kubernetes/cmd/kubeadm/app/apis/output + +// Package v1alpha2 defines the v1alpha2 version of the kubeadm data structures +// related to structured output +// The purpose of the kubeadm structured output is to have a well +// defined versioned output format that other software that uses +// kubeadm for cluster deployments can use and rely on. +package v1alpha2 // import "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/v1alpha2" diff --git a/cmd/kubeadm/app/apis/output/v1alpha2/register.go b/cmd/kubeadm/app/apis/output/v1alpha2/register.go new file mode 100644 index 00000000000..f6004c57165 --- /dev/null +++ b/cmd/kubeadm/app/apis/output/v1alpha2/register.go @@ -0,0 +1,67 @@ +/* +Copyright 2021 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "output.kubeadm.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"} + +var ( + // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + + // SchemeBuilder points to a list of functions added to Scheme. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + // AddToScheme applies all the stored functions to the 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) +} + +// Kind takes an unqualified kind and returns a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &BootstrapToken{}, + &Images{}, + &UpgradePlan{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/cmd/kubeadm/app/apis/output/v1alpha2/types.go b/cmd/kubeadm/app/apis/output/v1alpha2/types.go new file mode 100644 index 00000000000..71bc2fa93be --- /dev/null +++ b/cmd/kubeadm/app/apis/output/v1alpha2/types.go @@ -0,0 +1,80 @@ +/* +Copyright 2021 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + bootstraptokenv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/bootstraptoken/v1" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BootstrapToken represents information for the bootstrap token output produced by kubeadm +type BootstrapToken struct { + metav1.TypeMeta `json:",inline"` + + bootstraptokenv1.BootstrapToken +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Images represents information for the output produced by 'kubeadm config images list' +type Images struct { + metav1.TypeMeta `json:",inline"` + + Images []string `json:"images"` +} + +// ComponentUpgradePlan represents information about upgrade plan for one component +type ComponentUpgradePlan struct { + Name string `json:"name"` + CurrentVersion string `json:"currentVersion"` + NewVersion string `json:"newVersion"` +} + +// ComponentConfigVersionState describes the current and desired version of a component config +type ComponentConfigVersionState struct { + // Group points to the Kubernetes API group that covers the config + Group string `json:"group"` + + // CurrentVersion is the currently active component config version + // NOTE: This can be empty in case the config was not found on the cluster or it was unsupported + // kubeadm generated version + CurrentVersion string `json:"currentVersion"` + + // PreferredVersion is the component config version that is currently preferred by kubeadm for use. + // NOTE: As of today, this is the only version supported by kubeadm. + PreferredVersion string `json:"preferredVersion"` + + // ManualUpgradeRequired indicates if users need to manually upgrade their component config versions. This happens if + // the CurrentVersion of the config is user supplied (or modified) and no longer supported. Users should upgrade + // their component configs to PreferredVersion or any other supported component config version. + ManualUpgradeRequired bool `json:"manualUpgradeRequired"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// UpgradePlan represents information about upgrade plan for the output +// produced by 'kubeadm upgrade plan' +type UpgradePlan struct { + metav1.TypeMeta + + Components []ComponentUpgradePlan `json:"components"` + + ConfigVersions []ComponentConfigVersionState `json:"configVersions"` +} diff --git a/cmd/kubeadm/app/apis/output/v1alpha2/zz_generated.conversion.go b/cmd/kubeadm/app/apis/output/v1alpha2/zz_generated.conversion.go new file mode 100644 index 00000000000..5893ba6c309 --- /dev/null +++ b/cmd/kubeadm/app/apis/output/v1alpha2/zz_generated.conversion.go @@ -0,0 +1,202 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by conversion-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + unsafe "unsafe" + + conversion "k8s.io/apimachinery/pkg/conversion" + runtime "k8s.io/apimachinery/pkg/runtime" + output "k8s.io/kubernetes/cmd/kubeadm/app/apis/output" +) + +func init() { + localSchemeBuilder.Register(RegisterConversions) +} + +// RegisterConversions adds conversion functions to the given scheme. +// Public to allow building arbitrary schemes. +func RegisterConversions(s *runtime.Scheme) error { + if err := s.AddGeneratedConversionFunc((*BootstrapToken)(nil), (*output.BootstrapToken)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha2_BootstrapToken_To_output_BootstrapToken(a.(*BootstrapToken), b.(*output.BootstrapToken), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*output.BootstrapToken)(nil), (*BootstrapToken)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_output_BootstrapToken_To_v1alpha2_BootstrapToken(a.(*output.BootstrapToken), b.(*BootstrapToken), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ComponentConfigVersionState)(nil), (*output.ComponentConfigVersionState)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha2_ComponentConfigVersionState_To_output_ComponentConfigVersionState(a.(*ComponentConfigVersionState), b.(*output.ComponentConfigVersionState), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*output.ComponentConfigVersionState)(nil), (*ComponentConfigVersionState)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_output_ComponentConfigVersionState_To_v1alpha2_ComponentConfigVersionState(a.(*output.ComponentConfigVersionState), b.(*ComponentConfigVersionState), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*ComponentUpgradePlan)(nil), (*output.ComponentUpgradePlan)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha2_ComponentUpgradePlan_To_output_ComponentUpgradePlan(a.(*ComponentUpgradePlan), b.(*output.ComponentUpgradePlan), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*output.ComponentUpgradePlan)(nil), (*ComponentUpgradePlan)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_output_ComponentUpgradePlan_To_v1alpha2_ComponentUpgradePlan(a.(*output.ComponentUpgradePlan), b.(*ComponentUpgradePlan), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*Images)(nil), (*output.Images)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha2_Images_To_output_Images(a.(*Images), b.(*output.Images), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*output.Images)(nil), (*Images)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_output_Images_To_v1alpha2_Images(a.(*output.Images), b.(*Images), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*UpgradePlan)(nil), (*output.UpgradePlan)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha2_UpgradePlan_To_output_UpgradePlan(a.(*UpgradePlan), b.(*output.UpgradePlan), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*output.UpgradePlan)(nil), (*UpgradePlan)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_output_UpgradePlan_To_v1alpha2_UpgradePlan(a.(*output.UpgradePlan), b.(*UpgradePlan), scope) + }); err != nil { + return err + } + return nil +} + +func autoConvert_v1alpha2_BootstrapToken_To_output_BootstrapToken(in *BootstrapToken, out *output.BootstrapToken, s conversion.Scope) error { + out.BootstrapToken = in.BootstrapToken + return nil +} + +// Convert_v1alpha2_BootstrapToken_To_output_BootstrapToken is an autogenerated conversion function. +func Convert_v1alpha2_BootstrapToken_To_output_BootstrapToken(in *BootstrapToken, out *output.BootstrapToken, s conversion.Scope) error { + return autoConvert_v1alpha2_BootstrapToken_To_output_BootstrapToken(in, out, s) +} + +func autoConvert_output_BootstrapToken_To_v1alpha2_BootstrapToken(in *output.BootstrapToken, out *BootstrapToken, s conversion.Scope) error { + out.BootstrapToken = in.BootstrapToken + return nil +} + +// Convert_output_BootstrapToken_To_v1alpha2_BootstrapToken is an autogenerated conversion function. +func Convert_output_BootstrapToken_To_v1alpha2_BootstrapToken(in *output.BootstrapToken, out *BootstrapToken, s conversion.Scope) error { + return autoConvert_output_BootstrapToken_To_v1alpha2_BootstrapToken(in, out, s) +} + +func autoConvert_v1alpha2_ComponentConfigVersionState_To_output_ComponentConfigVersionState(in *ComponentConfigVersionState, out *output.ComponentConfigVersionState, s conversion.Scope) error { + out.Group = in.Group + out.CurrentVersion = in.CurrentVersion + out.PreferredVersion = in.PreferredVersion + out.ManualUpgradeRequired = in.ManualUpgradeRequired + return nil +} + +// Convert_v1alpha2_ComponentConfigVersionState_To_output_ComponentConfigVersionState is an autogenerated conversion function. +func Convert_v1alpha2_ComponentConfigVersionState_To_output_ComponentConfigVersionState(in *ComponentConfigVersionState, out *output.ComponentConfigVersionState, s conversion.Scope) error { + return autoConvert_v1alpha2_ComponentConfigVersionState_To_output_ComponentConfigVersionState(in, out, s) +} + +func autoConvert_output_ComponentConfigVersionState_To_v1alpha2_ComponentConfigVersionState(in *output.ComponentConfigVersionState, out *ComponentConfigVersionState, s conversion.Scope) error { + out.Group = in.Group + out.CurrentVersion = in.CurrentVersion + out.PreferredVersion = in.PreferredVersion + out.ManualUpgradeRequired = in.ManualUpgradeRequired + return nil +} + +// Convert_output_ComponentConfigVersionState_To_v1alpha2_ComponentConfigVersionState is an autogenerated conversion function. +func Convert_output_ComponentConfigVersionState_To_v1alpha2_ComponentConfigVersionState(in *output.ComponentConfigVersionState, out *ComponentConfigVersionState, s conversion.Scope) error { + return autoConvert_output_ComponentConfigVersionState_To_v1alpha2_ComponentConfigVersionState(in, out, s) +} + +func autoConvert_v1alpha2_ComponentUpgradePlan_To_output_ComponentUpgradePlan(in *ComponentUpgradePlan, out *output.ComponentUpgradePlan, s conversion.Scope) error { + out.Name = in.Name + out.CurrentVersion = in.CurrentVersion + out.NewVersion = in.NewVersion + return nil +} + +// Convert_v1alpha2_ComponentUpgradePlan_To_output_ComponentUpgradePlan is an autogenerated conversion function. +func Convert_v1alpha2_ComponentUpgradePlan_To_output_ComponentUpgradePlan(in *ComponentUpgradePlan, out *output.ComponentUpgradePlan, s conversion.Scope) error { + return autoConvert_v1alpha2_ComponentUpgradePlan_To_output_ComponentUpgradePlan(in, out, s) +} + +func autoConvert_output_ComponentUpgradePlan_To_v1alpha2_ComponentUpgradePlan(in *output.ComponentUpgradePlan, out *ComponentUpgradePlan, s conversion.Scope) error { + out.Name = in.Name + out.CurrentVersion = in.CurrentVersion + out.NewVersion = in.NewVersion + return nil +} + +// Convert_output_ComponentUpgradePlan_To_v1alpha2_ComponentUpgradePlan is an autogenerated conversion function. +func Convert_output_ComponentUpgradePlan_To_v1alpha2_ComponentUpgradePlan(in *output.ComponentUpgradePlan, out *ComponentUpgradePlan, s conversion.Scope) error { + return autoConvert_output_ComponentUpgradePlan_To_v1alpha2_ComponentUpgradePlan(in, out, s) +} + +func autoConvert_v1alpha2_Images_To_output_Images(in *Images, out *output.Images, s conversion.Scope) error { + out.Images = *(*[]string)(unsafe.Pointer(&in.Images)) + return nil +} + +// Convert_v1alpha2_Images_To_output_Images is an autogenerated conversion function. +func Convert_v1alpha2_Images_To_output_Images(in *Images, out *output.Images, s conversion.Scope) error { + return autoConvert_v1alpha2_Images_To_output_Images(in, out, s) +} + +func autoConvert_output_Images_To_v1alpha2_Images(in *output.Images, out *Images, s conversion.Scope) error { + out.Images = *(*[]string)(unsafe.Pointer(&in.Images)) + return nil +} + +// Convert_output_Images_To_v1alpha2_Images is an autogenerated conversion function. +func Convert_output_Images_To_v1alpha2_Images(in *output.Images, out *Images, s conversion.Scope) error { + return autoConvert_output_Images_To_v1alpha2_Images(in, out, s) +} + +func autoConvert_v1alpha2_UpgradePlan_To_output_UpgradePlan(in *UpgradePlan, out *output.UpgradePlan, s conversion.Scope) error { + out.Components = *(*[]output.ComponentUpgradePlan)(unsafe.Pointer(&in.Components)) + out.ConfigVersions = *(*[]output.ComponentConfigVersionState)(unsafe.Pointer(&in.ConfigVersions)) + return nil +} + +// Convert_v1alpha2_UpgradePlan_To_output_UpgradePlan is an autogenerated conversion function. +func Convert_v1alpha2_UpgradePlan_To_output_UpgradePlan(in *UpgradePlan, out *output.UpgradePlan, s conversion.Scope) error { + return autoConvert_v1alpha2_UpgradePlan_To_output_UpgradePlan(in, out, s) +} + +func autoConvert_output_UpgradePlan_To_v1alpha2_UpgradePlan(in *output.UpgradePlan, out *UpgradePlan, s conversion.Scope) error { + out.Components = *(*[]ComponentUpgradePlan)(unsafe.Pointer(&in.Components)) + out.ConfigVersions = *(*[]ComponentConfigVersionState)(unsafe.Pointer(&in.ConfigVersions)) + return nil +} + +// Convert_output_UpgradePlan_To_v1alpha2_UpgradePlan is an autogenerated conversion function. +func Convert_output_UpgradePlan_To_v1alpha2_UpgradePlan(in *output.UpgradePlan, out *UpgradePlan, s conversion.Scope) error { + return autoConvert_output_UpgradePlan_To_v1alpha2_UpgradePlan(in, out, s) +} diff --git a/cmd/kubeadm/app/apis/output/v1alpha2/zz_generated.deepcopy.go b/cmd/kubeadm/app/apis/output/v1alpha2/zz_generated.deepcopy.go new file mode 100644 index 00000000000..54cc75256b3 --- /dev/null +++ b/cmd/kubeadm/app/apis/output/v1alpha2/zz_generated.deepcopy.go @@ -0,0 +1,149 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BootstrapToken) DeepCopyInto(out *BootstrapToken) { + *out = *in + out.TypeMeta = in.TypeMeta + in.BootstrapToken.DeepCopyInto(&out.BootstrapToken) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BootstrapToken. +func (in *BootstrapToken) DeepCopy() *BootstrapToken { + if in == nil { + return nil + } + out := new(BootstrapToken) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BootstrapToken) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentConfigVersionState) DeepCopyInto(out *ComponentConfigVersionState) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentConfigVersionState. +func (in *ComponentConfigVersionState) DeepCopy() *ComponentConfigVersionState { + if in == nil { + return nil + } + out := new(ComponentConfigVersionState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentUpgradePlan) DeepCopyInto(out *ComponentUpgradePlan) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentUpgradePlan. +func (in *ComponentUpgradePlan) DeepCopy() *ComponentUpgradePlan { + if in == nil { + return nil + } + out := new(ComponentUpgradePlan) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Images) DeepCopyInto(out *Images) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.Images != nil { + in, out := &in.Images, &out.Images + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Images. +func (in *Images) DeepCopy() *Images { + if in == nil { + return nil + } + out := new(Images) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Images) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpgradePlan) DeepCopyInto(out *UpgradePlan) { + *out = *in + out.TypeMeta = in.TypeMeta + if in.Components != nil { + in, out := &in.Components, &out.Components + *out = make([]ComponentUpgradePlan, len(*in)) + copy(*out, *in) + } + if in.ConfigVersions != nil { + in, out := &in.ConfigVersions, &out.ConfigVersions + *out = make([]ComponentConfigVersionState, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpgradePlan. +func (in *UpgradePlan) DeepCopy() *UpgradePlan { + if in == nil { + return nil + } + out := new(UpgradePlan) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *UpgradePlan) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +}