Skip to content

Commit

Permalink
Allow airflow webserver port to be configurable locally (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
andscoop authored Nov 16, 2018
1 parent e5619d2 commit b37cb74
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions airflow/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func generateConfig(projectName, airflowHome string) (string, error) {
AirflowImage: imageName(projectName, "latest"),
AirflowHome: airflowHome,
AirflowUser: "astro",
AirflowWebserverPort: "8080",
AirflowWebserverPort: config.CFG.WebserverPort.GetString(),
}

buff := new(bytes.Buffer)
Expand Down Expand Up @@ -180,8 +180,8 @@ func Start(airflowHome string) error {
return errors.Wrap(err, messages.COMPOSE_RECREATE_ERROR)
}
}
fmt.Println(messages.COMPOSE_LINK_WEBSERVER)
fmt.Println(messages.COMPOSE_LINK_POSTGRES)
fmt.Printf(messages.COMPOSE_LINK_WEBSERVER+"\n", config.CFG.WebserverPort.GetString())
fmt.Printf(messages.COMPOSE_LINK_POSTGRES, config.CFG.PostgresPort.GetString())
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions airflow/include/composeyml.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ services:
- scheduler
- postgres
environment:
AIRFLOW__WEBSERVER__WEB_SERVER_PORT: {{ .AirflowWebserverPort }}
AIRFLOW__CORE__EXECUTOR: LocalExecutor
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql://{{ .PostgresUser }}:{{ .PostgresPassword }}@{{ .PostgresHost }}:{{ .PostgresPort }}
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
AIRFLOW__CORE__FERNET_KEY: "d6Vefz3G9U_ynXB3cr7y_Ak35tAHkEGAVxuz_B-jzWw="
ports:
- {{ .AirflowWebserverPort }}:{{ .AirflowWebserverPort }}
expose:
- {{ .AirflowWebserverPort }}
volumes:
- {{ .AirflowHome }}/dags:/usr/local/airflow/dags:ro
- {{ .AirflowHome }}/plugins:/usr/local/airflow/plugins:ro
Expand Down
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ var (

// CFG Houses configuration meta
CFG = cfgs{
Contexts: newCfg("contexts", ""),
CloudAPIProtocol: newCfg("cloud.api.protocol", "https"),
CloudAPIPort: newCfg("cloud.api.port", "443"),
CloudAPIToken: newCfg("cloud.api.token", ""),
Context: newCfg("context", ""),
Contexts: newCfg("contexts", ""),
LocalHouston: newCfg("local.houston", ""),
LocalOrbit: newCfg("local.orbit", ""),
PostgresUser: newCfg("postgres.user", "postgres"),
Expand All @@ -50,6 +50,7 @@ var (
ProjectDeployment: newCfg("project.deployment", ""),
ProjectName: newCfg("project.name", ""),
ProjectWorkspace: newCfg("project.workspace", ""),
WebserverPort: newCfg("webserver.port", "8080"),
}

// viperHome is the viper object in the users home directory
Expand Down
3 changes: 2 additions & 1 deletion config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ type cfg struct {

// cfgs houses all configurations for an astro project
type cfgs struct {
Contexts cfg
CloudAPIProtocol cfg
CloudAPIPort cfg
CloudAPIToken cfg
Context cfg
Contexts cfg
LocalEnabled cfg
LocalHouston cfg
LocalOrbit cfg
Expand All @@ -23,6 +23,7 @@ type cfgs struct {
ProjectName cfg
ProjectDeployment cfg
ProjectWorkspace cfg
WebserverPort cfg
}

// Creates a new cfg struct
Expand Down
4 changes: 2 additions & 2 deletions messages/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var (
COMPOSE_PAUSE_ERROR = "Error pausing project containers"
COMPOSE_RECREATE_ERROR = "Error building, (re)creating or starting project containers"
COMPOSE_PUSHING_IMAGE_PROMPT = "Pushing image to Astronomer registry"
COMPOSE_LINK_WEBSERVER = "Airflow Webserver: http://localhost:8080/admin/"
COMPOSE_LINK_POSTGRES = "Postgres Database: localhost:5432/postgres"
COMPOSE_LINK_WEBSERVER = "Airflow Webserver: http://localhost:%s/admin/"
COMPOSE_LINK_POSTGRES = "Postgres Database: localhost:%s/postgres"

HOUSTON_BASIC_AUTH_DISABLED = "Basic authentication is disabled, conact administrator or defer back to oAuth"
HOUSTON_DEPLOYMENT_HEADER = "Authenticated to %s \n\n"
Expand Down

0 comments on commit b37cb74

Please sign in to comment.