diff --git a/changelogs/unreleased/059-lintongj b/changelogs/unreleased/059-lintongj new file mode 100644 index 00000000..f5e74b5c --- /dev/null +++ b/changelogs/unreleased/059-lintongj @@ -0,0 +1 @@ +Code cleanup: Removed unused files and cleaned up unused code snippets diff --git a/pkg/cmd/cli/abort/abort.go b/pkg/cmd/cli/abort/abort.go deleted file mode 100644 index 85233b80..00000000 --- a/pkg/cmd/cli/abort/abort.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package abort - -import ( - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/cmd/cli/download" - "github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/cmd/cli/upload" -) - -func NewCommand(f client.Factory) *cobra.Command { - c := &cobra.Command{ - Use: "abort", - Short: "Abort data manager operations", - Long: "Abort data manager operations", - } - - c.AddCommand( - upload.NewAbortCommand(f, "upload"), - download.NewAbortCommand(f, "download"), - ) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/download/abort.go b/pkg/cmd/cli/download/abort.go deleted file mode 100644 index 8e130232..00000000 --- a/pkg/cmd/cli/download/abort.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package download - -import ( - "fmt" - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func NewAbortCommand(f client.Factory, use string) *cobra.Command { - var listOptions metav1.ListOptions - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: fmt.Sprintf("%s [NAMES]", use), - Short: "Abort downloads", - Run: func(c *cobra.Command, args []string) { - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Infof("Datamgr download abort called") - }, - } - - c.Flags().StringVarP(&listOptions.LabelSelector, "selector", "l", listOptions.LabelSelector, "only show items matching this label selector") - - output.BindFlags(c.Flags()) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/download/create.go b/pkg/cmd/cli/download/create.go deleted file mode 100644 index 2a49fe10..00000000 --- a/pkg/cmd/cli/download/create.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package download - -import ( - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/spf13/pflag" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - "strings" - - //"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/client" - //"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/cmd/util/output" - //"github.com/vmware-tanzu/velero-plugin-for-vsphere/pkg/util/logging" - // TODO: change the import package accordingly - veleroclient "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned" -) - -func NewCreateCommand(f client.Factory, use string) *cobra.Command { - o := NewCreateOptions() - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: use + " NAME", - Short: "Create an upload", - Args: cobra.ExactArgs(1), - Example: ` # upload a snapshot to durable storage - datamgr upload create upload1 --snapshot-id fcd::`, - Run: func(c *cobra.Command, args []string) { - //cmd.CheckError(o.Complete(args, f)) - //cmd.CheckError(o.Validate(c, args, f)) - //cmd.CheckError(o.Run(c, f)) - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Debugf("setting log-level to %s", strings.ToUpper(logLevel.String())) - logger.Infof("Starting datamgr server") - }, - } - - o.BindFlags(c.Flags()) - output.BindFlags(c.Flags()) - output.ClearOutputFlagDefault(c) - - return c -} - -type CreateOptions struct { - Name string - SnapshotId string - StorageLocation string - SnapshotLocations []string - Node string - Wait bool - - client veleroclient.Interface -} - -func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) { - flags.StringVar(&o.SnapshotId, "snapshot-id", "", "The ID of Protected Entity to be uploaded") - flags.StringVar(&o.StorageLocation, "storage-location", "", "location in which to store the backup") - flags.StringVar(&o.Node, "datamgr-node", "", "node in which to do the upload operation") - flags.StringSliceVar(&o.SnapshotLocations, "volume-snapshot-locations", o.SnapshotLocations, "list of locations (at most one per provider) where volume snapshots should be stored") -} - -func NewCreateOptions() *CreateOptions { - return &CreateOptions{} -} \ No newline at end of file diff --git a/pkg/cmd/cli/download/delete.go b/pkg/cmd/cli/download/delete.go deleted file mode 100644 index cdba6edb..00000000 --- a/pkg/cmd/cli/download/delete.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package download - -import ( - "fmt" - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "strings" -) - -func NewDeleteCommand(f client.Factory, use string) *cobra.Command { - var listOptions metav1.ListOptions - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: fmt.Sprintf("%s [NAMES]", use), - Short: "Delete downloads", - Run: func(c *cobra.Command, args []string) { - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Debugf("setting log-level to %s", strings.ToUpper(logLevel.String())) - logger.Infof("Datamgr download delete called") - }, - } - - c.Flags().StringVarP(&listOptions.LabelSelector, "selector", "l", listOptions.LabelSelector, "only show items matching this label selector") - - output.BindFlags(c.Flags()) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/download/describe.go b/pkg/cmd/cli/download/describe.go deleted file mode 100644 index 4b7146dd..00000000 --- a/pkg/cmd/cli/download/describe.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package download - -import ( - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "strings" -) - -func NewDescribeCommand(f client.Factory, use string) *cobra.Command { - var listOptions metav1.ListOptions - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: use + " [NAME1] [NAME2] [NAME...]", - Short: "Describe downloads", - Run: func(c *cobra.Command, args []string) { - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Debugf("setting log-level to %s", strings.ToUpper(logLevel.String())) - logger.Infof("Datamgr download describe called") - }, - } - - c.Flags().StringVarP(&listOptions.LabelSelector, "selector", "l", listOptions.LabelSelector, "only show items matching this label selector") - - output.BindFlags(c.Flags()) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/download/download.go b/pkg/cmd/cli/download/download.go deleted file mode 100644 index bac8ad43..00000000 --- a/pkg/cmd/cli/download/download.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package download - -import ( - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" -) - -func NewCommand(f client.Factory) *cobra.Command { - c := &cobra.Command{ - Use: "download", - Short: "Work with data manager download", - Long: "Work with data manager download", - } - - c.AddCommand( - NewCreateCommand(f, "create"), - NewGetCommand(f, "get"), - NewDescribeCommand(f, "describe"), - NewDeleteCommand(f, "delete"), - ) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/download/get.go b/pkg/cmd/cli/download/get.go deleted file mode 100644 index 7c7826bc..00000000 --- a/pkg/cmd/cli/download/get.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package download - -import ( - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "strings" -) - -func NewGetCommand(f client.Factory, use string) *cobra.Command { - var listOptions metav1.ListOptions - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: use, - Short: "Get downloads", - Run: func(c *cobra.Command, args []string) { - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Debugf("setting log-level to %s", strings.ToUpper(logLevel.String())) - logger.Infof("Datamgr download get called") - }, - } - - c.Flags().StringVarP(&listOptions.LabelSelector, "selector", "l", listOptions.LabelSelector, "only show items matching this label selector") - - output.BindFlags(c.Flags()) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/upload/abort.go b/pkg/cmd/cli/upload/abort.go deleted file mode 100644 index ec09d36e..00000000 --- a/pkg/cmd/cli/upload/abort.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package upload - -import ( - "fmt" - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func NewAbortCommand(f client.Factory, use string) *cobra.Command { - var listOptions metav1.ListOptions - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: fmt.Sprintf("%s [NAMES]", use), - Short: "Abort uploads", - Run: func(c *cobra.Command, args []string) { - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Infof("Datamgr upload abort called") - }, - } - - c.Flags().StringVarP(&listOptions.LabelSelector, "selector", "l", listOptions.LabelSelector, "only show items matching this label selector") - - output.BindFlags(c.Flags()) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/upload/create.go b/pkg/cmd/cli/upload/create.go deleted file mode 100644 index 73092356..00000000 --- a/pkg/cmd/cli/upload/create.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package upload - -import ( - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/spf13/pflag" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - veleroclient "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned" - "strings" -) - -func NewCreateCommand(f client.Factory, use string) *cobra.Command { - o := NewCreateOptions() - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: use + " NAME", - Short: "Create a backup", - Args: cobra.ExactArgs(1), - Example: ` # upload a snapshot to durable storage - datamgr upload create upload1 --snapshot-id fcd::`, - Run: func(c *cobra.Command, args []string) { - //cmd.CheckError(o.Complete(args, f)) - //cmd.CheckError(o.Validate(c, args, f)) - //cmd.CheckError(o.Run(c, f)) - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Debugf("setting log-level to %s", strings.ToUpper(logLevel.String())) - logger.Infof("Starting datamgr server") - }, - } - - o.BindFlags(c.Flags()) - output.BindFlags(c.Flags()) - output.ClearOutputFlagDefault(c) - - return c -} - -type CreateOptions struct { - Name string - SnapshotId string - StorageLocation string - SnapshotLocations []string - Node string - Wait bool - - client veleroclient.Interface -} - -func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) { - flags.StringVar(&o.SnapshotId, "snapshot-id", "", "The ID of Protected Entity to be uploaded") - flags.StringVar(&o.StorageLocation, "storage-location", "", "location in which to store the backup") - flags.StringVar(&o.Node, "datamgr-node", "", "node in which to do the upload operation") - flags.StringSliceVar(&o.SnapshotLocations, "volume-snapshot-locations", o.SnapshotLocations, "list of locations (at most one per provider) where volume snapshots should be stored") -} - -func NewCreateOptions() *CreateOptions { - return &CreateOptions{} -} \ No newline at end of file diff --git a/pkg/cmd/cli/upload/delete.go b/pkg/cmd/cli/upload/delete.go deleted file mode 100644 index 57487586..00000000 --- a/pkg/cmd/cli/upload/delete.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package upload - -import ( - "fmt" - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "strings" -) - -func NewDeleteCommand(f client.Factory, use string) *cobra.Command { - var listOptions metav1.ListOptions - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: fmt.Sprintf("%s [NAMES]", use), - Short: "Delete uploads", - Run: func(c *cobra.Command, args []string) { - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Debugf("setting log-level to %s", strings.ToUpper(logLevel.String())) - logger.Infof("Datamgr upload delete called") - }, - } - - c.Flags().StringVarP(&listOptions.LabelSelector, "selector", "l", listOptions.LabelSelector, "only show items matching this label selector") - - output.BindFlags(c.Flags()) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/upload/describe.go b/pkg/cmd/cli/upload/describe.go deleted file mode 100644 index 52960133..00000000 --- a/pkg/cmd/cli/upload/describe.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package upload - -import ( - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "strings" -) - -func NewDescribeCommand(f client.Factory, use string) *cobra.Command { - var listOptions metav1.ListOptions - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: use + " [NAME1] [NAME2] [NAME...]", - Short: "Describe uploads", - Run: func(c *cobra.Command, args []string) { - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Debugf("setting log-level to %s", strings.ToUpper(logLevel.String())) - logger.Infof("Datamgr upload describe called") - }, - } - - c.Flags().StringVarP(&listOptions.LabelSelector, "selector", "l", listOptions.LabelSelector, "only show items matching this label selector") - - output.BindFlags(c.Flags()) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/upload/get.go b/pkg/cmd/cli/upload/get.go deleted file mode 100644 index 49f9fa4f..00000000 --- a/pkg/cmd/cli/upload/get.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package upload - -import ( - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" - "github.com/vmware-tanzu/velero/pkg/cmd/util/output" - "github.com/vmware-tanzu/velero/pkg/util/logging" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "strings" -) - -func NewGetCommand(f client.Factory, use string) *cobra.Command { - var listOptions metav1.ListOptions - logLevelFlag := logging.LogLevelFlag(logrus.InfoLevel) - formatFlag := logging.NewFormatFlag() - - c := &cobra.Command{ - Use: use, - Short: "Get uploads", - Run: func(c *cobra.Command, args []string) { - logLevel := logLevelFlag.Parse() - logger := logging.DefaultLogger(logLevel, formatFlag.Parse()) - logger.Debugf("setting log-level to %s", strings.ToUpper(logLevel.String())) - logger.Infof("Datamgr upload get called") - }, - } - - c.Flags().StringVarP(&listOptions.LabelSelector, "selector", "l", listOptions.LabelSelector, "only show items matching this label selector") - - output.BindFlags(c.Flags()) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/cli/upload/upload.go b/pkg/cmd/cli/upload/upload.go deleted file mode 100644 index 642e482b..00000000 --- a/pkg/cmd/cli/upload/upload.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright 2020 the Velero contributors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package upload - -import ( - "github.com/spf13/cobra" - "github.com/vmware-tanzu/velero/pkg/client" -) - -func NewCommand(f client.Factory) *cobra.Command { - c := &cobra.Command{ - Use: "upload", - Short: "Work with data manager upload", - Long: "Work with data manager upload", - } - - c.AddCommand( - NewCreateCommand(f, "create"), - NewGetCommand(f, "get"), - NewDescribeCommand(f, "describe"), - NewDeleteCommand(f, "delete"), - ) - - return c -} \ No newline at end of file diff --git a/pkg/cmd/datamgr/datamgr.go b/pkg/cmd/datamgr/datamgr.go index a3232c7a..7424cfc0 100644 --- a/pkg/cmd/datamgr/datamgr.go +++ b/pkg/cmd/datamgr/datamgr.go @@ -37,10 +37,6 @@ func NewCommand(name string) *cobra.Command { fmt.Fprintf(os.Stderr, "WARNING: Error reading config file: %v\n", err) } - //// Declare cmdFeatures here so we can access them in the PreRun hooks - //// without doing a chain of calls into the command's FlagSet - //var cmdFeatures veleroflag.StringArray - c := &cobra.Command{ Use: name, Short: "Upload and download snapshots of persistent volume on vSphere kubernetes cluster", @@ -48,27 +44,14 @@ func NewCommand(name string) *cobra.Command { moving local snapshotted data from/to remote durable persistent storage. Specifically, the data manager component is supposed to be running in separate container from the velero server`, - //// PersistentPreRun will run before all subcommands EXCEPT in the following conditions: - //// - a subcommand defines its own PersistentPreRun function - //// - the command is run without arguments or with --help and only prints the usage info - //PersistentPreRun: func(cmd *cobra.Command, args []string) { - // features.Enable(config.Features()...) - // features.Enable(cmdFeatures...) - //}, } f := client.NewFactory(name, config) f.BindFlags(c.PersistentFlags()) - // Bind features directly to the root command so it's available to all callers. - //c.PersistentFlags().Var(&cmdFeatures, "features", "Comma-separated list of features to enable for this Velero process. Combines with values from $HOME/.config/velero/config.json if present") - c.AddCommand( server.NewCommand(f), install.NewCommand(f), -// upload.NewCommand(f), -// download.NewCommand(f), -// abort.NewCommand(f), ) // init and add the klog flags diff --git a/pkg/plugin/volume_snapshotter_plugin.go b/pkg/plugin/volume_snapshotter_plugin.go index 8388c3cb..14fabc2f 100644 --- a/pkg/plugin/volume_snapshotter_plugin.go +++ b/pkg/plugin/volume_snapshotter_plugin.go @@ -28,24 +28,10 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) -// Volume keeps track of volumes created by this plugin -type Volume struct { - volType, az string - iops int64 -} - -// Snapshot keeps track of snapshots created by this plugin -type Snapshot struct { - volID, az string - tags map[string]string -} - // NewVolumeSnapshotter is a plugin for containing state for the blockstore type NewVolumeSnapshotter struct { config map[string]string logrus.FieldLogger - volumes map[string]Volume - snapshots map[string]Snapshot snapMgr *snapshotmgr.SnapshotManager } @@ -58,14 +44,6 @@ func (p *NewVolumeSnapshotter) Init(config map[string]string) error { p.Infof("Init called with config: %v", config) p.config = config - // Make sure we don't overwrite data, now that we can re-initialize the plugin - if p.volumes == nil { - p.volumes = make(map[string]Volume) - } - if p.snapshots == nil { - p.snapshots = make(map[string]Snapshot) - } - // Initializing snapshot manager p.Infof("Initializing snapshot manager") if config == nil { @@ -80,7 +58,6 @@ func (p *NewVolumeSnapshotter) Init(config map[string]string) error { } p.Infof("vSphere VolumeSnapshotter is initialized") - return nil } @@ -109,25 +86,16 @@ func (p *NewVolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, p.Debugf("A new volume %s with type being %s was just created from the call of SnapshotManager CreateVolumeFromSnapshot", returnVolumeID, returnVolumeType) - p.volumes[returnVolumeID] = Volume{ - volType: returnVolumeType, - az: volumeAZ, - iops: 100, - } return returnVolumeID, nil } -const cnsBlockVolumeType = "ivd" - // GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for // the specified volume in the given availability zone. func (p *NewVolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) { p.Infof("GetVolumeInfo called with volumeID %s, volumeAZ %s", volumeID, volumeAZ) - if val, ok := p.volumes[volumeID]; ok { - iops := val.iops - return val.volType, &iops, nil - } - return cnsBlockVolumeType, nil, nil + var iops int64 + iops = 100 // dummy iops is applied + return utils.CnsBlockVolumeType, &iops, nil } // IsVolumeReady Check if the volume is ready. @@ -150,25 +118,11 @@ func (p *NewVolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags ma return "", err } - // Remember the "original" volume, only required for the first - // time. - if _, exists := p.volumes[volumeID]; !exists { - p.volumes[volumeID] = Volume{ - volType: cnsBlockVolumeType, - az: volumeAZ, - iops: 100, - } - } - // Construct the snapshotID for cns volume snapshotID = peID.String() p.Debugf("The snapshotID depends on the Astrolabe PE ID in the format, ::, %s", snapshotID) - // Remember the snapshot - p.snapshots[snapshotID] = Snapshot{volID: volumeID, - az: volumeAZ, - tags: tags} - p.Debugf("CreateSnapshot returning: %s", snapshotID) + p.Infof("CreateSnapshot completed with snapshotID, %s", snapshotID) return snapshotID, nil } @@ -230,14 +184,12 @@ func (p *NewVolumeSnapshotter) SetVolumeID(unstructuredPV runtime.Unstructured, p.Debugf("Set VolumeID, %s, to vSphere CSI VolumeHandle", volumeID) pv.Spec.CSI.VolumeHandle = volumeID - res, err := runtime.DefaultUnstructuredConverter.ToUnstructured(pv) if err != nil { return nil, errors.WithStack(err) } unstructuredPV = &unstructured.Unstructured{Object: res} - p.Debugf("Updated unstructured PV: %v", unstructuredPV) return unstructuredPV, nil diff --git a/pkg/utils/constants.go b/pkg/utils/constants.go index a8bd4d85..bfd3b788 100644 --- a/pkg/utils/constants.go +++ b/pkg/utils/constants.go @@ -18,6 +18,11 @@ package utils import "time" +const ( + // supported volume type in plugin + CnsBlockVolumeType = "ivd" +) + const ( // Duration at which lease expires on CRs. LeaseDuration = 60 * time.Second