forked from toolshed/abra
		
	refactor: tidy up a little
This commit is contained in:
		@ -216,15 +216,15 @@ checkout as-is. Recipe commit hashes are also supported as values for
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
		configs, err := client.GetConfigs(cl, context.Background(), app.Server, configFilters)
 | 
			
		||||
		configList, err := client.GetConfigs(cl, context.Background(), app.Server, configFilters)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
		configNames := client.GetConfigNames(configs)
 | 
			
		||||
		configNames := client.GetConfigNames(configList)
 | 
			
		||||
 | 
			
		||||
		var configInfo []string
 | 
			
		||||
		for _, config := range configNames {
 | 
			
		||||
			name, version := extractConfigNameMetadata(config, app.StackName())
 | 
			
		||||
			name, version := client.GetConfigNameAndVersion(config, app.StackName())
 | 
			
		||||
			configInfo = append(configInfo, fmt.Sprintf("%s: %s", name, version))
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -378,16 +378,6 @@ func getDeployVersion(cliArgs []string, deployMeta stack.DeployMeta, app app.App
 | 
			
		||||
	return v, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// extractConfigNameMetadata strips the stack name and returns 
 | 
			
		||||
// Example: "wordpress_db_password_v1" -> "v1"
 | 
			
		||||
func extractConfigNameMetadata(fullName string, stackName string) (string, string) {
 | 
			
		||||
	name := strings.TrimPrefix(fullName, stackName + "_")
 | 
			
		||||
	if lastUnderscore := strings.LastIndex(name, "_"); lastUnderscore != -1 {
 | 
			
		||||
		return name[0:lastUnderscore], name[lastUnderscore+1:]
 | 
			
		||||
	}
 | 
			
		||||
	return name, ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AppDeployCommand.Flags().BoolVarP(
 | 
			
		||||
		&internal.Chaos,
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ package client
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/pkg/i18n"
 | 
			
		||||
	"github.com/docker/docker/api/types/filters"
 | 
			
		||||
@ -37,3 +38,11 @@ func RemoveConfigs(cl *client.Client, ctx context.Context, configNames []string,
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetConfigNameAndVersion(fullName string, stackName string) (string, string) {
 | 
			
		||||
	name := strings.TrimPrefix(fullName, stackName + "_")
 | 
			
		||||
	if lastUnderscore := strings.LastIndex(name, "_"); lastUnderscore != -1 {
 | 
			
		||||
		return name[0:lastUnderscore], name[lastUnderscore+1:]
 | 
			
		||||
	}
 | 
			
		||||
	return name, ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user