Skip to content

Commit

Permalink
fix(kubernetes): add code back required that was marked as duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Oct 26, 2024
1 parent ab85b24 commit 1e8186c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/source/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *GitHub) Run(ctx context.Context) error {
}

// sourceRun - run the source specific logic
func (s *GitHub) sourceRun(ctx context.Context) error {
func (s *GitHub) sourceRun(ctx context.Context) error { //nolint:dupl
cacheFile := filepath.Join(s.Options.Config.GetMetadataPath(), fmt.Sprintf("cache-%s", s.GetID()))

s.client = github.NewClient(httpcache.NewTransport(diskcache.New(cacheFile)).Client())
Expand Down
29 changes: 28 additions & 1 deletion pkg/source/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"fmt"
"path/filepath"

"github.com/apex/log"
"github.com/google/go-github/v66/github"
"github.com/gregjones/httpcache"
"github.com/gregjones/httpcache/diskcache"

"github.com/ekristen/distillery/pkg/asset"
)

Expand All @@ -26,7 +31,7 @@ func (s *Kubernetes) GetRepo() string {
return s.Repo
}
func (s *Kubernetes) GetApp() string {
return fmt.Sprintf("%s/%s", s.Owner, s.Repo)
return fmt.Sprintf("%s/%s", s.Owner, s.AppName)
}
func (s *Kubernetes) GetID() string {
return fmt.Sprintf("%s-%s", s.GetSource(), s.GetRepo())
Expand All @@ -36,6 +41,28 @@ func (s *Kubernetes) GetDownloadsDir() string {
return filepath.Join(s.Options.Config.GetDownloadsPath(), s.GetSource(), s.GetOwner(), s.GetRepo(), s.Version)
}

// sourceRun - run the source specific logic (note this is duplicate because of the GetReleaseAssets override)
func (s *Kubernetes) sourceRun(ctx context.Context) error { //nolint:dupl
cacheFile := filepath.Join(s.Options.Config.GetMetadataPath(), fmt.Sprintf("cache-%s", s.GetID()))

s.client = github.NewClient(httpcache.NewTransport(diskcache.New(cacheFile)).Client())
githubToken := s.Options.Settings["github-token"].(string)
if githubToken != "" {
log.Debug("auth token provided")
s.client = s.client.WithAuthToken(githubToken)
}

if err := s.FindRelease(ctx); err != nil {
return err
}

if err := s.GetReleaseAssets(ctx); err != nil {
return err
}

return nil
}

func (s *Kubernetes) GetReleaseAssets(_ context.Context) error {
binName := fmt.Sprintf("%s-%s-%s-%s", s.AppName, s.Version, s.GetOS(), s.GetArch())
s.Assets = append(s.Assets, &KubernetesAsset{
Expand Down

0 comments on commit 1e8186c

Please sign in to comment.