forked from toolshed/abra
		
	refactor: NewClientWithContext -> New, and use server only
This commit is contained in:
		| @ -13,19 +13,20 @@ import ( | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| func getAppsHost(appName string) string { | ||||
| // getAppServer retrieves the server of an app. | ||||
| func getAppServer(appName string) string { | ||||
| 	appFiles, err := config.LoadAppFiles("") | ||||
| 	if err != nil { | ||||
| 		logrus.Fatal(err) | ||||
| 	} | ||||
|  | ||||
| 	var host string | ||||
| 	var server string | ||||
| 	if app, ok := appFiles[appName]; ok { | ||||
| 		host = app.Server | ||||
| 		server = app.Server | ||||
| 	} else { | ||||
| 		logrus.Fatalf(`app "%s" does not exist`, appName) | ||||
| 	} | ||||
| 	return host | ||||
| 	return server | ||||
| } | ||||
|  | ||||
| var appVolumeListCommand = &cli.Command{ | ||||
| @ -37,10 +38,10 @@ var appVolumeListCommand = &cli.Command{ | ||||
| 		if appName == "" { | ||||
| 			internal.ShowSubcommandHelpAndError(c, errors.New("no app name provided!")) | ||||
| 		} | ||||
| 		host := getAppsHost(appName) | ||||
|  | ||||
| 		ctx := context.Background() | ||||
| 		volumeList, err := client.GetVolumes(ctx, host, appName) | ||||
| 		server := getAppServer(appName) | ||||
| 		volumeList, err := client.GetVolumes(ctx, server, appName) | ||||
| 		if err != nil { | ||||
| 			logrus.Fatal(err) | ||||
| 		} | ||||
| @ -71,9 +72,9 @@ var appVolumeRemoveCommand = &cli.Command{ | ||||
| 		if appName == "" { | ||||
| 			internal.ShowSubcommandHelpAndError(c, errors.New("no app name provided!")) | ||||
| 		} | ||||
| 		host := getAppsHost(appName) | ||||
| 		server := getAppServer(appName) | ||||
| 		ctx := context.Background() | ||||
| 		volumeList, err := client.GetVolumes(ctx, host, appName) | ||||
| 		volumeList, err := client.GetVolumes(ctx, server, appName) | ||||
| 		if err != nil { | ||||
| 			logrus.Fatal(err) | ||||
| 		} | ||||
| @ -93,7 +94,7 @@ var appVolumeRemoveCommand = &cli.Command{ | ||||
| 			volumesToRemove = volumeNames | ||||
| 		} | ||||
|  | ||||
| 		err = client.RemoveVolumes(ctx, host, volumesToRemove, internal.Force) | ||||
| 		err = client.RemoveVolumes(ctx, server, volumesToRemove, internal.Force) | ||||
| 		if err != nil { | ||||
| 			logrus.Fatal(err) | ||||
| 		} | ||||
|  | ||||
		Reference in New Issue
	
	Block a user