Skip to content

Commit

Permalink
Log searched assets #149 (#159)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Vaumoron <dvaumoron@gmail.com>
  • Loading branch information
dvaumoron authored Jun 7, 2024
1 parent 44d6d47 commit 2480a97
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/apimsg/apimsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ package apimsg
import "errors"

const (
AssetsName = "assets"
MsgFetchAllReleases = "Fetching all releases information from "
MsgFetchRelease = "Fetching release information from "
MsgSearch = "Search"
)

var (
Expand Down
5 changes: 5 additions & 0 deletions versionmanager/retriever/atmos/atmosretriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"runtime"
"strings"

"github.com/hashicorp/go-hclog"
"github.com/tofuutils/tenv/config"
"github.com/tofuutils/tenv/pkg/apimsg"
sha256check "github.com/tofuutils/tenv/pkg/check/sha256"
Expand Down Expand Up @@ -63,6 +64,10 @@ func (r AtmosRetriever) InstallRelease(versionStr string, targetPath string) err

var assetURLs []string
fileName, shaFileName := buildAssetNames(versionStr, r.conf.Arch)
if r.conf.Displayer.IsDebug() {
r.conf.Displayer.Log(hclog.Debug, apimsg.MsgSearch, apimsg.AssetsName, []string{fileName, shaFileName})
}

switch r.conf.Atmos.GetInstallMode() {
case config.InstallModeDirect:
baseAssetURL, err2 := url.JoinPath(r.conf.Atmos.GetRemoteURL(), cloudposseName, config.AtmosName, github.Releases, github.Download, tag) //nolint
Expand Down
9 changes: 9 additions & 0 deletions versionmanager/retriever/terraform/terraformretriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"runtime"
"strings"

"github.com/hashicorp/go-hclog"
"github.com/tofuutils/tenv/config"
"github.com/tofuutils/tenv/pkg/apimsg"
pgpcheck "github.com/tofuutils/tenv/pkg/check/pgp"
Expand Down Expand Up @@ -71,6 +72,10 @@ func (r TerraformRetriever) InstallRelease(version string, targetPath string) er
switch r.conf.Tf.GetInstallMode() {
case config.InstallModeDirect:
fileName, shaFileName, shaSigFileName = buildAssetNames(version, r.conf.Arch)
if r.conf.Displayer.IsDebug() {
r.conf.Displayer.Log(hclog.Debug, apimsg.MsgSearch, apimsg.AssetsName, []string{fileName, shaFileName, shaSigFileName})
}

assetURLs, err := htmlretriever.BuildAssetURLs(baseVersionURL, fileName, shaFileName, shaSigFileName)
if err != nil {
return err
Expand All @@ -95,6 +100,10 @@ func (r TerraformRetriever) InstallRelease(version string, targetPath string) er
return err
}

if r.conf.Displayer.IsDebug() {
r.conf.Displayer.Log(hclog.Debug, apimsg.MsgSearch, apimsg.AssetsName, []string{fileName, shaFileName, shaSigFileName})
}

assetURLs, err := htmlretriever.BuildAssetURLs(baseVersionURL, shaFileName, shaSigFileName)
if err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions versionmanager/retriever/terragrunt/terragruntretriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"runtime"
"strings"

"github.com/hashicorp/go-hclog"
"github.com/tofuutils/tenv/config"
"github.com/tofuutils/tenv/pkg/apimsg"
sha256check "github.com/tofuutils/tenv/pkg/check/sha256"
Expand Down Expand Up @@ -60,6 +61,10 @@ func (r TerragruntRetriever) InstallRelease(versionStr string, targetPath string

var assetURLs []string
fileName, shaFileName := buildAssetNames(r.conf.Arch)
if r.conf.Displayer.IsDebug() {
r.conf.Displayer.Log(hclog.Debug, apimsg.MsgSearch, apimsg.AssetsName, []string{fileName, shaFileName})
}

switch r.conf.Tg.GetInstallMode() {
case config.InstallModeDirect:
baseAssetURL, err2 := url.JoinPath(r.conf.Tg.GetRemoteURL(), gruntworkName, config.TerragruntName, github.Releases, github.Download, tag) //nolint
Expand Down
5 changes: 5 additions & 0 deletions versionmanager/retriever/tofu/tofuretriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"runtime"
"strings"

"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-version"
"github.com/tofuutils/tenv/config"
"github.com/tofuutils/tenv/pkg/apimsg"
Expand Down Expand Up @@ -76,6 +77,10 @@ func (r TofuRetriever) InstallRelease(versionStr string, targetPath string) erro

var assetURLs []string
assetNames := buildAssetNames(versionStr, r.conf.Arch, stable)
if r.conf.Displayer.IsDebug() {
r.conf.Displayer.Log(hclog.Debug, apimsg.MsgSearch, apimsg.AssetsName, assetNames)
}

switch r.conf.Tofu.GetInstallMode() {
case config.InstallModeDirect:
baseAssetURL, err2 := url.JoinPath(r.conf.Tofu.GetRemoteURL(), opentofu, opentofu, github.Releases, github.Download, tag) //nolint
Expand Down

0 comments on commit 2480a97

Please sign in to comment.