Repository: threefoldtech/zos
Pull request #360 (2019-11-01 12:23:01)

fix format of flist name + support v prefix in flist version

codecov[bot]: # [Codecov](https://codecov.io/gh/threefoldtech/zos/pull/360?src=pr&el=h1) Report
> Merging [#360](https://codecov.io/gh/threefoldtech/zos/pull/360?src=pr&el=desc) into [master](https://codecov.io/gh/threefoldtech/zos/commit/378ee868d928ec2944168c44870b1f2c38ce7463?src=pr&el=desc) will **increase** coverage by `0.03%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/threefoldtech/zos/pull/360/graphs/tree.svg?width=650&token=f7Vmq1OAEm&height=150&src=pr)](https://codecov.io/gh/threefoldtech/zos/pull/360?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #360      +/-   ##
==========================================
+ Coverage   40.83%   40.86%   +0.03%     
==========================================
  Files          61       61              
  Lines        3781     3783       +2     
==========================================
+ Hits         1544     1546       +2     
  Misses       2032     2032              
  Partials      205      205
```


| [Impacted Files](https://codecov.io/gh/threefoldtech/zos/pull/360?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/upgrade/hub.go](https://codecov.io/gh/threefoldtech/zos/pull/360/diff?src=pr&el=tree#diff-cGtnL3VwZ3JhZGUvaHViLmdv) | `45.33% <100%> (+1.49%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/threefoldtech/zos/pull/360?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/threefoldtech/zos/pull/360?src=pr&el=footer). Last update [378ee86...97c6c86](https://codecov.io/gh/threefoldtech/zos/pull/360?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/.github/workflows/publish-development.yaml b/.github/workflows/publish-development.yaml
index a81d61bd..8ee64341 100644
--- a/.github/workflows/publish-development.yaml
+++ b/.github/workflows/publish-development.yaml
@@ -40,7 +40,7 @@ jobs:
         user: tf-autobuilder
         root: archive
         token: ${{ secrets.HUB_JWT }}
-        name: zos-${{ github.sha }}.flist
+        name: zos:${{ github.sha }}.flist
 
     - name: Set name of the development build
       id: setname
@@ -55,7 +55,7 @@ jobs:
         user: tf-zos
         root: archive
         token: ${{ secrets.HUB_JWT }}
-        name: tf-autobuilder/zos-${{ github.sha }}.flist
+        name: tf-autobuilder/zos:${{ github.sha }}.flist
         target: ${{ steps.setname.outputs.build }}
 
     - name: Readlink of current development build
diff --git a/.github/workflows/publish-pre-release.yaml b/.github/workflows/publish-pre-release.yaml
index ba067383..5ce03a21 100644
--- a/.github/workflows/publish-pre-release.yaml
+++ b/.github/workflows/publish-pre-release.yaml
@@ -49,7 +49,7 @@ jobs:
         user: tf-autobuilder
         root: archive
         token: ${{ secrets.HUB_JWT }}
-        name: zos-${{ github.sha }}.flist
+        name: zos:${{ github.sha }}.flist
 
     - name: Promote flist (${{ github.ref }})
       if: success()
@@ -58,8 +58,8 @@ jobs:
         action: promote
         user: tf-zos
         token: ${{ secrets.HUB_JWT }}
-        name: tf-autobuilder/zos-${{ github.sha }}.flist
-        target: zos-${{ github.ref }}.flist
+        name: tf-autobuilder/zos:${{ github.sha }}.flist
+        target: zos:${{ github.ref }}.flist
 
     - name: Symlink flist (development)
       if: success()
@@ -68,7 +68,7 @@ jobs:
         action: symlink
         user: tf-zos
         token: ${{ secrets.HUB_JWT }}
-        name: zos-${{ github.ref }}.flist
+        name: zos:${{ github.ref }}.flist
         target: zos:development:latest.flist
     
     - name: Symlink flist (testing)
@@ -78,6 +78,6 @@ jobs:
         action: symlink
         user: tf-zos
         token: ${{ secrets.HUB_JWT }}
-        name: zos-${{ github.ref }}.flist
+        name: zos:${{ github.ref }}.flist
         target: zos:testing:latest.flist
 
diff --git a/.github/workflows/publish-release.yaml b/.github/workflows/publish-release.yaml
index 3f212a57..e370ca9f 100644
--- a/.github/workflows/publish-release.yaml
+++ b/.github/workflows/publish-release.yaml
@@ -50,7 +50,7 @@ jobs:
         user: tf-autobuilder
         root: archive
         token: ${{ secrets.HUB_JWT }}
-        name: zos-${{ github.sha }}.flist
+        name: zos:${{ github.sha }}.flist
 
     - name: Promote flist (${{ github.ref }})
       if: success()
@@ -59,7 +59,7 @@ jobs:
         action: promote
         user: tf-zos
         token: ${{ secrets.HUB_JWT }}
-        name: tf-autobuilder/zos-${{ github.sha }}.flist
+        name: tf-autobuilder/zos:${{ github.sha }}.flist
         target: zos-${{ github.ref }}.flist
     
     - name: Symlink flist (development)
@@ -69,7 +69,7 @@ jobs:
         action: symlink
         user: tf-zos
         token: ${{ secrets.HUB_JWT }}
-        name: zos-${{ github.ref }}.flist
+        name: zos:${{ github.ref }}.flist
         target: zos:development:latest.flist
     
     - name: Symlink flist (testing)
@@ -79,7 +79,7 @@ jobs:
         action: symlink
         user: tf-zos
         token: ${{ secrets.HUB_JWT }}
-        name: zos-${{ github.ref }}.flist
+        name: zos:${{ github.ref }}.flist
         target: zos:testing:latest.flist
 
     - name: Symlink flist (production)
@@ -89,6 +89,6 @@ jobs:
         action: symlink
         user: tf-zos
         token: ${{ secrets.HUB_JWT }}
-        name: zos-${{ github.ref }}.flist
+        name: zos:${{ github.ref }}.flist
         target: zos:production:latest.flist
 
diff --git a/pkg/upgrade/hub.go b/pkg/upgrade/hub.go
index c2751c84..2e1730d4 100644
--- a/pkg/upgrade/hub.go
+++ b/pkg/upgrade/hub.go
@@ -116,7 +116,9 @@ func (b *flistInfo) extractVersion(name string) (ver semver.Version, err error)
 	// <name>:<version>.flist
 	parts := strings.Split(name, ":")
 	last := parts[len(parts)-1]
-	return semver.Parse(strings.TrimSuffix(last, ".flist"))
+	last = strings.TrimPrefix(last, "v")
+	last = strings.TrimSuffix(last, ".flist")
+	return semver.Parse(last)
 }
 
 // Version returns the version of the flist


Test patch:
diff --git a/pkg/upgrade/hub_test.go b/pkg/upgrade/hub_test.go
index 3dec38c5..3839682a 100644
--- a/pkg/upgrade/hub_test.go
+++ b/pkg/upgrade/hub_test.go
@@ -9,16 +9,36 @@ import (
 )
 
 func TestInfo(t *testing.T) {
-	const input = `{"size": 0, "name": "zos:development:latest.flist", "target": "zos:development:0.2.0.flist", "type": "symlink", "updated": 1569924782, "md5": "9798ef9b930b49ab18c45953cf1d2369"}`
-
-	var info flistInfo
-	err := json.Unmarshal([]byte(input), &info)
-	require.NoError(t, err)
-
-	ver, err := info.Version()
-	require.NoError(t, err)
-
-	require.Equal(t, semver.MustParse("0.2.0"), ver)
+	tt := []struct {
+		name    string
+		input   string
+		version semver.Version
+	}{
+		{
+			name:    "0.2.0",
+			input:   `{"size": 0, "name": "zos:development:latest.flist", "target": "zos:development:0.2.0.flist", "type": "symlink", "updated": 1569924782, "md5": "9798ef9b930b49ab18c45953cf1d2369"}`,
+			version: semver.MustParse("0.2.0"),
+		},
+		{
+			name:    "v0.2.0",
+			input:   `{"size": 0, "name": "zos:development:latest.flist", "target": "zos:development:v0.2.0.flist", "type": "symlink", "updated": 1569924782, "md5": "9798ef9b930b49ab18c45953cf1d2369"}`,
+			version: semver.MustParse("0.2.0"),
+		},
+	}
+
+	for _, tc := range tt {
+		t.Run(tc.name, func(t *testing.T) {
+
+			var info flistInfo
+			err := json.Unmarshal([]byte(tc.input), &info)
+			require.NoError(t, err)
+
+			ver, err := info.Version()
+			require.NoError(t, err)
+
+			require.Equal(t, tc.version, ver)
+		})
+	}
 }
 
 func TestInfoGet(t *testing.T) {