diff --git a/cmd/updater/versionCmd.go b/cmd/updater/versionCmd.go index 4b700ef1e7..5b8345bf8d 100644 --- a/cmd/updater/versionCmd.go +++ b/cmd/updater/versionCmd.go @@ -28,20 +28,26 @@ import ( var ( destFile string versionBucket string + packageName string specificVersion uint64 semanticOutput bool ) +// DefaultPackageName is the package we'll use by default. +const DefaultPackageName = "node" + func init() { versionCmd.AddCommand(checkCmd) versionCmd.AddCommand(getCmd) - checkCmd.Flags().StringVarP(&versionBucket, "bucket", "b", "", "S3 bucket containing updates.") checkCmd.Flags().BoolVarP(&semanticOutput, "semantic", "s", false, "Human readable semantic version output.") + checkCmd.Flags().StringVarP(&packageName, "package", "p", DefaultPackageName, "Get version of specific package.") + checkCmd.Flags().StringVarP(&versionBucket, "bucket", "b", "", "S3 bucket containing updates.") getCmd.Flags().StringVarP(&destFile, "outputFile", "o", "", "Path for downloaded file (required).") - getCmd.Flags().StringVarP(&versionBucket, "bucket", "b", "", "S3 bucket containing updates.") getCmd.Flags().Uint64VarP(&specificVersion, "version", "v", 0, "Specific version to download.") + getCmd.Flags().StringVarP(&packageName, "package", "p", DefaultPackageName, "Get version of specific package.") + getCmd.Flags().StringVarP(&versionBucket, "bucket", "b", "", "S3 bucket containing updates.") getCmd.MarkFlagRequired("outputFile") } @@ -67,7 +73,7 @@ var checkCmd = &cobra.Command{ if err != nil { exitErrorf("Error creating s3 session %s\n", err.Error()) } else { - version, _, err := s3Session.GetLatestUpdateVersion(channel) + version, _, err := s3Session.GetPackageVersion(channel, packageName, 0) if err != nil { exitErrorf("Error getting latest version from s3 %s\n", err.Error()) } @@ -102,7 +108,7 @@ var getCmd = &cobra.Command{ if err != nil { exitErrorf("Error creating s3 session %s\n", err.Error()) } else { - version, name, err := s3Session.GetUpdateVersion(channel, specificVersion) + version, name, err := s3Session.GetPackageVersion(channel, packageName, specificVersion) if err != nil { exitErrorf("Error getting latest version from s3 %s\n", err.Error()) } diff --git a/util/s3/s3Helper.go b/util/s3/s3Helper.go index a997f20a1d..2369113704 100644 --- a/util/s3/s3Helper.go +++ b/util/s3/s3Helper.go @@ -199,11 +199,6 @@ func makeS3Session(credentials *credentials.Credentials, bucket string) (helper return } -// GetLatestUpdateVersion returns the latest version details for the 'node' package -func (helper *Helper) GetLatestUpdateVersion(channel string) (maxVersion uint64, maxVersionName string, err error) { - return helper.GetUpdateVersion(channel, 0) -} - // GetLatestPackageVersion returns the latest version details for a given package name (eg node, install, tools) func (helper *Helper) GetLatestPackageVersion(channel string, packageName string) (maxVersion uint64, maxVersionName string, err error) { return helper.GetPackageVersion(channel, packageName, 0) @@ -214,12 +209,6 @@ func (helper *Helper) GetLatestPackageFilesVersion(channel string, packagePrefix return helper.GetPackageFilesVersion(channel, packagePrefix, 0) } -// GetUpdateVersion ensures the specified version is present and returns the name of the file, if found -// Or if specificVersion == 0, returns the name of the file with the max version -func (helper *Helper) GetUpdateVersion(channel string, specificVersion uint64) (maxVersion uint64, maxVersionName string, err error) { - return helper.GetPackageVersion(channel, "node", specificVersion) -} - // DownloadFile downloads the specified file to the provided Writer func (helper *Helper) DownloadFile(name string, writer io.WriterAt) error { downloader := s3manager.NewDownloader(helper.session)