in fast-build-update-tool/internal/tools/update_script_generator.go [34:62]
func (i *InstanceUpdateScriptGenerator) GenerateScript(ctx context.Context, operatingSystem config.OperatingSystem, executableNames []string) (filname string, err error) {
// Actually create a file to write the update script contents to
i.tempBuildFile, err = os.CreateTemp("", "*"+string(config.UpdateScriptForOperatingSystem(operatingSystem)))
if err != nil {
return "", fmt.Errorf("error creating temporary file for server update script %w", err)
}
defer i.tempBuildFile.Close()
// Generate the update script
switch operatingSystem {
case config.OperatingSystemLinux:
err = generateLinuxUpdateScript(i.tempBuildFile, executableNames, i.localBuildZipPath, i.lockName, i.updateOperation)
if err != nil {
return "", fmt.Errorf("error generating server update script %w", err)
}
case config.OperatingSystemWindows:
err = generateWindowsUpdateScript(i.tempBuildFile, executableNames, i.localBuildZipPath, i.lockName, i.updateOperation)
if err != nil {
return "", fmt.Errorf("error generating server update script %w", err)
}
default:
return "", config.UnknownOperatingSystemError(fmt.Sprint(operatingSystem))
}
// Return the filepath
return i.tempBuildFile.Name(), nil
}