Skip to content

Commit

Permalink
Fix confusing prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolmin committed Aug 7, 2023
1 parent fdc1c19 commit 9d172bb
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions dependencies/clients/teku.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,11 @@ func (t *TekuClient) Install(url string, isUpdate bool) (err error) {
}
}

err = installAndUntarFromURL(url)
err = installAndUntarFromURL(url, t.name, isUpdate)
if err != nil {
return
}

switch isUpdate {
case true:
log.Infof("✅ %s updated!\n\n", t.Name())
case false:
log.Infof("✅ %s downloaded!\n\n", t.Name())
}

_, isInstalled := os.LookupEnv(system.JavaHomeEnv) // means that JDk is not set up
if !isInstalled {
message := "Teku is written in Java. This means that to use it you need to have:\n" +
Expand All @@ -96,7 +89,7 @@ func (t *TekuClient) Install(url string, isUpdate bool) (err error) {
return
}

err = setupJava()
err = setupJava(isUpdate)
if err != nil {
return
}
Expand Down Expand Up @@ -246,7 +239,7 @@ func untarDir(dst string, t *tar.Reader) error {
return nil
}

func setupJava() (err error) {
func setupJava(isUpdate bool) (err error) {
log.Info("⬇️ Downloading JDK...")

var systemOs, arch string
Expand All @@ -258,16 +251,20 @@ func setupJava() (err error) {
}

arch = system.GetArch()
if arch != "aarch64" && arch != "x86_64" {
log.Warnf("⚠️ x86_64 or aarch64 architecture is required to continue - skipping installation...")

if arch == "x86_64" {
arch = "x64"
}
if arch != "aarch64" && arch != "x64" {
log.Warnf("⚠️ x64 or aarch64 architecture is required to continue - defaulting ...")

return
}

jdkURL := strings.Replace(jdkInstallURL, "|OS|", systemOs, -1)
jdkURL = strings.Replace(jdkURL, "|ARCH|", arch, -1)

err = installAndUntarFromURL(jdkURL)
err = installAndUntarFromURL(jdkURL, "JDK", isUpdate)
if err != nil {
return err
}
Expand All @@ -289,7 +286,7 @@ func setupJava() (err error) {
return
}

func installAndUntarFromURL(url string) (err error) {
func installAndUntarFromURL(url, name string, isUpdate bool) (err error) {
response, err := http.Get(url)
if nil != err {
return
Expand Down Expand Up @@ -329,6 +326,13 @@ func installAndUntarFromURL(url string) (err error) {
return
}

switch isUpdate {
case true:
log.Infof("✅ %s updated!\n\n", name)
case false:
log.Infof("✅ %s downloaded!\n\n", name)
}

return
}

Expand Down

0 comments on commit 9d172bb

Please sign in to comment.