feat: publish verifiable proxyctl v1
This commit is contained in:
+22
-4
@@ -27,6 +27,9 @@ import (
|
||||
"proxyctl/internal/tui"
|
||||
)
|
||||
|
||||
// version is overridden for releases with -ldflags "-X main.version=<version>".
|
||||
var version = "dev"
|
||||
|
||||
func main() {
|
||||
if err := run(os.Args[1:], os.Stdin, os.Stdout); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "proxyctl:", err)
|
||||
@@ -50,11 +53,17 @@ func runWithSystemTargets(args []string, input io.Reader, output io.Writer, syst
|
||||
|
||||
type processEnvironment struct{}
|
||||
|
||||
var (
|
||||
processCurrentUser = profile.SystemCurrentUser
|
||||
processLookupUser = profile.SystemLookupUser
|
||||
processProductionTargets = productionTargets
|
||||
)
|
||||
|
||||
func (processEnvironment) CurrentUser() (profile.UserIdentity, error) {
|
||||
return profile.SystemCurrentUser()
|
||||
return processCurrentUser()
|
||||
}
|
||||
func (processEnvironment) LookupUser(name string) (profile.UserIdentity, error) {
|
||||
return profile.SystemLookupUser(name)
|
||||
return processLookupUser(name)
|
||||
}
|
||||
func (processEnvironment) LookupEnv(name string) (string, bool) { return os.LookupEnv(name) }
|
||||
|
||||
@@ -63,6 +72,15 @@ func runWithEnvironment(args []string, input io.Reader, output io.Writer, enviro
|
||||
}
|
||||
|
||||
func runWithEnvironmentAndTargets(args []string, input io.Reader, output io.Writer, environment profile.IdentityEnvironment, files shell.FileSystem, executable string, systemTargets []target.Target) error {
|
||||
if len(args) == 1 && args[0] == "version" {
|
||||
fmt.Fprintf(output, "proxyctl version %s\n", version)
|
||||
return nil
|
||||
}
|
||||
if len(args) == 2 && args[0] == "version" && args[1] == "--short" {
|
||||
fmt.Fprintln(output, version)
|
||||
return nil
|
||||
}
|
||||
|
||||
profileConfiguration, err := profile.ResolveConfiguration(environment)
|
||||
if err != nil {
|
||||
if len(args) == 1 && args[0] == "doctor" {
|
||||
@@ -79,7 +97,7 @@ func runWithEnvironmentAndTargets(args []string, input io.Reader, output io.Writ
|
||||
}
|
||||
shellTarget := shell.New(shellConfiguration, files, environment)
|
||||
if systemTargets == nil {
|
||||
systemTargets, err = productionTargets(environment)
|
||||
systemTargets, err = processProductionTargets(environment)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -129,7 +147,7 @@ func runWithEnvironmentAndTargets(args []string, input io.Reader, output io.Writ
|
||||
case len(args) == 1 && args[0] == "reset":
|
||||
return runMaintenanceCommand(args, input, output, store, targets, mutationLock, logger, nil)
|
||||
default:
|
||||
return fmt.Errorf("usage: proxyctl [doctor|reset|shell install|shell uninstall]")
|
||||
return fmt.Errorf("usage: proxyctl [version [--short]|doctor|reset|shell install|shell uninstall]")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user