Skip to content

Commit

Permalink
feat: upgrade kb from 9c02d557f01b-to-b6a0bf1b6040
Browse files Browse the repository at this point in the history
  • Loading branch information
Camila Macedo committed Nov 10, 2020
1 parent d50d944 commit 3acf514
Show file tree
Hide file tree
Showing 130 changed files with 302 additions and 342 deletions.

This file was deleted.

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.20201109173827-b6a0bf1b6040
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 @@ -1218,8 +1218,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.20201109173827-b6a0bf1b6040 h1:KnyrRNbDvCTW5PBWI8HzW67Z/04sQHAgS3+3VFYFlBI=
sigs.k8s.io/kubebuilder/v2 v2.3.2-0.20201109173827-b6a0bf1b6040/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
26 changes: 1 addition & 25 deletions 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 Expand Up @@ -83,33 +83,9 @@ func GetPluginsCLIAndRoot() (cli.CLI, *cobra.Command) {
}
root.PersistentPreRun = rootPersistentPreRun

// Hidden commands which are based operator type
hiddenCommands(root)

return c, root
}

// hiddenCommands will hidden commands based on the operator type
func hiddenCommands(root *cobra.Command) {
if !isGoOperator() {
for _, cmd := range root.Commands() {
// The edit command is valid only for Go based- operators
if cmd.Name() == "edit" {
cmd.Hidden = true
}
}
}
}

// isGoOperator returns true when the cli is called from a Go operator
func isGoOperator() bool {
cfg, err := projutil.ReadConfig()
if err == nil && cfg != nil {
return projutil.PluginKeyToOperatorType(cfg.Layout) == projutil.OperatorTypeGo
}
return false
}

func rootPersistentPreRun(cmd *cobra.Command, args []string) {
if viper.GetBool(flags.VerboseOpt) {
if err := projutil.SetGoVerbose(); err != nil {
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
}

0 comments on commit 3acf514

Please sign in to comment.