Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24
go-version-file: go.mod

- name: Install pallas
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24
go-version-file: go.mod

- name: Install Build Dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24
go-version-file: go.mod

- name: Install Build Dependencies
run: |
Expand Down
3 changes: 2 additions & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"os"
"strings"

digest "github.com/opencontainers/go-digest"
"github.com/spf13/cobra"

"github.com/vanilla-os/abroot/core"
Expand Down Expand Up @@ -203,7 +204,7 @@ func upgrade(cmd *cobra.Command, args []string) error {
}

if raw {
newDigestIfHasUpdate := ""
var newDigestIfHasUpdate digest.Digest = ""
if res {
newDigestIfHasUpdate = newDigest
}
Expand Down
10 changes: 6 additions & 4 deletions core/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ import (
"os"
"path/filepath"
"time"

digest "github.com/opencontainers/go-digest"
)

// The ABImage is the representation of an OCI image used by ABRoot, it
// contains the digest, the timestamp and the image name. If you need to
// investigate the current ABImage on an ABRoot system, you can find it
// at /abimage.abr
type ABImage struct {
Digest string `json:"digest"`
Timestamp time.Time `json:"timestamp"`
Image string `json:"image"`
Digest digest.Digest `json:"digest"`
Timestamp time.Time `json:"timestamp"`
Image string `json:"image"`
}

// NewABImage creates a new ABImage instance and returns a pointer to it,
// if the digest is empty, it returns an error
func NewABImage(digest string, image string) (*ABImage, error) {
func NewABImage(digest digest.Digest, image string) (*ABImage, error) {
if digest == "" {
return nil, fmt.Errorf("NewABImage: digest is empty")
}
Expand Down
38 changes: 37 additions & 1 deletion core/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/containers/image/v5/types"
"github.com/containers/storage"
humanize "github.com/dustin/go-humanize"
digest "github.com/opencontainers/go-digest"
"github.com/pterm/pterm"
"github.com/vanilla-os/abroot/settings"
"github.com/vanilla-os/prometheus"
Expand Down Expand Up @@ -218,11 +219,13 @@ func pullImageWithProgressbar(pt *prometheus.Prometheus, name string, image *Ima

progressCh := make(chan types.ProgressProperties)
manifestCh := make(chan prometheus.OciManifest)
errorCh := make(chan error)

defer close(progressCh)
defer close(manifestCh)
defer close(errorCh)

err := pt.PullImageAsync(image.From, name, progressCh, manifestCh)
err := pt.PullImageAsync(image.From, name, progressCh, manifestCh, errorCh)
if err != nil {
PrintVerboseErr("pullImageWithProgressbar", 0, err)
return err
Expand Down Expand Up @@ -360,3 +363,36 @@ func DeleteAllButLatestImage() error {

return nil
}

// HasUpdate checks if the image/tag from the registry has a different digest
// it returns the new digest and a boolean indicating if an update is available
func HasUpdate(oldDigest digest.Digest) (digest.Digest, bool, error) {
PrintVerboseInfo("OCI.HasUpdate", "Checking for updates ...")

pt, err := prometheus.NewPrometheus(
"/var/lib/abroot/storage",
"overlay",
settings.Cnf.MaxParallelDownloads,
)
if err != nil {
PrintVerboseErr("OCI.HasUpdate", 0, err)
return "", false, err
}

imageName := fmt.Sprintf("%s/%s:%s", settings.Cnf.Registry, settings.Cnf.Name, settings.Cnf.Tag)
PrintVerboseInfo("OCI.HasUpdate", "checking image: ", imageName)

_, newDigest, err := pt.PullManifestOnly(imageName)
if err != nil {
PrintVerboseErr("OCI.HasUpdate", 1, err)
return "", false, err
}

if newDigest == oldDigest {
PrintVerboseInfo("OCI.HasUpdate", "no update available")
return "", false, nil
}

PrintVerboseInfo("OCI.HasUpdate", "update available. Old digest: ", oldDigest, ", new digest: ", newDigest)
return newDigest, true, nil
}
3 changes: 2 additions & 1 deletion core/package-diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import (
"net/http"
"strings"

digest "github.com/opencontainers/go-digest"
"github.com/vanilla-os/abroot/extras/dpkg"
"github.com/vanilla-os/abroot/settings"
"github.com/vanilla-os/differ/diff"
)

// BaseImagePackageDiff retrieves the added, removed, upgraded and downgraded
// base packages (the ones bundled with the image).
func BaseImagePackageDiff(currentDigest, newDigest string) (
func BaseImagePackageDiff(currentDigest, newDigest digest.Digest) (
added, upgraded, downgraded, removed []diff.PackageDiff,
err error,
) {
Expand Down
229 changes: 0 additions & 229 deletions core/registry.go

This file was deleted.

Loading