Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move version checks from public container to static website #1550

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 2.3.3 (Unreleased)
## 2.4.0 (Unreleased)
**Bug Fixes**
**Other Changes**
- Version check is now moved to a static website hosted on a public container.

## 2.3.2 (2024-09-03)
**Bug Fixes**
Expand Down
14 changes: 9 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ import (
)

type VersionFilesList struct {
XMLName xml.Name `xml:"EnumerationResults"`
Blobs []Blob `xml:"Blobs>Blob"`
Version string `xml:"latest"`
}

type Blob struct {
Expand Down Expand Up @@ -104,18 +103,23 @@ func getRemoteVersion(req string) (string, error) {
return "", err
}

if len(body) > 50 {
vibhansa-msft marked this conversation as resolved.
Show resolved Hide resolved
log.Err("getRemoteVersion: something suspicious in the contents from remote version")
return "", fmt.Errorf("unable to get latest version")
}

var versionList VersionFilesList
err = xml.Unmarshal(body, &versionList)
if err != nil {
log.Err("getRemoteVersion: error unmarshalling xml response [%s]", err.Error())
return "", err
}

if len(versionList.Blobs) != 1 {
if len(versionList.Version) < 5 || len(versionList.Version) > 20 {
return "", fmt.Errorf("unable to get latest version")
}

versionName := strings.Split(versionList.Blobs[0].Name, "/")[1]
versionName := versionList.Version
return versionName, nil
}

Expand All @@ -126,7 +130,7 @@ func beginDetectNewVersion() chan interface{} {
go func() {
defer close(completed)

latestVersionUrl := common.Blobfuse2ListContainerURL + "?restype=container&comp=list&prefix=latest/"
latestVersionUrl := common.Blobfuse2ListContainerURL + "/latest/index.xml"
remoteVersion, err := getRemoteVersion(latestVersionUrl)
if err != nil {
log.Err("beginDetectNewVersion: error getting latest version [%s]", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func getDummyVersion() string {

func (suite *rootCmdSuite) TestGetRemoteVersionValidContainer() {
defer suite.cleanupTest()
latestVersionUrl := common.Blobfuse2ListContainerURL + "?restype=container&comp=list&prefix=latest/"
latestVersionUrl := common.Blobfuse2ListContainerURL + "/latest/index.xml"
out, err := getRemoteVersion(latestVersionUrl)
suite.assert.NotEmpty(out)
suite.assert.Nil(err)
Expand Down
2 changes: 1 addition & 1 deletion common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (

// Standard config default values
const (
blobfuse2Version_ = "2.3.3"
blobfuse2Version_ = "2.4.0"

DefaultMaxLogFileSize = 512
DefaultLogFileCount = 10
Expand Down
2 changes: 1 addition & 1 deletion common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"strings"
)

const Blobfuse2ListContainerURL = "https://blobfuse2.blob.core.windows.net/release"
const Blobfuse2ListContainerURL = "https://blobfuse2.z13.web.core.windows.net/release"
vibhansa-msft marked this conversation as resolved.
Show resolved Hide resolved
const BlobFuse2WarningsURL = "https://aka.ms/blobfuse2warnings"
const BlobFuse2BlockingURL = "https://aka.ms/blobfuse2blockers"

Expand Down
Loading