Skip to content
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 .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.21
- name: Set up Go 1.24
uses: actions/setup-go@v2
with:
go-version: 1.21
go-version: 1.24

- name: Check out source code
uses: actions/checkout@v2
Expand Down
128 changes: 128 additions & 0 deletions cmd/convert/convert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package convert

import (
"github.com/konveyor/crane-lib/convert"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"

buildv1 "github.com/openshift/api/build/v1"
imagev1 "github.com/openshift/api/image/v1"
)

type ConvertOptions struct {
configFlags *genericclioptions.ConfigFlags
genericclioptions.IOStreams
SourceContext string
Namespace string
logger logrus.FieldLogger
ResourceType string
SearchRegistries []string
InsecureRegistries []string
BlockRegistries []string
exportDir string
}

func NewConvertOptions(streams genericclioptions.IOStreams) *cobra.Command {
t := &ConvertOptions{
configFlags: genericclioptions.NewConfigFlags(false),

IOStreams: streams,
logger: logrus.New(),
}

cmd := &cobra.Command{
Use: "convert",
Short: "Convert a deprecated resource to its replacement",
RunE: func(c *cobra.Command, args []string) error {
if err := t.Complete(c, args); err != nil {
return err
}
// if err := t.Validate(); err != nil {
// return err
// }
if err := t.Run(); err != nil {
return err
}

return nil
},
}
addFlagsForConvertOptions(t, cmd)

return cmd
}

func addFlagsForConvertOptions(t *ConvertOptions, cmd *cobra.Command) {
cmd.Flags().StringVar(&t.SourceContext, "source-context", "", "The source context in current kubeconfig")
cmd.Flags().StringVarP(&t.Namespace, "namespace", "n", "", "The namespace to convert resources from")
cmd.Flags().StringVarP(&t.ResourceType, "resource", "r", "", "The deprecated plural resource type to convert, e.g. BuildConfigs")
cmd.Flags().StringSliceVarP(&t.SearchRegistries, "search-registries", "s", []string{}, "List of search registries")
cmd.Flags().StringSliceVar(&t.InsecureRegistries, "insecure-registries", []string{}, "List of search registries")
cmd.Flags().StringSliceVar(&t.BlockRegistries, "block-registries", []string{}, "List of search registries")
cmd.Flags().StringVarP(&t.exportDir, "export-dir", "e", "convert", "The path where files are to be exported")
}

func (t *ConvertOptions) Complete(c *cobra.Command, args []string) error {
return nil
}

func (t *ConvertOptions) Run() error {
return t.run()
}

func (t *ConvertOptions) run() error {
srcClient, err := t.getClientFromContext()
if err != nil {
return err
}

convertOptions := convert.ConvertOptions{
Client: srcClient,
Namespace: t.Namespace,
ResourceType: t.ResourceType,
SearchRegistries: t.SearchRegistries,
InsecureRegistries: t.InsecureRegistries,
BlockRegistries: t.BlockRegistries,
ExportDir: t.exportDir,
}

err = convertOptions.Convert()
if err != nil {
return err
}

return nil
}

func (t *ConvertOptions) getClientFromContext() (client.Client, error) {
err := buildv1.Install(scheme.Scheme)
if err != nil {
return nil, err
}

err = imagev1.Install(scheme.Scheme)
if err != nil {
return nil, err
}

restConfig, err := t.getRestConfigFromContext(t.SourceContext)
if err != nil {
return nil, err
}

restConfig.Burst = 1000
restConfig.QPS = 100

return client.New(restConfig, client.Options{Scheme: scheme.Scheme})
}

func (t *ConvertOptions) getRestConfigFromContext(ctx string) (*rest.Config, error) {
c := ctx
t.configFlags.Context = &c

return t.configFlags.ToRESTConfig()
}
10 changes: 5 additions & 5 deletions cmd/plugin-manager/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func NewAddCommand(f *flags.GlobalFlags) *cobra.Command {
return err
}
if err := o.Validate(args); err != nil {
log.Errorf(fmt.Sprintf("%s", err.Error()))
log.Errorf("%s", err.Error())
return nil
}
if err := o.Run(args); err != nil {
Expand Down Expand Up @@ -145,7 +145,7 @@ func (o *Options) run(args []string) error {
case len(manifestMap) > 1:
// if the plugin is found across multiple repository then fail and ask for a specific repo
// TODO: if the version is mentioned look for a plugin with the same version, if found in only one repo add the same else fail and ask for the repo
log.Errorf(fmt.Sprintf("The plugin %s is found across multiple repos, please specify one repo with --repo flag", args[0]))
log.Errorf("The plugin %s is found across multiple repos, please specify one repo with --repo flag", args[0])
case len(manifestMap) == 1:
// the plugin is found in only one repo
for _, pluginsMap := range manifestMap {
Expand All @@ -157,7 +157,7 @@ func (o *Options) run(args []string) error {
if value.Name != "" && (o.Version == "" || string(value.Version) == o.Version) {
return downloadBinary(o.PluginDir, value.Name, value.Binaries[0].URI, log)
} else {
log.Errorf(fmt.Sprintf("The version %s of plugin %s is not available", installVersion, value.Name))
log.Errorf("The version %s of plugin %s is not available", installVersion, value.Name)
fmt.Printf("Run \"crane plugin-manager list --name %s --params\" to see available versions along with additional information \n", args[0])
}
}
Expand All @@ -176,11 +176,11 @@ func (o *Options) run(args []string) error {
return downloadBinary(o.PluginDir, value.Name, value.Binaries[0].URI, log)
}
}
log.Errorf(fmt.Sprintf("The %s version of the plugin %s is not found", installVersion, args[0]))
log.Errorf("The %s version of the plugin %s is not found", installVersion, args[0])
fmt.Printf("Run \"crane plugin-manager list --name %s --params\" to see available versions along with additional information \n", args[0])
default:
// throw error saying that the plugin doest exists
log.Errorf(fmt.Sprintf("The plugin %s is not found", args[0]))
log.Errorf("The plugin %s is not found", args[0])
fmt.Println(fmt.Sprintf("Run \"crane plugin-manager list\" to list all the available plugins \n"))
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/plugin-manager/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (o *Options) run() error {
}
}
} else {
log.Errorf(fmt.Sprintf("name flag must be used with wither params or versions"))
log.Errorf("name flag must be used with wither params or versions")
}
} else {
manifestMap, err := plugin.BuildManifestMap(log, "", o.Repo)
Expand Down
2 changes: 1 addition & 1 deletion cmd/plugin-manager/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (o *Options) run(args []string) error {
fmt.Printf("%s \n", path)
}
} else if len(paths) == 0 {
log.Errorf(fmt.Sprintf("Plugin %s not found in the plugin dir %s", args[0], pluginDir))
log.Errorf("Plugin %s not found in the plugin dir %s", args[0], pluginDir)
fmt.Printf("Run \"crane plugin-manager list --installed -p %s\" to see the list of installed plugins \n", pluginDir)
} else {
err = os.Remove(paths[0])
Expand Down
117 changes: 61 additions & 56 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,68 +1,67 @@
module github.com/konveyor/crane

go 1.23.0
go 1.24.0

toolchain go1.24.2
toolchain go1.24.4

require (
github.com/backube/pvc-transfer v0.0.0-20220718185428-1d2440958552
github.com/bombsimon/logrusr/v3 v3.0.0
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v1.2.3
github.com/go-logr/logr v1.4.3
github.com/jarcoal/httpmock v1.2.0
github.com/konveyor/crane-lib v0.0.8
github.com/konveyor/crane-lib v0.1.5-0.20250909151500-172f817bb41b
github.com/olekukonko/tablewriter v0.0.5
github.com/openshift/api v0.0.0-20220525145417-ee5b62754c68
github.com/openshift/library-go v0.0.0-20220704153411-3ea4b775d418
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.5.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.9.1
github.com/spf13/viper v1.12.0
github.com/vmware-tanzu/velero v1.6.3
golang.org/x/mod v0.8.0
golang.org/x/mod v0.24.0
gotest.tools/v3 v3.0.3
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
k8s.io/cli-runtime v0.24.2
k8s.io/client-go v0.24.2
sigs.k8s.io/controller-runtime v0.12.2
k8s.io/api v0.33.2
k8s.io/apimachinery v0.33.2
k8s.io/cli-runtime v0.33.2
k8s.io/client-go v0.33.2
sigs.k8s.io/controller-runtime v0.20.4
sigs.k8s.io/kustomize/cmd/config v0.10.7
sigs.k8s.io/kustomize/kyaml v0.13.7
sigs.k8s.io/yaml v1.3.0
sigs.k8s.io/kustomize/kyaml v0.19.0
sigs.k8s.io/yaml v1.4.0
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Luzifer/go-dhparam v1.1.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch v5.9.11+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.6.9 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
Expand All @@ -71,29 +70,35 @@ require (
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/shipwright-io/build v0.16.4 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/oauth2 v0.29.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/term v0.31.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/time v0.10.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220401212409-b28bf2818661 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/kustomize/api v0.11.5 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/kustomize/api v0.19.0 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
)
Loading