github.com/datreeio/datree@v1.9.22-rc/pkg/upgradeManager/upgradeManager.go (about)

     1  package upgrademanager
     2  
     3  import (
     4  	"os"
     5  	"os/exec"
     6  	"runtime"
     7  	"strings"
     8  )
     9  
    10  type UpgradeManager struct {
    11  }
    12  
    13  func NewUpgradeManager() *UpgradeManager {
    14  	return &UpgradeManager{}
    15  }
    16  
    17  func (m *UpgradeManager) CheckIfDatreeInstalledUsingBrew() bool {
    18  	_, err := exec.Command("brew", "list", "datree").Output()
    19  	return err == nil
    20  }
    21  
    22  func (m *UpgradeManager) CheckIfOsIsWindows() bool {
    23  	return strings.Contains(runtime.GOOS, "windows")
    24  }
    25  
    26  func (m *UpgradeManager) Upgrade() error {
    27  	oneLineInstallationCommand := exec.Command("bash", "-c", "curl https://get.datree.io | /bin/bash")
    28  	oneLineInstallationCommand.Stdout = os.Stdout
    29  	oneLineInstallationCommand.Stderr = os.Stderr
    30  	return oneLineInstallationCommand.Run()
    31  }