Skip to content

Cannot use the internalversion clientset #381

Open

Description

Steps to reproduce:

  1. Setup dummy main.go
package main

import (
	"fmt"

	machine "github.com/gardener/machine-controller-manager/pkg/client/clientset/internalversion"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	rest "k8s.io/client-go/rest"
)

func main() {
	config := rest.Config{
		Host: "(minikube ip):8443",
		TLSClientConfig: rest.TLSClientConfig{
			CAFile:   "/path/to/ca.crt",
			CertFile: "/path/to/client.crt",
			KeyFile:  "/path/to/client.key",
		},
	}
	client, err := machine.NewForConfig(&config)
	if err != nil {
		panic(err)
	}

	machineList, err := client.Machine().List(metav1.ListOptions{})
	if err != nil {
		panic(err)
	}

	fmt.Println(len(machineList.Items))
}
  1. Try to run it and ensure it fails
$ go mod vendor && go mod tidy
$ go run -mod=vendor main.go
# github.com/gardener/machine-controller-manager/pkg/client/clientset/internalversion/typed/machine/internalversion
vendor/github.com/gardener/machine-controller-manager/pkg/client/clientset/internalversion/typed/machine/internalversion/machine.go:85:19: machine.Machine undefined (type *machine.Machine has no field or method Machine)
vendor/github.com/gardener/machine-controller-manager/pkg/client/clientset/internalversion/typed/machine/internalversion/machine.go:97:19: machine.Machine undefined (type *machine.Machine has no field or method Machine)
vendor/github.com/gardener/machine-controller-manager/pkg/client/clientset/internalversion/typed/machine/internalversion/machine.go:112:19: machine.Machine undefined (type *machine.Machine has no field or method Machine)
vendor/github.com/gardener/machine-controller-manager/pkg/client/clientset/internalversion/typed/machine/internalversion/machine_client.go:10:6: MachineInterface redeclared in this block
	previous declaration at vendor/github.com/gardener/machine-controller-manager/pkg/client/clientset/internalversion/typed/machine/internalversion/machine.go:21:6
vendor/github.com/gardener/machine-controller-manager/pkg/client/clientset/internalversion/typed/machine/internalversion/machine_client.go:47:20: cannot use newMachines(c, namespace) (type *machines) as type MachineInterface in return argument:
	*machines does not implement MachineInterface (missing AWSMachineClasses method)

Also golangci-lint reports for the same redeclaration of MachineInterface.

$ golangci-lint run --version
golangci-lint has version 1.18.0 built from 31afdf8 on 2019-09-10T09:34:48Z
$ golangci-lint run ./...
pkg/client/clientset/internalversion/typed/machine/internalversion/machine_client.go:10:6: `MachineInterface` redeclared in this block (typecheck)
type MachineInterface interface {
     ^
pkg/client/clientset/internalversion/typed/machine/internalversion/machine.go:21:6: 	other declaration of MachineInterface (typecheck)
type MachineInterface interface {
     ^
[...]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    kind/api-changeAPI change with impact on API userskind/bugBuglifecycle/rottenNobody worked on this for 12 months (final aging stage)needs/planningNeeds (more) planning with other MCM maintainerspriority/4Priority (lower number equals higher priority)triage/wont-fixWe will not fix this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions