refactor: remove use of IP and PORT files from core-post-deploy plugin
This commit is contained in:
committed by
Michael Hobbs
parent
7fe2f8593c
commit
dc00542b6f
@@ -374,6 +374,21 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
# TODO
|
||||
```
|
||||
|
||||
### `network-config-exists`
|
||||
|
||||
- Description: Returns whether the network configuration for a given app exists
|
||||
- Invoked by: `internally triggered by core-post-deploy within proxy implementations`
|
||||
- Arguments: `$APP`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
# TODO
|
||||
```
|
||||
|
||||
### `network-get-ipaddr`
|
||||
|
||||
- Description: Return the ipaddr for a given app container
|
||||
|
||||
@@ -9,7 +9,7 @@ build-in-docker: clean
|
||||
|
||||
build: commands subcommands triggers
|
||||
subcommands: subcommands/rebuild subcommands/rebuildall
|
||||
triggers: network-build-config network-compute-ports network-get-ipaddr network-get-listeners network-get-port network-write-ipaddr network-write-port
|
||||
triggers: network-build-config network-compute-ports network-config-exists network-get-ipaddr network-get-listeners network-get-port network-write-ipaddr network-write-port
|
||||
commands: **/**/commands.go
|
||||
go build -a -o commands src/commands/commands.go
|
||||
|
||||
@@ -25,6 +25,9 @@ network-build-config: **/**/**/network-build-config.go
|
||||
network-compute-ports: **/**/**/network-compute-ports.go
|
||||
go build -a -o network-compute-ports src/triggers/network-compute-ports/network-compute-ports.go
|
||||
|
||||
network-config-exists: **/**/**/network-config-exists.go
|
||||
go build -a -o network-config-exists src/triggers/network-config-exists/network-config-exists.go
|
||||
|
||||
network-get-ipaddr: **/**/**/network-get-ipaddr.go
|
||||
go build -a -o network-get-ipaddr src/triggers/network-get-ipaddr/network-get-ipaddr.go
|
||||
|
||||
|
||||
@@ -76,6 +76,15 @@ func GetContainerPort(appName string, procType string, isHerokuishContainer bool
|
||||
return port
|
||||
}
|
||||
|
||||
// HasNetworkConfig returns whether the network configuration for a given app exists
|
||||
func HasNetworkConfig(appName string) bool {
|
||||
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
|
||||
ipfile := fmt.Sprintf("%v/IP.web.1", appRoot)
|
||||
portfile := fmt.Sprintf("%v/PORT.web.1", appRoot)
|
||||
|
||||
return common.FileExists(ipfile) && common.FileExists(portfile)
|
||||
}
|
||||
|
||||
// BuildConfig builds network config files
|
||||
func BuildConfig(appName string) {
|
||||
err := common.VerifyAppName(appName)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
// write the ipaddress to stdout for a given app container
|
||||
func main() {
|
||||
flag.Parse()
|
||||
appName := flag.Arg(0)
|
||||
|
||||
if network.HasNetworkConfig(appName) {
|
||||
fmt.Fprintln(os.Stdout, "true")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintln(os.Stdout, "false")
|
||||
}
|
||||
@@ -9,7 +9,10 @@ nginx_core_post_deploy() {
|
||||
declare desc="nginx-vhosts core-post-deploy plugin trigger"
|
||||
local trigger="nginx_core_post_deploy"
|
||||
local APP="$1"
|
||||
if [[ -f "$DOKKU_ROOT/$APP/IP.web.1" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT.web.1" ]]; then
|
||||
local HAS_NETWORK_CONFIG
|
||||
|
||||
HAS_NETWORK_CONFIG="$(plugn trigger network-config-exists "$APP")"
|
||||
if [[ "$HAS_NETWORK_CONFIG" == "true" ]]; then
|
||||
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
|
||||
dokku_log_info1 "VHOST support disabled. Skipping domains setup"
|
||||
elif [[ ! -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user