Created
November 21, 2022 09:09
-
-
Save abserari/f7e941e1543b0eb319676a38a09b574e to your computer and use it in GitHub Desktop.
Go Install Binary Program in Dapr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// installBinary installs the daprd, placement or dashboard binaries and associated files inside the default dapr bin directory. | |
func installBinary(version, binaryFilePrefix, githubRepo string, info initInfo) error { | |
var ( | |
err error | |
filepath string | |
) | |
dir := defaultDaprBinPath() | |
if isAirGapInit { | |
filepath = path_filepath.Join(info.fromDir, *info.bundleDet.BinarySubDir, binaryName(binaryFilePrefix)) | |
} else { | |
filepath, err = downloadBinary(dir, version, binaryFilePrefix, githubRepo) | |
if err != nil { | |
return fmt.Errorf("error downloading %s binary: %w", binaryFilePrefix, err) | |
} | |
} | |
extractedFilePath, err := extractFile(filepath, dir, binaryFilePrefix) | |
if err != nil { | |
return err | |
} | |
// remove downloaded archive from the default dapr bin path. | |
if !isAirGapInit { | |
err = os.Remove(filepath) | |
if err != nil { | |
return fmt.Errorf("failed to remove archive: %w", err) | |
} | |
} | |
if binaryFilePrefix == "dashboard" { | |
extractedFilePath, err = moveDashboardFiles(extractedFilePath, dir) | |
if err != nil { | |
return err | |
} | |
} | |
binaryPath, err := moveFileToPath(extractedFilePath, dir) | |
if err != nil { | |
return fmt.Errorf("error moving %s binary to path: %w", binaryFilePrefix, err) | |
} | |
err = makeExecutable(binaryPath) | |
if err != nil { | |
return fmt.Errorf("error making %s binary executable: %w", binaryFilePrefix, err) | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SourceCode Read Path