diff --git a/go.work.sum b/go.work.sum index 59da80e5a..ad5810785 100644 --- a/go.work.sum +++ b/go.work.sum @@ -127,8 +127,6 @@ cloud.google.com/go/webrisk v1.7.0/go.mod h1:mVMHgEYH0r337nmt1JyLthzMr6YxwN1aAIE cloud.google.com/go/websecurityscanner v1.4.0/go.mod h1:ebit/Fp0a+FWu5j4JOmJEV8S8CzdTkAS77oDsiSqYWQ= cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= -github.com/aws/aws-sdk-go-v2/service/ecr v1.15.0 h1:lY2Z2sBP+zSbJ6CvvmnFgPcgknoQ0OJV88AwVetRRFk= -github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.12.0 h1:LsqBpyRofMG6eDs6YGud6FhdGyIyXelAasPOZ6wWLro= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= @@ -136,12 +134,9 @@ github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMn github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/emicklei/go-restful v2.16.0+incompatible h1:rgqiKNjTnFQA6kkhFe16D8epTksy9HQ1MyrbDXSdYhM= github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= @@ -149,18 +144,14 @@ github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqE github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= -github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= -github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= +github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= -golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= @@ -181,7 +172,6 @@ golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo= @@ -201,5 +191,8 @@ google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsA k8s.io/api v0.27.1/go.mod h1:z5g/BpAiD+f6AArpqNjkY+cji8ueZDU/WV1jcj5Jk4E= k8s.io/gengo v0.0.0-20220913193501-391367153a38/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= +k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg= k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY= +k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= diff --git a/pkg/airgapped/plugin_bundle_download.go b/pkg/airgapped/plugin_bundle_download.go index a91d3f06e..0a8e8998c 100644 --- a/pkg/airgapped/plugin_bundle_download.go +++ b/pkg/airgapped/plugin_bundle_download.go @@ -85,8 +85,8 @@ func (o *DownloadPluginBundleOptions) DownloadPluginBundle() error { // getSelectedPluginInfo returns the list of PluginInventoryEntry and // PluginGroupEntry based on the DownloadPluginBundleOptions that needs to be // considered for downloading plugin bundle. -// Downloads the the plugin inventory image and selects the plugins and plugin -// groups based on the DownloadPluginBundleOptions.Groups by quering the +// Downloads the plugin inventory image and selects the plugins and plugin +// groups based on the DownloadPluginBundleOptions.Groups by querying the // plugin inventory database func (o *DownloadPluginBundleOptions) getSelectedPluginInfo() ([]*plugininventory.PluginInventoryEntry, []*plugininventory.PluginGroup, error) { var err error diff --git a/pkg/airgapped/plugin_bundle_test.go b/pkg/airgapped/plugin_bundle_test.go index a0b8f52fb..da50fc5f1 100644 --- a/pkg/airgapped/plugin_bundle_test.go +++ b/pkg/airgapped/plugin_bundle_test.go @@ -109,13 +109,13 @@ var _ = Describe("Unit tests for download and upload bundle", func() { sourceFilePath: plugin_inventory_metadata.db relativeImagePathWithTag: /plugin-inventory-metadata:latest imagesToCopy: - - sourceFilePath: plugin-inventory-image.tar.gz + - sourceTarFilePath: plugin-inventory-image.tar.gz relativeImagePath: /plugin-inventory - - sourceFilePath: bar-kubernetes-darwin_amd64-v0.0.1.tar.gz + - sourceTarFilePath: bar-kubernetes-darwin_amd64-v0.0.1.tar.gz relativeImagePath: /path/darwin/amd64/kubernetes/bar - - sourceFilePath: foo-global-darwin_amd64-v0.0.2.tar.gz + - sourceTarFilePath: foo-global-darwin_amd64-v0.0.2.tar.gz relativeImagePath: /path/darwin/amd64/global/foo - - sourceFilePath: foo-global-linux_amd64-v0.0.2.tar.gz + - sourceTarFilePath: foo-global-linux_amd64-v0.0.2.tar.gz relativeImagePath: /path/linux/amd64/global/foo ` @@ -125,9 +125,9 @@ imagesToCopy: sourceFilePath: plugin_inventory_metadata.db relativeImagePathWithTag: /plugin-inventory-metadata:latest imagesToCopy: - - sourceFilePath: plugin-inventory-image.tar.gz + - sourceTarFilePath: plugin-inventory-image.tar.gz relativeImagePath: /plugin-inventory - - sourceFilePath: bar-kubernetes-darwin_amd64-v0.0.1.tar.gz + - sourceTarFilePath: bar-kubernetes-darwin_amd64-v0.0.1.tar.gz relativeImagePath: /path/darwin/amd64/kubernetes/bar ` diff --git a/pkg/airgapped/plugin_bundle_upload.go b/pkg/airgapped/plugin_bundle_upload.go index dd58b2e3b..fab9f2d59 100644 --- a/pkg/airgapped/plugin_bundle_upload.go +++ b/pkg/airgapped/plugin_bundle_upload.go @@ -69,7 +69,7 @@ func (o *UploadPluginBundleOptions) UploadPluginBundle() error { log.Infof("publishing plugin inventory metadata image...") bundledPluginInventoryMetadataDBFilePath := filepath.Join(pluginBundleDir, manifest.InventoryMetadataImage.SourceFilePath) pluginInventoryMetadataImageWithTag := filepath.Join(o.DestinationRepo, manifest.InventoryMetadataImage.RelativeImagePathWithTag) - err = o.mergePluginInventoryMetadata(pluginInventoryMetadataImageWithTag, bundledPluginInventoryMetadataDBFilePath, filepath.Join(tempDir, "inventory-metadata")) + err = o.mergePluginInventoryMetadata(pluginInventoryMetadataImageWithTag, bundledPluginInventoryMetadataDBFilePath, tempDir) if err != nil { return errors.Wrap(err, "error while merging the plugin inventory metadata database before uploading metadata image") } diff --git a/pkg/airgapped/types.go b/pkg/airgapped/types.go index de6ed700c..7d667effd 100644 --- a/pkg/airgapped/types.go +++ b/pkg/airgapped/types.go @@ -15,7 +15,7 @@ type PluginMigrationManifest struct { // ImageCopyInfo maps the relative image path and local relative file path type ImageCopyInfo struct { - SourceTarFilePath string `yaml:"sourceFilePath"` + SourceTarFilePath string `yaml:"sourceTarFilePath"` RelativeImagePath string `yaml:"relativeImagePath"` } diff --git a/pkg/command/plugin_bundle.go b/pkg/command/plugin_bundle.go index b7cd3425a..530b79670 100644 --- a/pkg/command/plugin_bundle.go +++ b/pkg/command/plugin_bundle.go @@ -8,6 +8,7 @@ import ( "github.com/vmware-tanzu/tanzu-cli/pkg/airgapped" "github.com/vmware-tanzu/tanzu-cli/pkg/carvelhelpers" + "github.com/vmware-tanzu/tanzu-cli/pkg/constants" ) type downloadPluginBundleOptions struct { @@ -23,6 +24,13 @@ func newDownloadBundlePluginCmd() *cobra.Command { Use: "download-bundle", Short: "Download plugin bundle to the local system", Long: "Download plugin bundle to the local system", + Example: ` +# Download the plugin bundle for specific group from default discovery source +tanzu plugin download-bundle --to-tar /tmp/plugin_bundle_vmware_tkg_default_v1.0.0.tar.gz --group vmware-tkg/default:v1.0.0 + +# Download the plugin bundle with entire plugin repository from custom discovery source +tanzu plugin download-bundle --image custom.registry.vmware.com/tkg/tanzu-plugins/plugin-inventory:latest --to-tar /tmp/plugin_bundle_complete.tar.gz + `, RunE: func(cmd *cobra.Command, args []string) error { options := airgapped.DownloadPluginBundleOptions{ PluginInventoryImage: dpbo.pluginDiscoveryOCIImage, @@ -35,11 +43,10 @@ func newDownloadBundlePluginCmd() *cobra.Command { } f := downloadBundleCmd.Flags() - f.StringVarP(&dpbo.pluginDiscoveryOCIImage, "image", "", "", "URI of the plugin discovery image providing the plugins") + f.StringVarP(&dpbo.pluginDiscoveryOCIImage, "image", "", constants.TanzuCLIDefaultCentralPluginDiscoveryImage, "URI of the plugin discovery image providing the plugins") f.StringVarP(&dpbo.tarFile, "to-tar", "", "", "local tar file path to store the plugin images") - f.StringArrayVarP(&dpbo.groups, "group", "", []string{}, "only download the plugins specified in the plugin group") + f.StringSliceVarP(&dpbo.groups, "group", "", []string{}, "only download the plugins specified in the plugin group (can specify multiple)") - _ = downloadBundleCmd.MarkFlagRequired("image") _ = downloadBundleCmd.MarkFlagRequired("to-tar") return downloadBundleCmd @@ -57,6 +64,10 @@ func newUploadBundlePluginCmd() *cobra.Command { Use: "upload-bundle", Short: "Upload plugin bundle to a repository", Long: "Upload plugin bundle to a repository", + Example: ` +# Upload the plugin bundle to the remote repository +tanzu plugin upload-bundle --tar /tmp/plugin_bundle_vmware_tkg_default_v1.0.0.tar.gz --to-repo custom.registry.company.com/tanzu-plugins/ +tanzu plugin upload-bundle --tar /tmp/plugin_bundle_complete.tar.gz --to-repo custom.registry.company.com/tanzu-plugins/`, RunE: func(cmd *cobra.Command, args []string) error { options := airgapped.UploadPluginBundleOptions{ Tar: upbo.sourceTar, diff --git a/pkg/plugininventory/data/sqlite/plugin_inventory_metadata_tables.sql b/pkg/plugininventory/data/sqlite/plugin_inventory_metadata_tables.sql index c9c413a1f..b9652e97e 100644 --- a/pkg/plugininventory/data/sqlite/plugin_inventory_metadata_tables.sql +++ b/pkg/plugininventory/data/sqlite/plugin_inventory_metadata_tables.sql @@ -11,4 +11,3 @@ CREATE TABLE IF NOT EXISTS "AvailablePluginGroups" ( "GroupName" TEXT NOT NULL, PRIMARY KEY("Vendor", "Publisher", "GroupName") ); - \ No newline at end of file