Example #1
0
func (c *customizations) processGo(d *schema.FieldData) error {
	c.Opts.Bindata.Context["dev_go_version"] = d.Get("go_version")

	// Go is really finicky about the GOPATH. To help make the dev
	// environment and build environment more correct, we attempt to
	// detect the GOPATH automatically.
	//
	// We use this GOPATH for example in Vagrant to setup the synced
	// folder directly into the GOPATH properly. Magic!
	gopathPath := d.Get("import_path").(string)
	if gopathPath == "" {
		var err error
		c.Opts.Ctx.Ui.Header("Detecting application import path for GOPATH...")
		gopathPath, err = detectImportPath(c.Opts.Ctx)
		if err != nil {
			return err
		}
	}

	folderPath := "/vagrant"
	if gopathPath != "" {
		folderPath = "/opt/gopath/src/" + gopathPath
	}

	c.Opts.Bindata.Context["import_path"] = gopathPath
	c.Opts.Bindata.Context["shared_folder_path"] = folderPath

	return nil
}
Example #2
0
func (c *customizations) processRuby(d *schema.FieldData) error {
	vsn := d.Get("ruby_version")

	// If we were asked to detect the version, we attempt to do so.
	// If we can't detect it for non-erroneous reasons, we use our default.
	if vsn == "detect" {
		var err error
		c.Opts.Ctx.Ui.Header("Detecting Ruby version to use...")
		vsn, err = detectRubyVersionGemfile(filepath.Dir(c.Opts.Ctx.Appfile.Path))
		if err != nil {
			return err
		}
		if vsn != "" {
			c.Opts.Ctx.Ui.Message(fmt.Sprintf(
				"Detected desired Ruby version: %s", vsn))
		}
		if vsn == "" {
			vsn = defaultLatestVersion
			c.Opts.Ctx.Ui.Message(fmt.Sprintf(
				"No desired Ruby version found! Will use the default: %s", vsn))
		}
	}

	c.Opts.Bindata.Context["ruby_version"] = vsn
	return nil
}
Example #3
0
func (c *customizations) processDevDep(d *schema.FieldData) error {
	if _, ok := d.GetOk("vagrantfile"); !ok {
		return nil
	}

	c.Opts.Callbacks = append(c.Opts.Callbacks, c.compileCustomDevDep(d))
	return nil
}
func (c *customizations) process(d *schema.FieldData) error {
	c.Opts.Bindata.Context["node_version"] = d.Get("node_version")
	c.Opts.Bindata.Context["npm_version"] = d.Get("npm_version")
	c.Opts.Bindata.Context["port"] = d.Get("port")
	c.Opts.Bindata.Context["app_startup_file"] = d.Get("app_startup_file")
	c.Opts.Bindata.Context["env_variables"] = d.Get("env_variables")
	return nil
}
Example #5
0
func (c *customizations) processDevDep(d *schema.FieldData) error {
	cmd, err := c.Opts.Bindata.RenderString(d.Get("run_command").(string))
	if err != nil {
		return fmt.Errorf("Error processing 'run_command': %s", err)
	}

	c.Opts.Bindata.Context["dep_run_command"] = cmd
	return nil
}
Example #6
0
func (c *customizations) process(d *schema.FieldData) error {
	image := d.Get("image").(string)
	if image == "" {
		image = c.Opts.Ctx.Application.Name
	}

	c.Opts.Bindata.Context["docker_image"] = image
	c.Opts.Bindata.Context["run_args"] = d.Get("run_args").(string)
	return nil
}
Example #7
0
func (c *customizations) processDeploy(d *schema.FieldData) error {
	tf, ok := d.GetOk("terraform")
	if !ok {
		return nil
	}

	c.Opts.Bindata.Context["deploy_terraform_path"] = tf.(string)
	c.Opts.Callbacks = append(c.Opts.Callbacks, c.compileCustomDeploy(d))
	return nil
}
Example #8
0
func (c *customizations) processBuild(d *schema.FieldData) error {
	p, ok := d.GetOk("packer")
	if !ok {
		return nil
	}

	c.Opts.Bindata.Context["build_packer_path"] = p.(string)
	c.Opts.Callbacks = append(c.Opts.Callbacks, c.compileCustomBuild(d))
	return nil
}
Example #9
0
func (c *customizations) processDev(d *schema.FieldData) error {
	p, ok := d.GetOk("vagrant")
	if !ok {
		return nil
	}

	c.Opts.Bindata.Context["dev_vagrant_path"] = p.(string)
	c.Opts.Callbacks = append(c.Opts.Callbacks, c.compileCustomDev(d))
	return nil
}
Example #10
0
func (c *customizations) compileCustomDevDep(d *schema.FieldData) compile.CompileCallback {
	vf := d.Get("vagrantfile").(string)

	return func() error {
		if !filepath.IsAbs(vf) {
			vf = filepath.Join(filepath.Dir(c.Opts.Ctx.Appfile.Path), vf)
		}

		data := c.Opts.Bindata
		fragment := data.Context["fragment_path"].(string)
		if err := data.RenderReal(fragment, vf); err != nil {
			return err
		}

		return data.RenderAsset(
			filepath.Join(c.Opts.Ctx.Dir, "dev", "Vagrantfile"),
			"data/dev/Vagrantfile.tpl")
	}
}
Example #11
0
func (c *customizations) process(d *schema.FieldData) error {
	if p, ok := d.GetOk("packer"); ok {
		c.Opts.Bindata.Context["build_packer_path"] = p.(string)
		c.Opts.Callbacks = append(c.Opts.Callbacks, c.compileCustomBuild(d))
	}

	if tf, ok := d.GetOk("terraform"); ok {
		c.Opts.Bindata.Context["deploy_terraform_path"] = tf.(string)
		c.Opts.Callbacks = append(c.Opts.Callbacks, c.compileCustomDeploy(d))
	}

	if p, ok := d.GetOk("dev_vagrantfile"); ok {
		c.Opts.Bindata.Context["dev_vagrant_path"] = p.(string)
		c.Opts.Callbacks = append(c.Opts.Callbacks, c.compileCustomDev(d))
	}

	if _, ok := d.GetOk("dep_vagrantfile"); ok {
		c.Opts.Callbacks = append(c.Opts.Callbacks, c.compileCustomDevDep(d))
	}

	return nil
}
Example #12
0
func (c *customizations) processRuby(d *schema.FieldData) error {
	c.Opts.Bindata.Context["ruby_version"] = d.Get("ruby_version")
	return nil
}
Example #13
0
func (c *customizations) processDev(d *schema.FieldData) error {
	c.Opts.Bindata.Context["dev_node_version"] = d.Get("node_version")
	return nil
}
Example #14
0
func (c *customizations) processDev(d *schema.FieldData) error {
	c.Opts.Bindata.Context["gradle_version"] = d.Get("gradle_version")
	c.Opts.Bindata.Context["maven_version"] = d.Get("maven_version")
	return nil
}
Example #15
0
func (c *customizations) process(d *schema.FieldData) error {
	c.Opts.Bindata.Context["python_version"] = d.Get("python_version")
	c.Opts.Bindata.Context["python_entrypoint"] = d.Get("python_entrypoint")
	return nil
}