Skip to content

Commit 66cc63a

Browse files
authored
Merge pull request #36 from ekristen/fix-kubernetes
fix: kubernetes
2 parents ab85b24 + c043bf0 commit 66cc63a

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

pkg/commands/install/install.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"path/filepath"
77
"runtime"
88
"strings"
9+
"time"
910

1011
"github.com/apex/log"
1112
"github.com/urfave/cli/v2"
@@ -16,6 +17,8 @@ import (
1617
)
1718

1819
func Execute(c *cli.Context) error {
20+
start := time.Now().UTC()
21+
1922
cfg, err := config.New(c.String("config"))
2023
if err != nil {
2124
return err
@@ -61,7 +64,9 @@ func Execute(c *cli.Context) error {
6164
return err
6265
}
6366

64-
log.Infof("installation complete")
67+
elapsed := time.Since(start)
68+
69+
log.Infof("installation complete in %s", elapsed)
6570

6671
return nil
6772
}

pkg/source/github.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (s *GitHub) Run(ctx context.Context) error {
7171
}
7272

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

7777
s.client = github.NewClient(httpcache.NewTransport(diskcache.New(cacheFile)).Client())

pkg/source/kubernetes.go

+28-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import (
55
"fmt"
66
"path/filepath"
77

8+
"github.com/apex/log"
9+
"github.com/google/go-github/v66/github"
10+
"github.com/gregjones/httpcache"
11+
"github.com/gregjones/httpcache/diskcache"
12+
813
"github.com/ekristen/distillery/pkg/asset"
914
)
1015

@@ -26,7 +31,7 @@ func (s *Kubernetes) GetRepo() string {
2631
return s.Repo
2732
}
2833
func (s *Kubernetes) GetApp() string {
29-
return fmt.Sprintf("%s/%s", s.Owner, s.Repo)
34+
return fmt.Sprintf("%s/%s", s.Owner, s.AppName)
3035
}
3136
func (s *Kubernetes) GetID() string {
3237
return fmt.Sprintf("%s-%s", s.GetSource(), s.GetRepo())
@@ -36,6 +41,28 @@ func (s *Kubernetes) GetDownloadsDir() string {
3641
return filepath.Join(s.Options.Config.GetDownloadsPath(), s.GetSource(), s.GetOwner(), s.GetRepo(), s.Version)
3742
}
3843

44+
// sourceRun - run the source specific logic (note this is duplicate because of the GetReleaseAssets override)
45+
func (s *Kubernetes) sourceRun(ctx context.Context) error { //nolint:dupl
46+
cacheFile := filepath.Join(s.Options.Config.GetMetadataPath(), fmt.Sprintf("cache-%s", s.GetID()))
47+
48+
s.client = github.NewClient(httpcache.NewTransport(diskcache.New(cacheFile)).Client())
49+
githubToken := s.Options.Settings["github-token"].(string)
50+
if githubToken != "" {
51+
log.Debug("auth token provided")
52+
s.client = s.client.WithAuthToken(githubToken)
53+
}
54+
55+
if err := s.FindRelease(ctx); err != nil {
56+
return err
57+
}
58+
59+
if err := s.GetReleaseAssets(ctx); err != nil {
60+
return err
61+
}
62+
63+
return nil
64+
}
65+
3966
func (s *Kubernetes) GetReleaseAssets(_ context.Context) error {
4067
binName := fmt.Sprintf("%s-%s-%s-%s", s.AppName, s.Version, s.GetOS(), s.GetArch())
4168
s.Assets = append(s.Assets, &KubernetesAsset{

0 commit comments

Comments
 (0)