feat: simplify flag parsing in network plugin

Commands should be written such that they take arguments as is.
This commit is contained in:
Jose Diaz-Gonzalez
2020-05-28 20:30:27 -04:00
parent 94aa67d494
commit 91a668ee8f
3 changed files with 65 additions and 49 deletions

View File

@@ -25,17 +25,19 @@ var (
)
// BuildConfig builds network config files
func BuildConfig(appName string) {
func BuildConfig(appName string) error {
if err := common.VerifyAppName(appName); err != nil {
common.LogFail(err.Error())
return err
}
if !common.IsDeployed(appName) {
return
return nil
}
appRoot := common.AppRoot(appName)
scaleFile := strings.Join([]string{appRoot, "DOKKU_SCALE"}, "/")
if !common.FileExists(scaleFile) {
return
return nil
}
image := common.GetAppImageName(appName, "", "")
@@ -43,8 +45,9 @@ func BuildConfig(appName string) {
common.LogInfo1(fmt.Sprintf("Ensuring network configuration is in sync for %s", appName))
lines, err := common.FileToSlice(scaleFile)
if err != nil {
return
return err
}
for _, line := range lines {
if line == "" || strings.HasPrefix(line, "#") {
continue
@@ -91,6 +94,8 @@ func BuildConfig(appName string) {
}
}
}
return nil
}
// GetContainerIpaddress returns the ipaddr for a given app container