diff --git a/pkg/commands/install/install.go b/pkg/commands/install/install.go index 8c8c31d..0256ca1 100644 --- a/pkg/commands/install/install.go +++ b/pkg/commands/install/install.go @@ -6,6 +6,7 @@ import ( "path/filepath" "runtime" "strings" + "time" "github.com/apex/log" "github.com/urfave/cli/v2" @@ -16,6 +17,8 @@ import ( ) func Execute(c *cli.Context) error { + start := time.Now().UTC() + cfg, err := config.New(c.String("config")) if err != nil { return err @@ -61,7 +64,9 @@ func Execute(c *cli.Context) error { return err } - log.Infof("installation complete") + elapsed := time.Since(start) + + log.Infof("installation complete in %s", elapsed) return nil } diff --git a/pkg/source/github.go b/pkg/source/github.go index 9d70460..94198fc 100644 --- a/pkg/source/github.go +++ b/pkg/source/github.go @@ -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()) diff --git a/pkg/source/kubernetes.go b/pkg/source/kubernetes.go index 0359137..1266ed1 100644 --- a/pkg/source/kubernetes.go +++ b/pkg/source/kubernetes.go @@ -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" ) @@ -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()) @@ -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{