Skip to content

Commit

Permalink
Update Vyos rolling update iso url
Browse files Browse the repository at this point in the history
Changed because the download location for the Vyos Rolling update ISO file has changed.

Signed-off-by: Naofumi Uesugi <blacknon@orebibou.com>
  • Loading branch information
blacknon authored and stgraber committed Nov 6, 2023
1 parent b0234a2 commit c192e15
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exclude (

require (
github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3
github.com/google/go-github/v56 v56.0.0
github.com/lxc/incus v0.0.0-20231030213510-385b6509cfce
github.com/mudler/docker-companion v0.4.6-0.20211015133729-bd4704fad372
github.com/sirupsen/logrus v1.9.3
Expand Down Expand Up @@ -45,6 +46,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/gorilla/schema v1.2.0 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,15 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-github/v56 v56.0.0 h1:TysL7dMa/r7wsQi44BjqlwaHvwlFlqkK8CtBWCX3gb4=
github.com/google/go-github/v56 v56.0.0/go.mod h1:D8cdcX98YWJvi7TLo7zM4/h8ZTx6u6fwGEkCdisopo0=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
Expand Down
44 changes: 37 additions & 7 deletions sources/vyos-http.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,63 @@
package sources

import (
"context"
"fmt"
"os"
"path/filepath"

"github.com/google/go-github/v56/github"
"golang.org/x/sys/unix"

"github.com/lxc/distrobuilder/shared"
)

type vyos struct {
common

fname string
fpath string
}

func (s *vyos) Run() error {
isoURL := "https://s3-us.vyos.io/rolling/current/vyos-rolling-latest.iso"

fpath, err := s.DownloadHash(s.definition.Image, isoURL, "", nil)
err := s.downloadImage(s.definition)
if err != nil {
return fmt.Errorf("Failed downloading ISO: %w", err)
return fmt.Errorf("Failed to download image: %w", err)
}

err = s.unpackISO(filepath.Join(fpath, "vyos-rolling-latest.iso"), s.rootfsDir)
return s.unpackISO(filepath.Join(s.fpath, s.fname), s.rootfsDir)
}

func (s *vyos) downloadImage(definition shared.Definition) error {
var err error

ctx := context.Background()
client := github.NewClient(nil)
owner := "vyos"
repo := "vyos-rolling-nightly-builds"

latestRelease, _, err := client.Repositories.GetLatestRelease(ctx, owner, repo)
if err != nil {
return fmt.Errorf("Failed unpacking ISO: %w", err)
return fmt.Errorf("Failed to get latest release, %w", err)
}

return nil
isoURL := ""
assets := latestRelease.Assets
for _, a := range assets {
ext := filepath.Ext(a.GetName())
if ext == ".iso" {
isoURL = a.GetBrowserDownloadURL()
s.fname = a.GetName()
}
}

if isoURL == "" {
return fmt.Errorf("Failed to get latest release URL.")
}

s.fpath, err = s.DownloadHash(s.definition.Image, isoURL, "", nil)

return err
}

func (s *vyos) unpackISO(filePath string, rootfsDir string) error {
Expand Down

0 comments on commit c192e15

Please sign in to comment.