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

Update v2 #317

Merged
merged 4 commits into from
Sep 6, 2023
Merged
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
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ platform:

steps:
- name: test
image: registry.suse.com/bci/golang:1.19
image: registry.suse.com/bci/golang:1.20
commands:
- go install github.com/golang/mock/[email protected]
- ./scripts/ci
Expand All @@ -28,7 +28,7 @@ platform:

steps:
- name: test
image: registry.suse.com/bci/golang:1.19
image: registry.suse.com/bci/golang:1.20
commands:
- go install github.com/golang/mock/[email protected]
- ./scripts/ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: golangci-lint

env:
SETUP_GO_VERSION: '^1.19'
SETUP_GO_VERSION: '^1.20'

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ import (
"context"

"github.com/rancher/rancher/pkg/generated/controllers/management.cattle.io"
"github.com/rancher/wrangler/pkg/generated/controllers/core"
"github.com/rancher/wrangler/v2/pkg/generated/controllers/core"
"k8s.io/client-go/rest"
)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rancher/wrangler
module github.com/rancher/wrangler/v2

go 1.19
go 1.20

require (
github.com/evanphx/json-patch v5.6.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions pkg/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"sync"

"github.com/rancher/wrangler/pkg/apply/injectors"
"github.com/rancher/wrangler/pkg/objectset"
"github.com/rancher/wrangler/v2/pkg/apply/injectors"
"github.com/rancher/wrangler/v2/pkg/objectset"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
Expand Down
8 changes: 4 additions & 4 deletions pkg/apply/desiredset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package apply
import (
"context"

"github.com/rancher/wrangler/pkg/apply/injectors"
"github.com/rancher/wrangler/pkg/kv"
"github.com/rancher/wrangler/pkg/merr"
"github.com/rancher/wrangler/pkg/objectset"
"github.com/rancher/wrangler/v2/pkg/apply/injectors"
"github.com/rancher/wrangler/v2/pkg/kv"
"github.com/rancher/wrangler/v2/pkg/merr"
"github.com/rancher/wrangler/v2/pkg/objectset"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
6 changes: 3 additions & 3 deletions pkg/apply/desiredset_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

"github.com/sirupsen/logrus"

gvk2 "github.com/rancher/wrangler/pkg/gvk"
gvk2 "github.com/rancher/wrangler/v2/pkg/gvk"

"github.com/pkg/errors"
"github.com/rancher/wrangler/pkg/apply/injectors"
"github.com/rancher/wrangler/pkg/objectset"
"github.com/rancher/wrangler/v2/pkg/apply/injectors"
"github.com/rancher/wrangler/v2/pkg/objectset"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down
8 changes: 4 additions & 4 deletions pkg/apply/desiredset_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

jsonpatch "github.com/evanphx/json-patch"
"github.com/pkg/errors"
data2 "github.com/rancher/wrangler/pkg/data"
"github.com/rancher/wrangler/pkg/data/convert"
"github.com/rancher/wrangler/pkg/objectset"
patch2 "github.com/rancher/wrangler/pkg/patch"
data2 "github.com/rancher/wrangler/v2/pkg/data"
"github.com/rancher/wrangler/v2/pkg/data/convert"
"github.com/rancher/wrangler/v2/pkg/objectset"
patch2 "github.com/rancher/wrangler/v2/pkg/patch"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/api/meta"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
6 changes: 3 additions & 3 deletions pkg/apply/desiredset_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"fmt"
"strings"

"github.com/rancher/wrangler/pkg/gvk"
"github.com/rancher/wrangler/v2/pkg/gvk"

"github.com/rancher/wrangler/pkg/kv"
"github.com/rancher/wrangler/v2/pkg/kv"

"github.com/pkg/errors"
namer "github.com/rancher/wrangler/pkg/name"
namer "github.com/rancher/wrangler/v2/pkg/name"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
6 changes: 3 additions & 3 deletions pkg/apply/desiredset_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"sync"

"github.com/pkg/errors"
gvk2 "github.com/rancher/wrangler/pkg/gvk"
"github.com/rancher/wrangler/pkg/merr"
"github.com/rancher/wrangler/pkg/objectset"
gvk2 "github.com/rancher/wrangler/v2/pkg/gvk"
"github.com/rancher/wrangler/v2/pkg/merr"
"github.com/rancher/wrangler/v2/pkg/objectset"
"github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
errors2 "k8s.io/apimachinery/pkg/api/errors"
Expand Down
6 changes: 3 additions & 3 deletions pkg/apply/fake/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package fake
import (
"context"

"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/apply/injectors"
"github.com/rancher/wrangler/pkg/objectset"
"github.com/rancher/wrangler/v2/pkg/apply"
"github.com/rancher/wrangler/v2/pkg/apply/injectors"
"github.com/rancher/wrangler/v2/pkg/objectset"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
Expand Down
34 changes: 17 additions & 17 deletions pkg/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import (

"github.com/rancher/lasso/pkg/controller"
"github.com/rancher/lasso/pkg/dynamic"
"github.com/rancher/wrangler/pkg/apply"
admissionreg "github.com/rancher/wrangler/pkg/generated/controllers/admissionregistration.k8s.io"
admissionregcontrollers "github.com/rancher/wrangler/pkg/generated/controllers/admissionregistration.k8s.io/v1"
"github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io"
crdcontrollers "github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io/v1"
"github.com/rancher/wrangler/pkg/generated/controllers/apiregistration.k8s.io"
apicontrollers "github.com/rancher/wrangler/pkg/generated/controllers/apiregistration.k8s.io/v1"
"github.com/rancher/wrangler/pkg/generated/controllers/apps"
appcontrollers "github.com/rancher/wrangler/pkg/generated/controllers/apps/v1"
"github.com/rancher/wrangler/pkg/generated/controllers/batch"
batchcontrollers "github.com/rancher/wrangler/pkg/generated/controllers/batch/v1"
"github.com/rancher/wrangler/pkg/generated/controllers/core"
corecontrollers "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
"github.com/rancher/wrangler/pkg/generated/controllers/rbac"
rbaccontrollers "github.com/rancher/wrangler/pkg/generated/controllers/rbac/v1"
"github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/pkg/ratelimit"
"github.com/rancher/wrangler/v2/pkg/apply"
admissionreg "github.com/rancher/wrangler/v2/pkg/generated/controllers/admissionregistration.k8s.io"
admissionregcontrollers "github.com/rancher/wrangler/v2/pkg/generated/controllers/admissionregistration.k8s.io/v1"
"github.com/rancher/wrangler/v2/pkg/generated/controllers/apiextensions.k8s.io"
crdcontrollers "github.com/rancher/wrangler/v2/pkg/generated/controllers/apiextensions.k8s.io/v1"
"github.com/rancher/wrangler/v2/pkg/generated/controllers/apiregistration.k8s.io"
apicontrollers "github.com/rancher/wrangler/v2/pkg/generated/controllers/apiregistration.k8s.io/v1"
"github.com/rancher/wrangler/v2/pkg/generated/controllers/apps"
appcontrollers "github.com/rancher/wrangler/v2/pkg/generated/controllers/apps/v1"
"github.com/rancher/wrangler/v2/pkg/generated/controllers/batch"
batchcontrollers "github.com/rancher/wrangler/v2/pkg/generated/controllers/batch/v1"
"github.com/rancher/wrangler/v2/pkg/generated/controllers/core"
corecontrollers "github.com/rancher/wrangler/v2/pkg/generated/controllers/core/v1"
"github.com/rancher/wrangler/v2/pkg/generated/controllers/rbac"
rbaccontrollers "github.com/rancher/wrangler/v2/pkg/generated/controllers/rbac/v1"
"github.com/rancher/wrangler/v2/pkg/generic"
"github.com/rancher/wrangler/v2/pkg/ratelimit"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/client-go/discovery"
"k8s.io/client-go/discovery/cached/memory"
Expand Down
5 changes: 3 additions & 2 deletions pkg/codegen/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
controllergen "github.com/rancher/wrangler/pkg/controller-gen"
"github.com/rancher/wrangler/pkg/controller-gen/args"
controllergen "github.com/rancher/wrangler/v2/pkg/controller-gen"
"github.com/rancher/wrangler/v2/pkg/controller-gen/args"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
Expand All @@ -19,6 +19,7 @@ import (

func main() {
controllergen.Run(args.Options{
ImportPackage: "github.com/rancher/wrangler/v2/pkg/generated",
OutputPackage: "github.com/rancher/wrangler/pkg/generated",
mattfarina marked this conversation as resolved.
Show resolved Hide resolved
Boilerplate: "scripts/boilerplate.go.txt",
Groups: map[string]args.Group{
Expand Down
2 changes: 1 addition & 1 deletion pkg/condition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"time"

"github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/v2/pkg/generic"
"github.com/sirupsen/logrus"
)

Expand Down
12 changes: 8 additions & 4 deletions pkg/controller-gen/args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import (
)

type CustomArgs struct {
Package string
TypesByGroup map[schema.GroupVersion][]*types.Name
Options Options
OutputBase string
// Package is the directory path where generated code output will be located
Package string
ImportPackage string
TypesByGroup map[schema.GroupVersion][]*types.Name
Options Options
OutputBase string
}

type Options struct {
ImportPackage string
// OutputPackage is the directory path where generated code output will be located
OutputPackage string
Groups map[string]Group
Boilerplate string
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller-gen/generators/client_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"path/filepath"
"strings"

args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
args2 "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller-gen/generators/factory_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"io"

args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
args2 "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
)
Expand Down
8 changes: 6 additions & 2 deletions pkg/controller-gen/generators/group_interface_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"io"

args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
args2 "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
"k8s.io/gengo/namer"
Expand Down Expand Up @@ -37,7 +37,11 @@ func (f *interfaceGo) Imports(context *generator.Context) []string {
if gv.Group != f.group {
continue
}
packages = append(packages, fmt.Sprintf("%s \"%s/controllers/%s/%s\"", gv.Version, f.customArgs.Package,
pkg := f.customArgs.ImportPackage
if pkg == "" {
pkg = f.customArgs.Package
}
packages = append(packages, fmt.Sprintf("%s \"%s/controllers/%s/%s\"", gv.Version, pkg,
groupPackageName(gv.Group, f.customArgs.Options.Groups[gv.Group].OutputControllerPackageName), gv.Version))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"strings"

args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
args2 "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller-gen/generators/list_type_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package generators
import (
"io"

args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
args2 "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller-gen/generators/register_group_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package generators
import (
"fmt"

args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
args2 "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller-gen/generators/register_group_version_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"io"
"strings"

args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
"github.com/rancher/wrangler/pkg/name"
args2 "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"github.com/rancher/wrangler/v2/pkg/name"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller-gen/generators/type_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"strings"

args2 "github.com/rancher/wrangler/pkg/controller-gen/args"
args2 "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller-gen/generators/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ var (
"context",
"time",
"k8s.io/client-go/rest",
"github.com/rancher/wrangler/pkg/apply",
"github.com/rancher/wrangler/v2/pkg/apply",
"github.com/rancher/lasso/pkg/controller",
"github.com/rancher/wrangler/pkg/condition",
"github.com/rancher/wrangler/pkg/schemes",
"github.com/rancher/wrangler/pkg/generic",
"github.com/rancher/wrangler/pkg/kv",
"github.com/rancher/wrangler/v2/pkg/condition",
"github.com/rancher/wrangler/v2/pkg/schemes",
"github.com/rancher/wrangler/v2/pkg/generic",
"github.com/rancher/wrangler/v2/pkg/kv",
"k8s.io/apimachinery/pkg/api/equality",
"k8s.io/apimachinery/pkg/api/errors",
"metav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"",
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"k8s.io/gengo/generator"

cgargs "github.com/rancher/wrangler/pkg/controller-gen/args"
"github.com/rancher/wrangler/pkg/controller-gen/generators"
cgargs "github.com/rancher/wrangler/v2/pkg/controller-gen/args"
"github.com/rancher/wrangler/v2/pkg/controller-gen/generators"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/runtime/schema"
csargs "k8s.io/code-generator/cmd/client-gen/args"
Expand All @@ -30,11 +30,11 @@ import (

func Run(opts cgargs.Options) {
customArgs := &cgargs.CustomArgs{
Options: opts,
TypesByGroup: map[schema.GroupVersion][]*types.Name{},
Package: opts.OutputPackage,
ImportPackage: opts.ImportPackage,
Options: opts,
TypesByGroup: map[schema.GroupVersion][]*types.Name{},
Package: opts.OutputPackage,
}

genericArgs := args.Default().WithoutDefaultFlagParsing()
genericArgs.CustomArgs = customArgs
genericArgs.GoHeaderFilePath = opts.Boilerplate
Expand Down
12 changes: 6 additions & 6 deletions pkg/crd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"sync"
"time"

"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/data/convert"
"github.com/rancher/wrangler/pkg/kv"
"github.com/rancher/wrangler/pkg/name"
"github.com/rancher/wrangler/pkg/schemas/openapi"
"github.com/rancher/wrangler/v2/pkg/apply"
"github.com/rancher/wrangler/v2/pkg/data/convert"
"github.com/rancher/wrangler/v2/pkg/kv"
"github.com/rancher/wrangler/v2/pkg/name"
"github.com/rancher/wrangler/v2/pkg/schemas/openapi"
"github.com/sirupsen/logrus"
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand All @@ -30,7 +30,7 @@ import (
"k8s.io/client-go/rest"

// Ensure the gvks are loaded so that apply works correctly
_ "github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io/v1"
_ "github.com/rancher/wrangler/v2/pkg/generated/controllers/apiextensions.k8s.io/v1"
)

const CRDKind = "CustomResourceDefinition"
Expand Down
Loading
Loading