Skip to content

Commit

Permalink
refactor(db,javadb): add schema versions as tag only if repo doesn't …
Browse files Browse the repository at this point in the history
…contain tag
  • Loading branch information
DmitriyLewen committed Mar 6, 2024
1 parent 232c938 commit d8a0c03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"time"

"github.com/google/go-containerregistry/pkg/v1/remote/transport"
Expand Down Expand Up @@ -78,7 +79,10 @@ func NewClient(cacheDir string, quiet bool, opts ...Option) *Client {
opt(o)
}

o.dbRepository = fmt.Sprintf("%s:%d", o.dbRepository, db.SchemaVersion)
// Add the schema version as a tag if the tag doesn't exist.
if !strings.Contains(o.dbRepository, ":") {
o.dbRepository = fmt.Sprintf("%s:%d", o.dbRepository, db.SchemaVersion)
}

return &Client{
options: o,
Expand Down
7 changes: 6 additions & 1 deletion pkg/javadb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"sort"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -82,8 +83,12 @@ func (u *Updater) Update() error {
}

func Init(cacheDir, javaDBRepository string, skip, quiet bool, registryOption ftypes.RegistryOptions) {
// Add the schema version as a tag if the tag doesn't exist.
if !strings.Contains(javaDBRepository, ":") {
javaDBRepository = fmt.Sprintf("%s:%d", javaDBRepository, db.SchemaVersion)
}
updater = &Updater{
repo: fmt.Sprintf("%s:%d", javaDBRepository, db.SchemaVersion),
repo: javaDBRepository,
dbDir: filepath.Join(cacheDir, "java-db"),
skip: skip,
quiet: quiet,
Expand Down

0 comments on commit d8a0c03

Please sign in to comment.