Skip to content

Commit e0735d5

Browse files
windercce
authored andcommitted
Allow getting versions for any package. (algorand#2935)
## Summary Add an option to support version checking for arbitrary packages. This would allow us to deploy indexer releases at `algorand-releases/<channel>/indexer-*` ## Test Plan Ran the command and see the correct regex: ``` ~$ updater ver check -c nightly -p indexer Checking for files matching: 'channel/nightly/indexer_nightly_linux-amd64_' in bucket algorand-releases no updates found for channel 'nightly' ```
1 parent 85b2725 commit e0735d5

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

cmd/updater/versionCmd.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,26 @@ import (
2828
var (
2929
destFile string
3030
versionBucket string
31+
packageName string
3132
specificVersion uint64
3233
semanticOutput bool
3334
)
3435

36+
// DefaultPackageName is the package we'll use by default.
37+
const DefaultPackageName = "node"
38+
3539
func init() {
3640
versionCmd.AddCommand(checkCmd)
3741
versionCmd.AddCommand(getCmd)
3842

39-
checkCmd.Flags().StringVarP(&versionBucket, "bucket", "b", "", "S3 bucket containing updates.")
4043
checkCmd.Flags().BoolVarP(&semanticOutput, "semantic", "s", false, "Human readable semantic version output.")
44+
checkCmd.Flags().StringVarP(&packageName, "package", "p", DefaultPackageName, "Get version of specific package.")
45+
checkCmd.Flags().StringVarP(&versionBucket, "bucket", "b", "", "S3 bucket containing updates.")
4146

4247
getCmd.Flags().StringVarP(&destFile, "outputFile", "o", "", "Path for downloaded file (required).")
43-
getCmd.Flags().StringVarP(&versionBucket, "bucket", "b", "", "S3 bucket containing updates.")
4448
getCmd.Flags().Uint64VarP(&specificVersion, "version", "v", 0, "Specific version to download.")
49+
getCmd.Flags().StringVarP(&packageName, "package", "p", DefaultPackageName, "Get version of specific package.")
50+
getCmd.Flags().StringVarP(&versionBucket, "bucket", "b", "", "S3 bucket containing updates.")
4551
getCmd.MarkFlagRequired("outputFile")
4652
}
4753

@@ -67,7 +73,7 @@ var checkCmd = &cobra.Command{
6773
if err != nil {
6874
exitErrorf("Error creating s3 session %s\n", err.Error())
6975
} else {
70-
version, _, err := s3Session.GetLatestUpdateVersion(channel)
76+
version, _, err := s3Session.GetPackageVersion(channel, packageName, 0)
7177
if err != nil {
7278
exitErrorf("Error getting latest version from s3 %s\n", err.Error())
7379
}
@@ -102,7 +108,7 @@ var getCmd = &cobra.Command{
102108
if err != nil {
103109
exitErrorf("Error creating s3 session %s\n", err.Error())
104110
} else {
105-
version, name, err := s3Session.GetUpdateVersion(channel, specificVersion)
111+
version, name, err := s3Session.GetPackageVersion(channel, packageName, specificVersion)
106112
if err != nil {
107113
exitErrorf("Error getting latest version from s3 %s\n", err.Error())
108114
}

util/s3/s3Helper.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ func makeS3Session(credentials *credentials.Credentials, bucket string) (helper
199199
return
200200
}
201201

202-
// GetLatestUpdateVersion returns the latest version details for the 'node' package
203-
func (helper *Helper) GetLatestUpdateVersion(channel string) (maxVersion uint64, maxVersionName string, err error) {
204-
return helper.GetUpdateVersion(channel, 0)
205-
}
206-
207202
// GetLatestPackageVersion returns the latest version details for a given package name (eg node, install, tools)
208203
func (helper *Helper) GetLatestPackageVersion(channel string, packageName string) (maxVersion uint64, maxVersionName string, err error) {
209204
return helper.GetPackageVersion(channel, packageName, 0)
@@ -214,12 +209,6 @@ func (helper *Helper) GetLatestPackageFilesVersion(channel string, packagePrefix
214209
return helper.GetPackageFilesVersion(channel, packagePrefix, 0)
215210
}
216211

217-
// GetUpdateVersion ensures the specified version is present and returns the name of the file, if found
218-
// Or if specificVersion == 0, returns the name of the file with the max version
219-
func (helper *Helper) GetUpdateVersion(channel string, specificVersion uint64) (maxVersion uint64, maxVersionName string, err error) {
220-
return helper.GetPackageVersion(channel, "node", specificVersion)
221-
}
222-
223212
// DownloadFile downloads the specified file to the provided Writer
224213
func (helper *Helper) DownloadFile(name string, writer io.WriterAt) error {
225214
downloader := s3manager.NewDownloader(helper.session)

0 commit comments

Comments
 (0)