Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staticcheck:update import package aliases #8256

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 105 additions & 105 deletions cmd/kops/create_cluster.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cmd/kops/edit_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

"github.com/spf13/cobra"
"k8s.io/kops/cmd/kops/util"
api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/registry"
"k8s.io/kops/pkg/apis/kops/validation"
"k8s.io/kops/pkg/assets"
Expand Down Expand Up @@ -172,7 +172,7 @@ func RunEditCluster(f *util.Factory, cmd *cobra.Command, args []string, out io.W
return preservedFile(fmt.Errorf("error parsing config: %s", err), file, out)
}

newCluster, ok := newObj.(*api.Cluster)
newCluster, ok := newObj.(*kopsapi.Cluster)
if !ok {
results = editResults{
file: file,
Expand Down
4 changes: 2 additions & 2 deletions cmd/kops/edit_instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kops/cmd/kops/util"
api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/validation"
"k8s.io/kops/pkg/assets"
"k8s.io/kops/pkg/kopscodecs"
Expand Down Expand Up @@ -147,7 +147,7 @@ func RunEditInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string, ou
return fmt.Errorf("error parsing InstanceGroup: %v", err)
}

newGroup, ok := newObj.(*api.InstanceGroup)
newGroup, ok := newObj.(*kopsapi.InstanceGroup)
if !ok {
return fmt.Errorf("object was not of expected type: %T", newObj)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/kops/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kops/cmd/kops/util"
api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/kopscodecs"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
"k8s.io/kubernetes/pkg/kubectl/util/templates"
Expand Down Expand Up @@ -135,7 +135,7 @@ func RunGet(context Factory, out io.Writer, options *GetOptions) error {
fmt.Fprintf(os.Stderr, "No instance groups found\n")
}

var instancegroups []*api.InstanceGroup
var instancegroups []*kopsapi.InstanceGroup
for i := range igList.Items {
instancegroups = append(instancegroups, &igList.Items[i])
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func RunGet(context Factory, out io.Writer, options *GetOptions) error {

case OutputTable:
fmt.Fprintf(os.Stdout, "Cluster\n")
err = clusterOutputTable([]*api.Cluster{cluster}, out)
err = clusterOutputTable([]*kopsapi.Cluster{cluster}, out)
if err != nil {
return err
}
Expand Down
20 changes: 10 additions & 10 deletions cmd/kops/get_instancegroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kops/cmd/kops/util"
api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/formatter"
"k8s.io/kops/util/pkg/tables"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
Expand Down Expand Up @@ -132,11 +132,11 @@ func RunGetInstanceGroups(options *GetInstanceGroupsOptions, args []string) erro
}
}

func filterInstanceGroupsByName(instanceGroupNames []string, list []api.InstanceGroup) ([]*api.InstanceGroup, error) {
var instancegroups []*api.InstanceGroup
func filterInstanceGroupsByName(instanceGroupNames []string, list []kopsapi.InstanceGroup) ([]*kopsapi.InstanceGroup, error) {
var instancegroups []*kopsapi.InstanceGroup
if len(instanceGroupNames) != 0 {
// Build a map so we can return items in the same order
m := make(map[string]*api.InstanceGroup)
m := make(map[string]*kopsapi.InstanceGroup)
for i := range list {
ig := &list[i]
m[ig.ObjectMeta.Name] = ig
Expand All @@ -159,23 +159,23 @@ func filterInstanceGroupsByName(instanceGroupNames []string, list []api.Instance
return instancegroups, nil
}

func igOutputTable(cluster *api.Cluster, instancegroups []*api.InstanceGroup, out io.Writer) error {
func igOutputTable(cluster *kopsapi.Cluster, instancegroups []*kopsapi.InstanceGroup, out io.Writer) error {
t := &tables.Table{}
t.AddColumn("NAME", func(c *api.InstanceGroup) string {
t.AddColumn("NAME", func(c *kopsapi.InstanceGroup) string {
return c.ObjectMeta.Name
})
t.AddColumn("ROLE", func(c *api.InstanceGroup) string {
t.AddColumn("ROLE", func(c *kopsapi.InstanceGroup) string {
return string(c.Spec.Role)
})
t.AddColumn("MACHINETYPE", func(c *api.InstanceGroup) string {
t.AddColumn("MACHINETYPE", func(c *kopsapi.InstanceGroup) string {
return c.Spec.MachineType
})
t.AddColumn("SUBNETS", formatter.RenderInstanceGroupSubnets(cluster))
t.AddColumn("ZONES", formatter.RenderInstanceGroupZones(cluster))
t.AddColumn("MIN", func(c *api.InstanceGroup) string {
t.AddColumn("MIN", func(c *kopsapi.InstanceGroup) string {
return int32PointerToString(c.Spec.MinSize)
})
t.AddColumn("MAX", func(c *api.InstanceGroup) string {
t.AddColumn("MAX", func(c *kopsapi.InstanceGroup) string {
return int32PointerToString(c.Spec.MaxSize)
})
// SUBNETS is not selected by default - not as useful as ZONES
Expand Down
10 changes: 5 additions & 5 deletions cmd/kops/toolbox_convert_imported.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kops/cmd/kops/util"
api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
"k8s.io/kops/upup/pkg/kutil"
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
Expand Down Expand Up @@ -57,7 +57,7 @@ type ToolboxConvertImportedOptions struct {
}

func (o *ToolboxConvertImportedOptions) InitDefaults() {
o.Channel = api.DefaultChannel
o.Channel = kopsapi.DefaultChannel
}

func NewCmdToolboxConvertImported(f *util.Factory, out io.Writer) *cobra.Command {
Expand Down Expand Up @@ -112,12 +112,12 @@ func RunToolboxConvertImported(f *util.Factory, out io.Writer, options *ToolboxC
if err != nil {
return err
}
var instanceGroups []*api.InstanceGroup
var instanceGroups []*kopsapi.InstanceGroup
for i := range list.Items {
instanceGroups = append(instanceGroups, &list.Items[i])
}

if cluster.ObjectMeta.Annotations[api.AnnotationNameManagement] != api.AnnotationValueManagementImported {
if cluster.ObjectMeta.Annotations[kopsapi.AnnotationNameManagement] != kopsapi.AnnotationValueManagementImported {
return fmt.Errorf("cluster %q does not appear to be a cluster imported using kops import", cluster.ObjectMeta.Name)
}

Expand Down Expand Up @@ -155,7 +155,7 @@ func RunToolboxConvertImported(f *util.Factory, out io.Writer, options *ToolboxC
return fmt.Errorf("error initializing AWS client: %v", err)
}

channel, err := api.LoadChannel(options.Channel)
channel, err := kopsapi.LoadChannel(options.Channel)
if err != nil {
return err
}
Expand Down
32 changes: 16 additions & 16 deletions examples/kops-api-example/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"io/ioutil"

api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/client/simple/vfsclientset"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/cloudup"
Expand All @@ -31,31 +31,31 @@ func up() error {
allowList := true
clientset := vfsclientset.NewVFSClientset(registryBase, allowList)

cluster := &api.Cluster{}
cluster := &kopsapi.Cluster{}
cluster.ObjectMeta.Name = clusterName
cluster.Spec = api.ClusterSpec{
cluster.Spec = kopsapi.ClusterSpec{
Channel: "stable",
CloudProvider: "aws",
ConfigBase: registryBase.Join(cluster.ObjectMeta.Name).Path(),
Topology: &api.TopologySpec{},
Topology: &kopsapi.TopologySpec{},
}
cluster.Spec.Topology.Masters = api.TopologyPublic
cluster.Spec.Topology.Nodes = api.TopologyPublic
cluster.Spec.Topology.Masters = kopsapi.TopologyPublic
cluster.Spec.Topology.Nodes = kopsapi.TopologyPublic

for _, z := range nodeZones {
cluster.Spec.Subnets = append(cluster.Spec.Subnets, api.ClusterSubnetSpec{
cluster.Spec.Subnets = append(cluster.Spec.Subnets, kopsapi.ClusterSubnetSpec{
Name: z,
Zone: z,
Type: api.SubnetTypePublic,
Type: kopsapi.SubnetTypePublic,
})
}

for _, etcdClusterName := range cloudup.EtcdClusters {
etcdCluster := &api.EtcdClusterSpec{
etcdCluster := &kopsapi.EtcdClusterSpec{
Name: etcdClusterName,
}
for _, masterZone := range masterZones {
etcdMember := &api.EtcdMemberSpec{
etcdMember := &kopsapi.EtcdMemberSpec{
Name: masterZone,
InstanceGroup: fi.String(masterZone),
}
Expand All @@ -75,10 +75,10 @@ func up() error {

// Create master ig
{
ig := &api.InstanceGroup{}
ig := &kopsapi.InstanceGroup{}
ig.ObjectMeta.Name = "master"
ig.Spec = api.InstanceGroupSpec{
Role: api.InstanceGroupRoleMaster,
ig.Spec = kopsapi.InstanceGroupSpec{
Role: kopsapi.InstanceGroupRoleMaster,
Subnets: masterZones,
}
_, err := clientset.InstanceGroupsFor(cluster).Create(ig)
Expand All @@ -89,10 +89,10 @@ func up() error {

// Create node ig
{
ig := &api.InstanceGroup{}
ig := &kopsapi.InstanceGroup{}
ig.ObjectMeta.Name = "nodes"
ig.Spec = api.InstanceGroupSpec{
Role: api.InstanceGroupRoleNode,
ig.Spec = kopsapi.InstanceGroupSpec{
Role: kopsapi.InstanceGroupRoleNode,
Subnets: nodeZones,
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/kops/registry/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package registry
import (
"fmt"

api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/client/simple"
)

func CreateClusterConfig(clientset simple.Clientset, cluster *api.Cluster, groups []*api.InstanceGroup) error {
func CreateClusterConfig(clientset simple.Clientset, cluster *kopsapi.Cluster, groups []*kopsapi.InstanceGroup) error {
// Check for instancegroup Name duplicates before writing
{
names := map[string]bool{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/kops/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"

"k8s.io/apimachinery/pkg/util/validation/field"
api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/util/pkg/vfs"
)

Expand All @@ -31,7 +31,7 @@ const (
PathClusterCompleted = "cluster.spec"
)

func ConfigBase(c *api.Cluster) (vfs.Path, error) {
func ConfigBase(c *kopsapi.Cluster) (vfs.Path, error) {
if c.Spec.ConfigBase == "" {
return nil, field.Required(field.NewPath("Spec", "ConfigBase"), "")
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/client/simple/vfsclientset/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/klog"
api "k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/registry"
"k8s.io/kops/pkg/apis/kops/v1alpha1"
"k8s.io/kops/pkg/apis/kops/validation"
Expand All @@ -49,7 +49,7 @@ func newClusterVFS(basePath vfs.Path) *ClusterVFS {
return c
}

func (c *ClusterVFS) Get(name string, options metav1.GetOptions) (*api.Cluster, error) {
func (c *ClusterVFS) Get(name string, options metav1.GetOptions) (*kopsapi.Cluster, error) {
if options.ResourceVersion != "" {
return nil, fmt.Errorf("ResourceVersion not supported in ClusterVFS::Get")
}
Expand All @@ -58,7 +58,7 @@ func (c *ClusterVFS) Get(name string, options metav1.GetOptions) (*api.Cluster,
return nil, err
}
if o == nil {
return nil, errors.NewNotFound(schema.GroupResource{Group: api.GroupName, Resource: "Cluster"}, name)
return nil, errors.NewNotFound(schema.GroupResource{Group: kopsapi.GroupName, Resource: "Cluster"}, name)
}
return o, nil
}
Expand All @@ -72,13 +72,13 @@ func (c *ClusterVFS) configBase(clusterName string) (vfs.Path, error) {
return configPath, nil
}

func (c *ClusterVFS) List(options metav1.ListOptions) (*api.ClusterList, error) {
func (c *ClusterVFS) List(options metav1.ListOptions) (*kopsapi.ClusterList, error) {
names, err := c.listNames()
if err != nil {
return nil, err
}

var items []api.Cluster
var items []kopsapi.Cluster

for _, clusterName := range names {
cluster, err := c.find(clusterName)
Expand All @@ -95,10 +95,10 @@ func (c *ClusterVFS) List(options metav1.ListOptions) (*api.ClusterList, error)
items = append(items, *cluster)
}

return &api.ClusterList{Items: items}, nil
return &kopsapi.ClusterList{Items: items}, nil
}

func (r *ClusterVFS) Create(c *api.Cluster) (*api.Cluster, error) {
func (r *ClusterVFS) Create(c *kopsapi.Cluster) (*kopsapi.Cluster, error) {
if err := validation.ValidateCluster(c, false); err != nil {
return nil, err
}
Expand All @@ -122,7 +122,7 @@ func (r *ClusterVFS) Create(c *api.Cluster) (*api.Cluster, error) {
return c, nil
}

func (r *ClusterVFS) Update(c *api.Cluster, status *api.ClusterStatus) (*api.Cluster, error) {
func (r *ClusterVFS) Update(c *kopsapi.Cluster, status *kopsapi.ClusterStatus) (*kopsapi.Cluster, error) {
clusterName := c.ObjectMeta.Name
if clusterName == "" {
return nil, field.Required(field.NewPath("Name"), "clusterName is required")
Expand All @@ -134,7 +134,7 @@ func (r *ClusterVFS) Update(c *api.Cluster, status *api.ClusterStatus) (*api.Clu
}

if old == nil {
return nil, errors.NewNotFound(schema.GroupResource{Group: api.GroupName, Resource: "Cluster"}, clusterName)
return nil, errors.NewNotFound(schema.GroupResource{Group: kopsapi.GroupName, Resource: "Cluster"}, clusterName)
}

if err := validation.ValidateClusterUpdate(c, status, old).ToAggregate(); err != nil {
Expand Down Expand Up @@ -178,7 +178,7 @@ func (r *ClusterVFS) listNames() ([]string, error) {
return keys, nil
}

func (r *ClusterVFS) find(clusterName string) (*api.Cluster, error) {
func (r *ClusterVFS) find(clusterName string) (*kopsapi.Cluster, error) {
if clusterName == "" {
return nil, fmt.Errorf("clusterName is required")
}
Expand All @@ -192,7 +192,7 @@ func (r *ClusterVFS) find(clusterName string) (*api.Cluster, error) {
return nil, fmt.Errorf("error reading cluster configuration %q: %v", clusterName, err)
}

c := o.(*api.Cluster)
c := o.(*kopsapi.Cluster)

if c.ObjectMeta.Name == "" {
c.ObjectMeta.Name = clusterName
Expand Down Expand Up @@ -225,6 +225,6 @@ func (r *ClusterVFS) Watch(opts metav1.ListOptions) (watch.Interface, error) {
return nil, fmt.Errorf("cluster Watch not implemented for vfs store")
}

func (r *ClusterVFS) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *api.Cluster, err error) {
func (r *ClusterVFS) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *kopsapi.Cluster, err error) {
return nil, fmt.Errorf("cluster Patch not implemented for vfs store")
}
Loading