Skip to content

Commit

Permalink
Merge pull request #12 from NYTimes/include_drone_field
Browse files Browse the repository at this point in the history
Added CronFile field to GAE and related funcs for handling said field
  • Loading branch information
jprobinson authored Jun 26, 2017
2 parents 5cffd67 + 6c78478 commit 086c903
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ type GAE struct {
// helpful to have a different `app.yaml` file per project for different environment
// and autoscaling configurations.
AppFile string `json:"app_file"`

// CronFile is the name of the cron.yaml file to use for this deployment. This field
// is only required if your cron.yaml file is not named 'cron.yaml'
CronFile string `json:"cron_file"`

// Dir points to the directory the application exists in. This is only required if
// you application is not in the base directory.
Dir string `json:"dir"`
Expand Down Expand Up @@ -215,6 +220,10 @@ func runGcloud(runner *Environ, workspace plugin.Workspace, vargs GAE) error {
return err
}

if err := setupCronFile(workspace, vargs); err != nil {
return err
}

err := runner.Run(vargs.GCloudCmd, args...)
if err != nil {
return fmt.Errorf("error: %s\n", err)
Expand Down Expand Up @@ -265,6 +274,10 @@ func runAppCfg(runner *Environ, workspace plugin.Workspace, vargs GAE) error {
return err
}

if err = setupCronFile(workspace, vargs); err != nil {
return err
}

err = runner.Run(vargs.AppCfgCmd, args...)
if err != nil {
return fmt.Errorf("error: %s\n", err)
Expand Down Expand Up @@ -301,6 +314,19 @@ func setupAppFile(workspace plugin.Workspace, vargs GAE) error {
return nil
}

// Useful for differentiating between prd and dev cron versions for GCP appengine
func setupCronFile(workspace plugin.Workspace, vargs GAE) error {
if vargs.CronFile != "cron.yaml" && vargs.CronFile != "" {
orig := filepath.Join(workspace.Path, vargs.Dir, vargs.CronFile)
dest := filepath.Join(workspace.Path, vargs.Dir, "cron.yaml")
err := copyFile(dest, orig)
if err != nil {
return fmt.Errorf("error moving cron file: %s\n", err)
}
}
return nil
}

func copyFile(dst, src string) error {
in, err := os.Open(src)
if err != nil {
Expand Down

0 comments on commit 086c903

Please sign in to comment.