Skip to content

Commit

Permalink
feat: improve logging for detect command
Browse files Browse the repository at this point in the history
  • Loading branch information
kvendingoldo committed Jun 12, 2024
1 parent 8e3ce52 commit bb529da
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ terraform
terragrunt
tofu
atmos

./build/**
29 changes: 19 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# limitations under the License.
#

.PHONY: build test clean

##@ General
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
Expand All @@ -29,18 +31,25 @@ vet: ## Run go vet against code.

##@ Build
build: get fmt ## Build service binary.
go build -o tenv ./cmd/tenv
go build -o tofu ./cmd/tofu
go build -o terraform ./cmd/terraform
go build -o terragrunt ./cmd/terragrunt
go build -o atmos ./cmd/atmos

run: ## Run service from your laptop.
go run ./main.go

##@ Test
mkdir ./build || echo
go build -o ./build/tenv ./cmd/tenv
go build -o ./build/tofu ./cmd/tofu
go build -o ./build/terraform ./cmd/terraform
go build -o ./build/terragrunt ./cmd/terragrunt
go build -o ./build/atmos ./cmd/atmos

##@ Run
run: build ## Run service from your laptop.
./build/tenv

##@ Lint
lint: ## Run Go linter
golangci-lint run ./...

##@ Test
test: ## Run Go tests
go test ./...

##@ Clean
clean:
rm -f ./build
18 changes: 14 additions & 4 deletions versionmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ import (
)

var (
errEmptyVersion = errors.New("empty version")
errNoCompatible = errors.New("no compatible version found")
errEmptyVersion = errors.New("empty version")
errNoCompatible = errors.New("no compatible version found")
errNoCompatibleLocally = errors.New("no compatible version found locally")
)

type ReleaseInfoRetriever interface {
Expand Down Expand Up @@ -112,12 +113,21 @@ func (m VersionManager) Evaluate(requestedVersion string, proxyCall bool) (strin
}
}

m.conf.Displayer.Display("No compatible version found locally, search a remote one...")
if m.conf.NoInstall {
m.conf.Displayer.Flush(proxyCall)

return "", errNoCompatible
version, err := m.searchInstallRemote(predicateInfo, m.conf.NoInstall, proxyCall)
if err != nil {
//m.conf.Displayer.Display("Found compatible version installed locally : " + version)
return "", errNoCompatibleLocally
}

m.conf.Displayer.Display("Auto-install is disabled. To install " + version + " version you can set environment variable TENV_AUTO_INSTALL=true, or install it via any of the following command: 'tenv tf install', 'tenv tf install " + version + "'")

return "", errNoCompatibleLocally
}
m.conf.Displayer.Display("No compatible version found locally, search a remote one...")

}

return m.searchInstallRemote(predicateInfo, m.conf.NoInstall, proxyCall)
Expand Down

0 comments on commit bb529da

Please sign in to comment.