Skip to content

Commit

Permalink
feat: upgrade kb from 9c02d557f01b-to-c158f4fa4207
Browse files Browse the repository at this point in the history
  • Loading branch information
Camila Macedo committed Nov 13, 2020
1 parent ddc3cdc commit 46df250
Show file tree
Hide file tree
Showing 127 changed files with 270 additions and 258 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
(go/v2) Fix `create api` when only the controller is created.
More info: https://github.com/kubernetes-sigs/kubebuilder/pull/1770
kind: "bugfix"
breaking: false
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
rsc.io/letsencrypt v0.0.3 // indirect
sigs.k8s.io/controller-runtime v0.6.3
sigs.k8s.io/controller-tools v0.3.0
sigs.k8s.io/kubebuilder v1.0.9-0.20201030182622-9c02d557f01b
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201111001842-c158f4fa4207
sigs.k8s.io/yaml v1.2.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,8 @@ sigs.k8s.io/controller-runtime v0.6.3 h1:SBbr+inLPEKhvlJtrvDcwIpm+uhDvp63Bl72xYJ
sigs.k8s.io/controller-runtime v0.6.3/go.mod h1:WlZNXcM0++oyaQt4B7C2lEE5JYRs8vJUzRP4N4JpdAY=
sigs.k8s.io/controller-tools v0.3.0 h1:y3YD99XOyWaXkiF1kd41uRvfp/64teWcrEZFuHxPhJ4=
sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI=
sigs.k8s.io/kubebuilder v1.0.9-0.20201030182622-9c02d557f01b h1:IDxyhHz2vQ5DRRp0azVMPC5rtSWz3ziFDWWnjC+TH5Q=
sigs.k8s.io/kubebuilder v1.0.9-0.20201030182622-9c02d557f01b/go.mod h1:NatUhFMh/ci8gR+qETvZBIlZ4RTQoNa+9uei7okpgcY=
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201111001842-c158f4fa4207 h1:JtlaBrtWymJbh6ea+TJUZkzBb0x0dMKV+P0+ZPaldxk=
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201111001842-c158f4fa4207/go.mod h1:J/D/179LBZhQOhRvmMRNbje/Bk+PjbN0/fzUupmO7+U=
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
Expand Down
2 changes: 1 addition & 1 deletion hack/generate/samples/internal/ansible/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strings"

log "github.com/sirupsen/logrus"
kbtestutils "sigs.k8s.io/kubebuilder/test/e2e/utils"
kbtestutils "sigs.k8s.io/kubebuilder/v2/test/e2e/utils"

"github.com/operator-framework/operator-sdk/hack/generate/samples/internal/pkg"
"github.com/operator-framework/operator-sdk/internal/testutils"
Expand Down
2 changes: 1 addition & 1 deletion hack/generate/samples/internal/ansible/molecule.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"path/filepath"
"strings"

kbtestutils "sigs.k8s.io/kubebuilder/test/e2e/utils"
kbtestutils "sigs.k8s.io/kubebuilder/v2/test/e2e/utils"

"github.com/operator-framework/operator-sdk/hack/generate/samples/internal/pkg"
"github.com/operator-framework/operator-sdk/internal/testutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"

log "github.com/sirupsen/logrus"
kbtestutils "sigs.k8s.io/kubebuilder/test/e2e/utils"
kbtestutils "sigs.k8s.io/kubebuilder/v2/test/e2e/utils"

"github.com/operator-framework/operator-sdk/hack/generate/samples/internal/pkg"
"github.com/operator-framework/operator-sdk/internal/testutils"
Expand Down
2 changes: 1 addition & 1 deletion hack/generate/samples/internal/pkg/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"regexp"

log "github.com/sirupsen/logrus"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"

"github.com/operator-framework/operator-sdk/internal/annotations/metrics"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/annotations/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"regexp"
"strings"

"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"

sdkversion "github.com/operator-framework/operator-sdk/internal/version"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/operator-sdk/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"sigs.k8s.io/kubebuilder/pkg/cli"
"sigs.k8s.io/kubebuilder/v2/pkg/cli"
)

var commands = []*cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/operator-sdk/generate/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/operator-framework/api/pkg/apis/scorecard/v1alpha3"
"github.com/operator-framework/operator-registry/pkg/lib/bundle"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"
"sigs.k8s.io/yaml"

metricsannotations "github.com/operator-framework/operator-sdk/internal/annotations/metrics"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/operator-sdk/generate/internal/genutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apimachinery/pkg/util/validation"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"
"sigs.k8s.io/yaml"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/operator-sdk/generate/kustomize/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"

genutil "github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/generate/internal"
gencsv "github.com/operator-framework/operator-sdk/internal/generate/clusterserviceversion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"os"
"path/filepath"

"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"

genutil "github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/generate/internal"
gencsv "github.com/operator-framework/operator-sdk/internal/generate/clusterserviceversion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/operator-framework/operator-registry/pkg/lib/bundle"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"

metricsannotations "github.com/operator-framework/operator-sdk/internal/annotations/metrics"
"github.com/operator-framework/operator-sdk/internal/generate/clusterserviceversion/bases"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/operator-framework/operator-registry/pkg/lib/bundle"
appsv1 "k8s.io/api/apps/v1"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"
"sigs.k8s.io/yaml"

metricsannotations "github.com/operator-framework/operator-sdk/internal/annotations/metrics"
Expand Down
2 changes: 1 addition & 1 deletion internal/kubebuilder/cmdutil/cmdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

package cmdutil

import "sigs.k8s.io/kubebuilder/pkg/plugin/scaffold"
import "sigs.k8s.io/kubebuilder/v2/pkg/plugin/scaffold"

// RunOptions represent the types used to implement the different commands
type RunOptions interface {
Expand Down
2 changes: 1 addition & 1 deletion internal/kubebuilder/machinery/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"errors"
"fmt"

"sigs.k8s.io/kubebuilder/pkg/model/file"
"sigs.k8s.io/kubebuilder/v2/pkg/model/file"
)

// This file contains the errors returned by the scaffolding machinery
Expand Down
4 changes: 2 additions & 2 deletions internal/kubebuilder/machinery/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"text/template"

"golang.org/x/tools/imports"
"sigs.k8s.io/kubebuilder/pkg/model"
"sigs.k8s.io/kubebuilder/pkg/model/file"
"sigs.k8s.io/kubebuilder/v2/pkg/model"
"sigs.k8s.io/kubebuilder/v2/pkg/model/file"

"github.com/operator-framework/operator-sdk/internal/kubebuilder/filesystem"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/kubebuilder/machinery/scaffold_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
"sigs.k8s.io/kubebuilder/pkg/model"
"sigs.k8s.io/kubebuilder/pkg/model/file"
"sigs.k8s.io/kubebuilder/v2/pkg/model"
"sigs.k8s.io/kubebuilder/v2/pkg/model/file"

"github.com/operator-framework/operator-sdk/internal/kubebuilder/filesystem"
)
Expand Down
30 changes: 15 additions & 15 deletions internal/plugins/ansible/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (
"strings"

"github.com/spf13/pflag"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/pkg/model/resource"
"sigs.k8s.io/kubebuilder/pkg/plugin"
"sigs.k8s.io/kubebuilder/pkg/plugin/scaffold"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/model/resource"
"sigs.k8s.io/kubebuilder/v2/pkg/plugin"
"sigs.k8s.io/kubebuilder/v2/pkg/plugin/scaffold"

"github.com/operator-framework/operator-sdk/internal/kubebuilder/cmdutil"
"github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds"
Expand All @@ -39,18 +39,18 @@ const (
crdVersionV1beta1 = "v1beta1"
)

type createAPIPlugin struct {
type createAPIPSubcommand struct {
config *config.Config
createOptions scaffolds.CreateOptions
}

var (
_ plugin.CreateAPI = &createAPIPlugin{}
_ cmdutil.RunOptions = &createAPIPlugin{}
_ plugin.CreateAPISubcommand = &createAPIPSubcommand{}
_ cmdutil.RunOptions = &createAPIPSubcommand{}
)

// UpdateContext injects documentation for the command
func (p *createAPIPlugin) UpdateContext(ctx *plugin.Context) {
func (p *createAPIPSubcommand) UpdateContext(ctx *plugin.Context) {
ctx.Description = `Scaffold a Kubernetes API in which the controller is an Ansible role or playbook.
- generates a Custom Resource Definition and sample
Expand Down Expand Up @@ -89,7 +89,7 @@ func (p *createAPIPlugin) UpdateContext(ctx *plugin.Context) {
)
}

func (p *createAPIPlugin) BindFlags(fs *pflag.FlagSet) {
func (p *createAPIPSubcommand) BindFlags(fs *pflag.FlagSet) {
fs.SortFlags = false

fs.StringVar(&p.createOptions.GVK.Group, groupFlag, "", "resource group")
Expand All @@ -100,11 +100,11 @@ func (p *createAPIPlugin) BindFlags(fs *pflag.FlagSet) {
fs.BoolVarP(&p.createOptions.GenerateRole, "generate-role", "", false, "Generate an Ansible role skeleton.")
}

func (p *createAPIPlugin) InjectConfig(c *config.Config) {
func (p *createAPIPSubcommand) InjectConfig(c *config.Config) {
p.config = c
}

func (p *createAPIPlugin) Run() error {
func (p *createAPIPSubcommand) Run() error {
if err := cmdutil.Run(p); err != nil {
return err
}
Expand All @@ -118,12 +118,12 @@ func (p *createAPIPlugin) Run() error {
}

// SDK phase 2 plugins.
func (p *createAPIPlugin) runPhase2() error {
func (p *createAPIPSubcommand) runPhase2() error {
gvk := p.createOptions.GVK
return manifests.RunCreateAPI(p.config, config.GVK{Group: gvk.Group, Version: gvk.Version, Kind: gvk.Kind})
}

func (p *createAPIPlugin) Validate() error {
func (p *createAPIPSubcommand) Validate() error {
if p.createOptions.CRDVersion != crdVersionV1 && p.createOptions.CRDVersion != crdVersionV1beta1 {
return fmt.Errorf("value of --%s must be either %q or %q", crdVersionFlag, crdVersionV1, crdVersionV1beta1)
}
Expand Down Expand Up @@ -152,10 +152,10 @@ func (p *createAPIPlugin) Validate() error {
return nil
}

func (p *createAPIPlugin) GetScaffolder() (scaffold.Scaffolder, error) {
func (p *createAPIPSubcommand) GetScaffolder() (scaffold.Scaffolder, error) {
return scaffolds.NewCreateAPIScaffolder(p.config, p.createOptions), nil
}

func (p *createAPIPlugin) PostScaffold() error {
func (p *createAPIPSubcommand) PostScaffold() error {
return nil
}
30 changes: 15 additions & 15 deletions internal/plugins/ansible/v1/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ import (

"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/validation"
"sigs.k8s.io/kubebuilder/pkg/model/config"
"sigs.k8s.io/kubebuilder/pkg/plugin"
"sigs.k8s.io/kubebuilder/pkg/plugin/scaffold"
"sigs.k8s.io/kubebuilder/v2/pkg/model/config"
"sigs.k8s.io/kubebuilder/v2/pkg/plugin"
"sigs.k8s.io/kubebuilder/v2/pkg/plugin/scaffold"

"github.com/operator-framework/operator-sdk/internal/kubebuilder/cmdutil"
"github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds"
"github.com/operator-framework/operator-sdk/internal/plugins/manifests"
"github.com/operator-framework/operator-sdk/internal/plugins/scorecard"
)

type initPlugin struct {
type initSubcommand struct {
config *config.Config
apiPlugin createAPIPlugin
apiPlugin createAPIPSubcommand

// If true, run the `create api` plugin.
doCreateAPI bool
Expand All @@ -44,12 +44,12 @@ type initPlugin struct {
}

var (
_ plugin.Init = &initPlugin{}
_ cmdutil.RunOptions = &initPlugin{}
_ plugin.InitSubcommand = &initSubcommand{}
_ cmdutil.RunOptions = &initSubcommand{}
)

// UpdateContext injects documentation for the command
func (p *initPlugin) UpdateContext(ctx *plugin.Context) {
func (p *initSubcommand) UpdateContext(ctx *plugin.Context) {
ctx.Description = `
Initialize a new Ansible-based operator project.
Expand Down Expand Up @@ -95,20 +95,20 @@ Optionally creates a new API, using the same flags as "create api"
p.commandName = ctx.CommandName
}

func (p *initPlugin) BindFlags(fs *pflag.FlagSet) {
func (p *initSubcommand) BindFlags(fs *pflag.FlagSet) {
fs.SortFlags = false
fs.StringVar(&p.config.Domain, "domain", "my.domain", "domain for groups")
fs.StringVar(&p.config.ProjectName, "project-name", "", "name of this project, the default being directory name")
p.apiPlugin.BindFlags(fs)
}

func (p *initPlugin) InjectConfig(c *config.Config) {
func (p *initSubcommand) InjectConfig(c *config.Config) {
c.Layout = pluginKey
p.config = c
p.apiPlugin.config = p.config
}

func (p *initPlugin) Run() error {
func (p *initSubcommand) Run() error {
if err := cmdutil.Run(p); err != nil {
return err
}
Expand All @@ -122,7 +122,7 @@ func (p *initPlugin) Run() error {
}

// SDK phase 2 plugins.
func (p *initPlugin) runPhase2() error {
func (p *initSubcommand) runPhase2() error {
if err := manifests.RunInit(p.config); err != nil {
return err
}
Expand All @@ -139,7 +139,7 @@ func (p *initPlugin) runPhase2() error {
return nil
}

func (p *initPlugin) Validate() error {
func (p *initSubcommand) Validate() error {
// Check if the project name is a valid k8s namespace (DNS 1123 label).
if p.config.ProjectName == "" {
dir, err := os.Getwd()
Expand All @@ -160,7 +160,7 @@ func (p *initPlugin) Validate() error {
return nil
}

func (p *initPlugin) GetScaffolder() (scaffold.Scaffolder, error) {
func (p *initSubcommand) GetScaffolder() (scaffold.Scaffolder, error) {
var (
apiScaffolder scaffold.Scaffolder
err error
Expand All @@ -174,7 +174,7 @@ func (p *initPlugin) GetScaffolder() (scaffold.Scaffolder, error) {
return scaffolds.NewInitScaffolder(p.config, apiScaffolder), nil
}

func (p *initPlugin) PostScaffold() error {
func (p *initSubcommand) PostScaffold() error {
if !p.doCreateAPI {
fmt.Printf("Next: define a resource with:\n$ %s create api\n", p.commandName)
}
Expand Down

0 comments on commit 46df250

Please sign in to comment.