Skip to content

Commit

Permalink
Hotfix for airflow init
Browse files Browse the repository at this point in the history
  • Loading branch information
andscoop committed May 9, 2018
1 parent 1c5d3f7 commit ff5f9ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 42 deletions.
56 changes: 16 additions & 40 deletions airflow/airflow.go
Expand Up @@ -11,37 +11,17 @@ import (
"github.com/iancoleman/strcase"

"github.com/astronomerio/astro-cli/airflow/include"
"github.com/astronomerio/astro-cli/config"
"github.com/astronomerio/astro-cli/houston"
"github.com/astronomerio/astro-cli/pkg/fileutil"
"github.com/astronomerio/astro-cli/pkg/httputil"
"github.com/astronomerio/astro-cli/config"
)

var (
http = httputil.NewHTTPClient()
api = houston.NewHoustonClient(http)
api = houston.NewHoustonClient(http)
)

func initProject(path string) {
// List of directories to create
dirs := []string{"dags", "plugins", "include"}

// Initailize directories
initDirs(path, dirs)

// Map of files to create
files := map[string]string{
".dockerignore": include.Dockerignore,
"Dockerfile": include.Dockerfile,
"packages.txt": "",
"requirements.txt": "",
"dags/example-dag.py": include.Exampledag,
}

// Initialize files
initFiles(path, files)
}

func initDirs(root string, dirs []string) bool {
// Any inputs exist
exists := false
Expand Down Expand Up @@ -91,28 +71,24 @@ func initFiles(root string, files map[string]string) bool {
}

// Init will scaffold out a new airflow project
func Init(projectName string) error {
// Grab working directory
path := fileutil.GetWorkingDir()

projectName, err := validateOrCreateProjectName(path, projectName)
if err != nil {
return err
}
func Init(path string) error {
// List of directories to create
dirs := []string{"dags", "plugins", "include"}

exists := config.ProjectConfigExists()
if !exists {
config.CreateProjectConfig(path)
// Map of files to create
files := map[string]string{
".dockerignore": include.Dockerignore,
"Dockerfile": include.Dockerfile,
"packages.txt": "",
"requirements.txt": "",
"dags/example-dag.py": include.Exampledag,
}
config.CFG.ProjectName.SetProjectString(projectName)

initProject(path)
// Initailize directories
initDirs(path, dirs)

if exists {
fmt.Printf("Reinitialized existing astronomer project in %s\n", path)
} else {
fmt.Printf("Initialized empty astronomer project in %s\n", path)
}
// Initialize files
initFiles(path, files)

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/airflow.go
Expand Up @@ -8,13 +8,13 @@ import (
"regexp"
"strings"

"github.com/spf13/cobra"
"github.com/iancoleman/strcase"
"github.com/spf13/cobra"

"github.com/astronomerio/astro-cli/airflow"
"github.com/astronomerio/astro-cli/config"
"github.com/astronomerio/astro-cli/pkg/git"
"github.com/astronomerio/astro-cli/pkg/fileutil"
"github.com/astronomerio/astro-cli/pkg/git"
)

var (
Expand Down

0 comments on commit ff5f9ac

Please sign in to comment.