Skip to content

Commit

Permalink
feat: support oci on other commands
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed Jan 31, 2024
1 parent 454121b commit cdd2dc9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
9 changes: 8 additions & 1 deletion internal/config/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@ func (u *Unit) Template(ctx context.Context, name, squadron, unit, namespace str
Args(u.PostRendererArgs()...).
Args("--values", "-").
Args(helmArgs...)

if strings.HasPrefix(u.Chart.Repository, "file://") {
cmd.Args(path.Clean(strings.TrimPrefix(u.Chart.Repository, "file://")))
} else {
cmd.Args(u.Chart.Name, "--repo", u.Chart.Repository, "--version", u.Chart.Version)
cmd.Args(u.Chart.Name)
if u.Chart.Repository != "" {
cmd.Args("--repo", u.Chart.Repository)
}
if u.Chart.Version != "" {
cmd.Args("--version", u.Chart.Version)
}
}
if out, err := cmd.Run(ctx); err != nil {
return nil, errors.Wrap(err, out)
Expand Down
18 changes: 13 additions & 5 deletions squadron.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"os/exec"
"path"
"slices"
"strings"
"sync"
Expand Down Expand Up @@ -364,10 +365,17 @@ func (sq *Squadron) Diff(ctx context.Context, helmArgs []string, parallel int) e
"--dry-run",
)
cmd.Stdin = bytes.NewReader(valueBytes)
if strings.Contains(v.Chart.Repository, "file://") {
cmd.Args = append(cmd.Args, "/"+strings.TrimPrefix(v.Chart.Repository, "file://"))

if strings.HasPrefix(v.Chart.Repository, "file://") {
cmd.Args = append(cmd.Args, path.Clean(strings.TrimPrefix(v.Chart.Repository, "file://")))
} else {
cmd.Args = append(cmd.Args, v.Chart.Name, "--repo", v.Chart.Repository, "--version", v.Chart.Version)
cmd.Args = append(cmd.Args, v.Chart.Name)
if v.Chart.Repository != "" {
cmd.Args = append(cmd.Args, "--repo", v.Chart.Repository)
}
if v.Chart.Version != "" {
cmd.Args = append(cmd.Args, "--version", v.Chart.Version)
}
}
cmd.Args = append(cmd.Args, helmArgs...)
out, err := cmd.CombinedOutput()
Expand Down Expand Up @@ -551,8 +559,8 @@ func (sq *Squadron) Up(ctx context.Context, helmArgs []string, username, version
Args("--values", "-").
Args(helmArgs...)

if strings.Contains(v.Chart.Repository, "file://") {
cmd.Args(strings.TrimPrefix(v.Chart.Repository, "file://"))
if strings.HasPrefix(v.Chart.Repository, "file://") {
cmd.Args(path.Clean(strings.TrimPrefix(v.Chart.Repository, "file://")))
} else {
cmd.Args(v.Chart.Name)
if v.Chart.Repository != "" {
Expand Down

0 comments on commit cdd2dc9

Please sign in to comment.