Browse Source

Revert "Merge pull request #607 from dramich/mockgen"

This reverts commit cb306b9378, reversing
changes made to ebb12c74c6.
pull/614/head
Erik Wilson 5 years ago
parent
commit
c32e6469a8
  1. 1
      pkg/codegen/main.go
  2. 6
      pkg/generated/controllers/k3s.cattle.io/factory.go
  3. 4
      trash.lock
  4. 2
      vendor.conf
  5. 10
      vendor/github.com/rancher/wrangler/pkg/apply/desiredset_apply.go
  6. 12
      vendor/github.com/rancher/wrangler/pkg/apply/desiredset_compare.go
  7. 1
      vendor/github.com/rancher/wrangler/pkg/controller-gen/args/args.go
  8. 7
      vendor/github.com/rancher/wrangler/pkg/controller-gen/generators/factory_go.go
  9. 1
      vendor/github.com/rancher/wrangler/pkg/controller-gen/generators/util.go
  10. 8
      vendor/github.com/rancher/wrangler/pkg/controller-gen/main.go
  11. 1
      vendor/github.com/rancher/wrangler/pkg/generic/controller.go
  12. 27
      vendor/github.com/rancher/wrangler/pkg/gvk/get.go
  13. 89
      vendor/github.com/rancher/wrangler/pkg/objectset/objectset.go
  14. 7
      vendor/github.com/rancher/wrangler/pkg/schemes/all.go

1
pkg/codegen/main.go

@ -94,6 +94,5 @@ func main() {
GenerateTypes: true, GenerateTypes: true,
}, },
}, },
GenMocks: false,
}) })
} }

6
pkg/generated/controllers/k3s.cattle.io/factory.go

@ -23,18 +23,12 @@ import (
"time" "time"
clientset "github.com/rancher/k3s/pkg/generated/clientset/versioned" clientset "github.com/rancher/k3s/pkg/generated/clientset/versioned"
scheme "github.com/rancher/k3s/pkg/generated/clientset/versioned/scheme"
informers "github.com/rancher/k3s/pkg/generated/informers/externalversions" informers "github.com/rancher/k3s/pkg/generated/informers/externalversions"
"github.com/rancher/wrangler/pkg/generic" "github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/pkg/schemes"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
) )
func init() {
scheme.AddToScheme(schemes.All)
}
type Factory struct { type Factory struct {
synced bool synced bool
informerFactory informers.SharedInformerFactory informerFactory informers.SharedInformerFactory

4
trash.lock

@ -231,7 +231,7 @@ import:
- package: github.com/rancher/remotedialer - package: github.com/rancher/remotedialer
version: 66218bc42b4fa27c34523c0d19a41a0e2b74983d version: 66218bc42b4fa27c34523c0d19a41a0e2b74983d
- package: github.com/rancher/wrangler - package: github.com/rancher/wrangler
version: d53925110e19e055d1c21df3b49021833e883f33 version: 4202dbfa88013c19238bb004d82e013f0593493d
- package: github.com/rancher/wrangler-api - package: github.com/rancher/wrangler-api
version: efe26ac6a9d720e1bfa5a8cc5f8dce5ad598ce26 version: efe26ac6a9d720e1bfa5a8cc5f8dce5ad598ce26
- package: github.com/robfig/cron - package: github.com/robfig/cron
@ -274,8 +274,6 @@ import:
version: 1d523034197ff1f222f6429836dd36a2457a1874 version: 1d523034197ff1f222f6429836dd36a2457a1874
- package: go.etcd.io/bbolt - package: go.etcd.io/bbolt
version: v1.3.1-etcd.8 version: v1.3.1-etcd.8
- package: go.etcd.io/etcd
version: v3.3.11
- package: golang.org/x/crypto - package: golang.org/x/crypto
version: a49355c7e3f8fe157a85be2f77e6e269a0f89602 version: a49355c7e3f8fe157a85be2f77e6e269a0f89602
- package: golang.org/x/net - package: golang.org/x/net

2
vendor.conf

@ -11,7 +11,7 @@ package=github.com/opencontainers/runc/contrib/cmd/recvtty
k8s.io/kubernetes v1.14.3-k3s.2 https://github.com/rancher/k3s.git transitive=true,staging=true k8s.io/kubernetes v1.14.3-k3s.2 https://github.com/rancher/k3s.git transitive=true,staging=true
github.com/rancher/wrangler d53925110e19e055d1c21df3b49021833e883f33 github.com/rancher/wrangler 4202dbfa88013c19238bb004d82e013f0593493d
github.com/rancher/wrangler-api efe26ac6a9d720e1bfa5a8cc5f8dce5ad598ce26 github.com/rancher/wrangler-api efe26ac6a9d720e1bfa5a8cc5f8dce5ad598ce26
github.com/rancher/dynamiclistener 4716ac2362986f28bede3f3caf5d1ce347da55b0 github.com/rancher/dynamiclistener 4716ac2362986f28bede3f3caf5d1ce347da55b0
github.com/rancher/remotedialer 66218bc42b4fa27c34523c0d19a41a0e2b74983d github.com/rancher/remotedialer 66218bc42b4fa27c34523c0d19a41a0e2b74983d

10
vendor/github.com/rancher/wrangler/pkg/apply/desiredset_apply.go generated vendored

@ -6,8 +6,6 @@ import (
"fmt" "fmt"
"sync" "sync"
gvk2 "github.com/rancher/wrangler/pkg/gvk"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/rancher/wrangler/pkg/apply/injectors" "github.com/rancher/wrangler/pkg/apply/injectors"
"github.com/rancher/wrangler/pkg/objectset" "github.com/rancher/wrangler/pkg/objectset"
@ -167,14 +165,10 @@ func (o *desiredSet) getLabelsAndAnnotations() (map[string]string, map[string]st
} }
if o.owner != nil { if o.owner != nil {
gvk, err := gvk2.Get(o.owner) annotations[LabelGVK] = o.owner.GetObjectKind().GroupVersionKind().String()
if err != nil {
return nil, nil, err
}
annotations[LabelGVK] = gvk.String()
metadata, err := meta.Accessor(o.owner) metadata, err := meta.Accessor(o.owner)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("failed to get metadata for %s", gvk) return nil, nil, fmt.Errorf("failed to get metadata for %s", o.owner.GetObjectKind().GroupVersionKind())
} }
annotations[LabelName] = metadata.GetName() annotations[LabelName] = metadata.GetName()
annotations[LabelNamespace] = metadata.GetNamespace() annotations[LabelNamespace] = metadata.GetNamespace()

12
vendor/github.com/rancher/wrangler/pkg/apply/desiredset_compare.go generated vendored

@ -208,19 +208,15 @@ func getOriginal(obj v1.Object) ([]byte, error) {
return []byte("{}"), nil return []byte("{}"), nil
} }
mapObj := map[string]interface{}{} mapObj := &unstructured.Unstructured{}
err := json.Unmarshal(original, &mapObj) err := json.Unmarshal(original, mapObj)
if err != nil { if err != nil {
return nil, err return nil, err
} }
removeCreationTimestamp(mapObj) removeCreationTimestamp(mapObj.Object)
u := &unstructured.Unstructured{ objCopy, err := prepareObjectForCreate(mapObj)
Object: mapObj,
}
objCopy, err := prepareObjectForCreate(u)
if err != nil { if err != nil {
return nil, err return nil, err
} }

1
vendor/github.com/rancher/wrangler/pkg/controller-gen/args/args.go generated vendored

@ -16,7 +16,6 @@ type Options struct {
OutputPackage string OutputPackage string
Groups map[string]Group Groups map[string]Group
Boilerplate string Boilerplate string
GenMocks bool
} }
type Group struct { type Group struct {

7
vendor/github.com/rancher/wrangler/pkg/controller-gen/generators/factory_go.go generated vendored

@ -3,7 +3,6 @@ package generators
import ( import (
"fmt" "fmt"
"io" "io"
"path/filepath"
args2 "github.com/rancher/wrangler/pkg/controller-gen/args" args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
"k8s.io/gengo/args" "k8s.io/gengo/args"
@ -39,9 +38,7 @@ func (f *factory) Imports(*generator.Context) []string {
"k8s.io/apimachinery/pkg/runtime/schema", "k8s.io/apimachinery/pkg/runtime/schema",
"k8s.io/client-go/rest", "k8s.io/client-go/rest",
GenericPackage, GenericPackage,
AllSchemes,
fmt.Sprintf("clientset \"%s\"", group.ClientSetPackage), fmt.Sprintf("clientset \"%s\"", group.ClientSetPackage),
fmt.Sprintf("scheme \"%s\"", filepath.Join(group.ClientSetPackage, "scheme")),
fmt.Sprintf("informers \"%s\"", group.InformersPackage), fmt.Sprintf("informers \"%s\"", group.InformersPackage),
} }
} }
@ -64,10 +61,6 @@ func (f *factory) Init(c *generator.Context, w io.Writer) error {
} }
var factoryBody = ` var factoryBody = `
func init() {
scheme.AddToScheme(schemes.All)
}
type Factory struct { type Factory struct {
synced bool synced bool
informerFactory informers.SharedInformerFactory informerFactory informers.SharedInformerFactory

1
vendor/github.com/rancher/wrangler/pkg/controller-gen/generators/util.go generated vendored

@ -8,7 +8,6 @@ import (
const ( const (
GenericPackage = "github.com/rancher/wrangler/pkg/generic" GenericPackage = "github.com/rancher/wrangler/pkg/generic"
AllSchemes = "github.com/rancher/wrangler/pkg/schemes"
) )
func groupPath(group string) string { func groupPath(group string) string {

8
vendor/github.com/rancher/wrangler/pkg/controller-gen/main.go generated vendored

@ -104,11 +104,9 @@ func Run(opts cgargs.Options) {
logrus.Fatalf("go modules copy failed: %v", err) logrus.Fatalf("go modules copy failed: %v", err)
} }
if opts.GenMocks { if err := clientGen.GenerateMocks(); err != nil {
if err := clientGen.GenerateMocks(); err != nil { logrus.Errorf("mocks failed: %v", err)
logrus.Errorf("mocks failed: %v", err) return
return
}
} }
} }

1
vendor/github.com/rancher/wrangler/pkg/generic/controller.go generated vendored

@ -56,6 +56,7 @@ func NewController(name string, informer cache.SharedIndexInformer, workqueue wo
workqueue: workqueue, workqueue: workqueue,
} }
logrus.Info("Setting up event handlers")
informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: controller.handleObject, AddFunc: controller.handleObject,
UpdateFunc: func(old, new interface{}) { UpdateFunc: func(old, new interface{}) {

27
vendor/github.com/rancher/wrangler/pkg/gvk/get.go generated vendored

@ -1,27 +0,0 @@
package gvk
import (
"fmt"
"github.com/rancher/wrangler/pkg/schemes"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
func Get(obj runtime.Object) (schema.GroupVersionKind, error) {
gvk := obj.GetObjectKind().GroupVersionKind()
if gvk.Kind != "" {
return gvk, nil
}
gvks, _, err := schemes.All.ObjectKinds(obj)
if err != nil {
return schema.GroupVersionKind{}, err
}
if len(gvks) == 0 {
return schema.GroupVersionKind{}, fmt.Errorf("failed to find gvk for %v", obj.GetObjectKind())
}
return gvks[0], nil
}

89
vendor/github.com/rancher/wrangler/pkg/objectset/objectset.go generated vendored

@ -5,8 +5,6 @@ import (
"reflect" "reflect"
"sort" "sort"
"github.com/rancher/wrangler/pkg/gvk"
"github.com/rancher/wrangler/pkg/merr" "github.com/rancher/wrangler/pkg/merr"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -35,21 +33,16 @@ func (o ObjectKey) String() string {
type ObjectByGVK map[schema.GroupVersionKind]map[ObjectKey]runtime.Object type ObjectByGVK map[schema.GroupVersionKind]map[ObjectKey]runtime.Object
func (o ObjectByGVK) Add(obj runtime.Object) (schema.GroupVersionKind, error) { func (o ObjectByGVK) Add(obj runtime.Object) error {
metadata, err := meta.Accessor(obj) metadata, err := meta.Accessor(obj)
if err != nil { if err != nil {
return schema.GroupVersionKind{}, err return err
}
gvk, err := gvk.Get(obj)
if err != nil {
return schema.GroupVersionKind{}, err
} }
objs := o[gvk] objs := o[obj.GetObjectKind().GroupVersionKind()]
if objs == nil { if objs == nil {
objs = map[ObjectKey]runtime.Object{} objs = map[ObjectKey]runtime.Object{}
o[gvk] = objs o[obj.GetObjectKind().GroupVersionKind()] = objs
} }
objs[ObjectKey{ objs[ObjectKey{
@ -57,28 +50,42 @@ func (o ObjectByGVK) Add(obj runtime.Object) (schema.GroupVersionKind, error) {
Name: metadata.GetName(), Name: metadata.GetName(),
}] = obj }] = obj
return gvk, nil return nil
} }
type ObjectSet struct { type ObjectSet struct {
errs []error errs []error
objects ObjectByGVK objects ObjectByGVK
order []runtime.Object nsed map[schema.GroupVersionKind]bool
gvkOrder []schema.GroupVersionKind inputs []runtime.Object
gvkSeen map[schema.GroupVersionKind]bool order []runtime.Object
} }
func NewObjectSet() *ObjectSet { func NewObjectSet() *ObjectSet {
return &ObjectSet{ return &ObjectSet{
nsed: map[schema.GroupVersionKind]bool{},
objects: ObjectByGVK{}, objects: ObjectByGVK{},
gvkSeen: map[schema.GroupVersionKind]bool{},
} }
} }
func (o *ObjectSet) Inputs() []runtime.Object {
return o.inputs
}
func (o *ObjectSet) ObjectsByGVK() ObjectByGVK { func (o *ObjectSet) ObjectsByGVK() ObjectByGVK {
return o.objects return o.objects
} }
func (o *ObjectSet) AddInput(objs ...runtime.Object) *ObjectSet {
for _, obj := range objs {
if obj == nil || reflect.ValueOf(obj).IsNil() {
continue
}
o.inputs = append(o.inputs, obj)
}
return o
}
func (o *ObjectSet) Add(objs ...runtime.Object) *ObjectSet { func (o *ObjectSet) Add(objs ...runtime.Object) *ObjectSet {
for _, obj := range objs { for _, obj := range objs {
o.add(obj) o.add(obj)
@ -91,17 +98,34 @@ func (o *ObjectSet) add(obj runtime.Object) {
return return
} }
gvk, err := o.objects.Add(obj) gvk := obj.GetObjectKind().GroupVersionKind()
metadata, err := meta.Accessor(obj)
if err != nil { if err != nil {
o.err(fmt.Errorf("failed to add %v", obj)) o.err(fmt.Errorf("failed to get metadata for %s", gvk))
return return
} }
o.order = append(o.order, obj) name := metadata.GetName()
if !o.gvkSeen[gvk] { if name == "" {
o.gvkSeen[gvk] = true o.err(fmt.Errorf("%s is missing name", gvk))
o.gvkOrder = append(o.gvkOrder, gvk) return
}
namespace := metadata.GetNamespace()
nsed, ok := o.nsed[gvk]
if ok && nsed != (namespace != "") {
o.err(fmt.Errorf("got %s objects that are both namespaced and not namespaced", gvk))
return
} }
o.nsed[gvk] = namespace != ""
if err := o.objects.Add(obj); err != nil {
o.err(fmt.Errorf("failed to get metadata for %s", gvk))
return
}
o.order = append(o.order, obj)
} }
func (o *ObjectSet) err(err error) error { func (o *ObjectSet) err(err error) error {
@ -122,12 +146,25 @@ func (o *ObjectSet) Len() int {
} }
func (o *ObjectSet) GVKOrder(known ...schema.GroupVersionKind) []schema.GroupVersionKind { func (o *ObjectSet) GVKOrder(known ...schema.GroupVersionKind) []schema.GroupVersionKind {
seen := map[schema.GroupVersionKind]bool{}
var gvkOrder []schema.GroupVersionKind
for _, obj := range o.order {
if seen[obj.GetObjectKind().GroupVersionKind()] {
continue
}
seen[obj.GetObjectKind().GroupVersionKind()] = true
gvkOrder = append(gvkOrder, obj.GetObjectKind().GroupVersionKind())
}
var rest []schema.GroupVersionKind var rest []schema.GroupVersionKind
for _, gvk := range known { for _, gvk := range known {
if o.gvkSeen[gvk] { if seen[gvk] {
continue continue
} }
seen[gvk] = true
rest = append(rest, gvk) rest = append(rest, gvk)
} }
@ -135,5 +172,5 @@ func (o *ObjectSet) GVKOrder(known ...schema.GroupVersionKind) []schema.GroupVer
return rest[i].String() < rest[j].String() return rest[i].String() < rest[j].String()
}) })
return append(o.gvkOrder, rest...) return append(gvkOrder, rest...)
} }

7
vendor/github.com/rancher/wrangler/pkg/schemes/all.go generated vendored

@ -1,7 +0,0 @@
package schemes
import (
"k8s.io/apimachinery/pkg/runtime"
)
var All = runtime.NewScheme()
Loading…
Cancel
Save