mirror of https://github.com/kubernetes/kops.git
staticcheck:remove duplicate import packages
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
This commit is contained in:
parent
4c57d2aad4
commit
a599348f99
|
|
@ -22,7 +22,6 @@ import (
|
||||||
|
|
||||||
"github.com/blang/semver"
|
"github.com/blang/semver"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kops/pkg/apis/kops/util"
|
"k8s.io/kops/pkg/apis/kops/util"
|
||||||
"k8s.io/kops/util/pkg/vfs"
|
"k8s.io/kops/util/pkg/vfs"
|
||||||
|
|
@ -36,7 +35,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Channel struct {
|
type Channel struct {
|
||||||
v1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"`
|
ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
Spec ChannelSpec `json:"spec,omitempty"`
|
Spec ChannelSpec `json:"spec,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ import (
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
|
@ -91,7 +90,7 @@ func (c *commonVFS) create(cluster *kops.Cluster, i runtime.Object) error {
|
||||||
|
|
||||||
creationTimestamp := objectMeta.GetCreationTimestamp()
|
creationTimestamp := objectMeta.GetCreationTimestamp()
|
||||||
if creationTimestamp.IsZero() {
|
if creationTimestamp.IsZero() {
|
||||||
objectMeta.SetCreationTimestamp(v1.NewTime(time.Now().UTC()))
|
objectMeta.SetCreationTimestamp(metav1.NewTime(time.Now().UTC()))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.writeConfig(cluster, c.basePath.Join(objectMeta.GetName()), i, vfs.WriteOptionCreate)
|
err = c.writeConfig(cluster, c.basePath.Join(objectMeta.GetName()), i, vfs.WriteOptionCreate)
|
||||||
|
|
@ -191,7 +190,7 @@ func (c *commonVFS) update(cluster *kops.Cluster, i runtime.Object) error {
|
||||||
|
|
||||||
creationTimestamp := objectMeta.GetCreationTimestamp()
|
creationTimestamp := objectMeta.GetCreationTimestamp()
|
||||||
if creationTimestamp.IsZero() {
|
if creationTimestamp.IsZero() {
|
||||||
objectMeta.SetCreationTimestamp(v1.NewTime(time.Now().UTC()))
|
objectMeta.SetCreationTimestamp(metav1.NewTime(time.Now().UTC()))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.writeConfig(cluster, c.basePath.Join(objectMeta.GetName()), i, vfs.WriteOptionOnlyIfExists)
|
err = c.writeConfig(cluster, c.basePath.Join(objectMeta.GetName()), i, vfs.WriteOptionOnlyIfExists)
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kops/pkg/apis/kops"
|
kopsapi "k8s.io/kops/pkg/apis/kops"
|
||||||
api "k8s.io/kops/pkg/apis/kops"
|
|
||||||
"k8s.io/kops/pkg/apis/kops/v1alpha1"
|
"k8s.io/kops/pkg/apis/kops/v1alpha1"
|
||||||
"k8s.io/kops/pkg/apis/kops/validation"
|
"k8s.io/kops/pkg/apis/kops/validation"
|
||||||
kopsinternalversion "k8s.io/kops/pkg/client/clientset_generated/clientset/typed/kops/internalversion"
|
kopsinternalversion "k8s.io/kops/pkg/client/clientset_generated/clientset/typed/kops/internalversion"
|
||||||
|
|
@ -39,16 +38,16 @@ type InstanceGroupVFS struct {
|
||||||
commonVFS
|
commonVFS
|
||||||
|
|
||||||
clusterName string
|
clusterName string
|
||||||
cluster *kops.Cluster
|
cluster *kopsapi.Cluster
|
||||||
}
|
}
|
||||||
|
|
||||||
type InstanceGroupMirror interface {
|
type InstanceGroupMirror interface {
|
||||||
WriteMirror(ig *kops.InstanceGroup) error
|
WriteMirror(ig *kopsapi.InstanceGroup) error
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ InstanceGroupMirror = &InstanceGroupVFS{}
|
var _ InstanceGroupMirror = &InstanceGroupVFS{}
|
||||||
|
|
||||||
func NewInstanceGroupMirror(cluster *kops.Cluster, configBase vfs.Path) InstanceGroupMirror {
|
func NewInstanceGroupMirror(cluster *kopsapi.Cluster, configBase vfs.Path) InstanceGroupMirror {
|
||||||
if cluster == nil || cluster.Name == "" {
|
if cluster == nil || cluster.Name == "" {
|
||||||
klog.Fatalf("cluster / cluster.Name is required")
|
klog.Fatalf("cluster / cluster.Name is required")
|
||||||
}
|
}
|
||||||
|
|
@ -64,12 +63,12 @@ func NewInstanceGroupMirror(cluster *kops.Cluster, configBase vfs.Path) Instance
|
||||||
defaultReadVersion := v1alpha1.SchemeGroupVersion.WithKind(kind)
|
defaultReadVersion := v1alpha1.SchemeGroupVersion.WithKind(kind)
|
||||||
r.defaultReadVersion = &defaultReadVersion
|
r.defaultReadVersion = &defaultReadVersion
|
||||||
r.validate = func(o runtime.Object) error {
|
r.validate = func(o runtime.Object) error {
|
||||||
return validation.ValidateInstanceGroup(o.(*kops.InstanceGroup))
|
return validation.ValidateInstanceGroup(o.(*kopsapi.InstanceGroup))
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInstanceGroupVFS(c *VFSClientset, cluster *kops.Cluster) *InstanceGroupVFS {
|
func newInstanceGroupVFS(c *VFSClientset, cluster *kopsapi.Cluster) *InstanceGroupVFS {
|
||||||
if cluster == nil || cluster.Name == "" {
|
if cluster == nil || cluster.Name == "" {
|
||||||
klog.Fatalf("cluster / cluster.Name is required")
|
klog.Fatalf("cluster / cluster.Name is required")
|
||||||
}
|
}
|
||||||
|
|
@ -85,14 +84,14 @@ func newInstanceGroupVFS(c *VFSClientset, cluster *kops.Cluster) *InstanceGroupV
|
||||||
defaultReadVersion := v1alpha1.SchemeGroupVersion.WithKind(kind)
|
defaultReadVersion := v1alpha1.SchemeGroupVersion.WithKind(kind)
|
||||||
r.defaultReadVersion = &defaultReadVersion
|
r.defaultReadVersion = &defaultReadVersion
|
||||||
r.validate = func(o runtime.Object) error {
|
r.validate = func(o runtime.Object) error {
|
||||||
return validation.ValidateInstanceGroup(o.(*kops.InstanceGroup))
|
return validation.ValidateInstanceGroup(o.(*kopsapi.InstanceGroup))
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ kopsinternalversion.InstanceGroupInterface = &InstanceGroupVFS{}
|
var _ kopsinternalversion.InstanceGroupInterface = &InstanceGroupVFS{}
|
||||||
|
|
||||||
func (c *InstanceGroupVFS) Get(name string, options metav1.GetOptions) (*api.InstanceGroup, error) {
|
func (c *InstanceGroupVFS) Get(name string, options metav1.GetOptions) (*kopsapi.InstanceGroup, error) {
|
||||||
if options.ResourceVersion != "" {
|
if options.ResourceVersion != "" {
|
||||||
return nil, fmt.Errorf("ResourceVersion not supported in InstanceGroupVFS::Get")
|
return nil, fmt.Errorf("ResourceVersion not supported in InstanceGroupVFS::Get")
|
||||||
}
|
}
|
||||||
|
|
@ -102,35 +101,35 @@ func (c *InstanceGroupVFS) Get(name string, options metav1.GetOptions) (*api.Ins
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if o == nil {
|
if o == nil {
|
||||||
return nil, errors.NewNotFound(schema.GroupResource{Group: api.GroupName, Resource: "InstanceGroup"}, name)
|
return nil, errors.NewNotFound(schema.GroupResource{Group: kopsapi.GroupName, Resource: "InstanceGroup"}, name)
|
||||||
}
|
}
|
||||||
ig := o.(*api.InstanceGroup)
|
ig := o.(*kopsapi.InstanceGroup)
|
||||||
c.addLabels(ig)
|
c.addLabels(ig)
|
||||||
|
|
||||||
return ig, nil
|
return ig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *InstanceGroupVFS) addLabels(ig *api.InstanceGroup) {
|
func (c *InstanceGroupVFS) addLabels(ig *kopsapi.InstanceGroup) {
|
||||||
if ig.ObjectMeta.Labels == nil {
|
if ig.ObjectMeta.Labels == nil {
|
||||||
ig.ObjectMeta.Labels = make(map[string]string)
|
ig.ObjectMeta.Labels = make(map[string]string)
|
||||||
}
|
}
|
||||||
ig.ObjectMeta.Labels[api.LabelClusterName] = c.clusterName
|
ig.ObjectMeta.Labels[kopsapi.LabelClusterName] = c.clusterName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *InstanceGroupVFS) List(options metav1.ListOptions) (*api.InstanceGroupList, error) {
|
func (c *InstanceGroupVFS) List(options metav1.ListOptions) (*kopsapi.InstanceGroupList, error) {
|
||||||
list := &api.InstanceGroupList{}
|
list := &kopsapi.InstanceGroupList{}
|
||||||
items, err := c.list(list.Items, options)
|
items, err := c.list(list.Items, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
list.Items = items.([]api.InstanceGroup)
|
list.Items = items.([]kopsapi.InstanceGroup)
|
||||||
for i := range list.Items {
|
for i := range list.Items {
|
||||||
c.addLabels(&list.Items[i])
|
c.addLabels(&list.Items[i])
|
||||||
}
|
}
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *InstanceGroupVFS) Create(g *api.InstanceGroup) (*api.InstanceGroup, error) {
|
func (c *InstanceGroupVFS) Create(g *kopsapi.InstanceGroup) (*kopsapi.InstanceGroup, error) {
|
||||||
err := c.create(c.cluster, g)
|
err := c.create(c.cluster, g)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -138,7 +137,7 @@ func (c *InstanceGroupVFS) Create(g *api.InstanceGroup) (*api.InstanceGroup, err
|
||||||
return g, nil
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *InstanceGroupVFS) Update(g *api.InstanceGroup) (*api.InstanceGroup, error) {
|
func (c *InstanceGroupVFS) Update(g *kopsapi.InstanceGroup) (*kopsapi.InstanceGroup, error) {
|
||||||
|
|
||||||
old, err := c.Get(g.Name, metav1.GetOptions{})
|
old, err := c.Get(g.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -156,7 +155,7 @@ func (c *InstanceGroupVFS) Update(g *api.InstanceGroup) (*api.InstanceGroup, err
|
||||||
return g, nil
|
return g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *InstanceGroupVFS) WriteMirror(g *api.InstanceGroup) error {
|
func (c *InstanceGroupVFS) WriteMirror(g *kopsapi.InstanceGroup) error {
|
||||||
err := c.writeConfig(c.cluster, c.basePath.Join(g.Name), g)
|
err := c.writeConfig(c.cluster, c.basePath.Join(g.Name), g)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error writing %s: %v", c.kind, err)
|
return fmt.Errorf("error writing %s: %v", c.kind, err)
|
||||||
|
|
@ -177,6 +176,6 @@ func (r *InstanceGroupVFS) Watch(opts metav1.ListOptions) (watch.Interface, erro
|
||||||
return nil, fmt.Errorf("InstanceGroupVFS Watch not implemented for vfs store")
|
return nil, fmt.Errorf("InstanceGroupVFS Watch not implemented for vfs store")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *InstanceGroupVFS) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *api.InstanceGroup, err error) {
|
func (r *InstanceGroupVFS) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *kopsapi.InstanceGroup, err error) {
|
||||||
return nil, fmt.Errorf("InstanceGroupVFS Patch not implemented for vfs store")
|
return nil, fmt.Errorf("InstanceGroupVFS Patch not implemented for vfs store")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,14 @@ import (
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kops/pkg/apis/kops"
|
kopsapi "k8s.io/kops/pkg/apis/kops"
|
||||||
api "k8s.io/kops/pkg/apis/kops"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CloudInstanceGroup is the cloud backing of InstanceGroup.
|
// CloudInstanceGroup is the cloud backing of InstanceGroup.
|
||||||
type CloudInstanceGroup struct {
|
type CloudInstanceGroup struct {
|
||||||
// HumanName is a user-friendly name for the group
|
// HumanName is a user-friendly name for the group
|
||||||
HumanName string
|
HumanName string
|
||||||
InstanceGroup *api.InstanceGroup
|
InstanceGroup *kopsapi.InstanceGroup
|
||||||
Ready []*CloudInstanceGroupMember
|
Ready []*CloudInstanceGroupMember
|
||||||
NeedUpdate []*CloudInstanceGroupMember
|
NeedUpdate []*CloudInstanceGroupMember
|
||||||
MinSize int
|
MinSize int
|
||||||
|
|
@ -84,12 +83,12 @@ func (c *CloudInstanceGroup) Status() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNodeMap returns a list of nodes keyed by their external id
|
// GetNodeMap returns a list of nodes keyed by their external id
|
||||||
func GetNodeMap(nodes []v1.Node, cluster *kops.Cluster) map[string]*v1.Node {
|
func GetNodeMap(nodes []v1.Node, cluster *kopsapi.Cluster) map[string]*v1.Node {
|
||||||
nodeMap := make(map[string]*v1.Node)
|
nodeMap := make(map[string]*v1.Node)
|
||||||
delimiter := "/"
|
delimiter := "/"
|
||||||
// Alicloud CCM uses the "{region}.{instance-id}" of a instance as ProviderID.
|
// Alicloud CCM uses the "{region}.{instance-id}" of a instance as ProviderID.
|
||||||
// We need to set delimiter to "." for Alicloud.
|
// We need to set delimiter to "." for Alicloud.
|
||||||
if kops.CloudProviderID(cluster.Spec.CloudProvider) == kops.CloudProviderALI {
|
if kopsapi.CloudProviderID(cluster.Spec.CloudProvider) == kopsapi.CloudProviderALI {
|
||||||
delimiter = "."
|
delimiter = "."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue