func (p *Project) Generate(clientset *client.ConfigSet) error {
	p.Runtime = strings.TrimLeft(p.Runtime, "-")
	samples := NewTable()
	if p.Runtime == "" || p.Runtime == "h" || p.Runtime == "help" {
		return p.help(samples)
	}
	sample, exist := (*samples)[p.Runtime]
	if !exist {
		return p.help(samples)
	}
	var buildArgs []string
	if sample.handler != "" {
		buildArgs = append(buildArgs, fmt.Sprintf("HANDLER=%s", sample.handler))
	}
	provider := file.TriggermeshProvider{
		Name: "triggermesh",
	}
	functionName := fmt.Sprintf("%s-function", p.Runtime)
	functions := map[string]file.Function{
		functionName: {
			Source:    sample.source,
			Runtime:   sample.runtime,
			Buildargs: buildArgs,
			Environment: map[string]string{
				"foo": "bar",
			},
		},
	}
	if sample.apiGateway {
		functions[functionName].Environment["EVENT"] = "API_GATEWAY"
	}
	template := file.Definition{
		Service:     p.Name,
		Description: "Sample knative service",
		Provider:    provider,
		Functions:   functions,
	}
	if template.Service == "" {
		template.Service = fmt.Sprintf("%s-demo-service", p.Runtime)
	}
	manifest, err := yaml.Marshal(&template)
	if err != nil {
		return err
	}
	if client.Dry {
		fmt.Printf("%s/%s:\n---\n%s\n\n", p.Runtime, sample.source, sample.function)
		fmt.Printf("%s/%s:\n---\n%s\n", p.Runtime, manifestName, manifest)
		return nil
	}
	path := p.Name
	if path == "" {
		path = p.Runtime
	}
	if err := file.MakeDir(path); err != nil {
		return err
	}
	for _, dep := range sample.dependencies {
		if err := file.Write(fmt.Sprintf("%s/%s", path, dep.name), dep.data); err != nil {
			return fmt.Errorf("writing dependencies to file: %s", err)
		}
	}
	if err := file.Write(fmt.Sprintf("%s/%s", path, sample.source), sample.function); err != nil {
		return fmt.Errorf("writing function to file: %s", err)
	}
	if err := file.Write(fmt.Sprintf("%s/%s", path, manifestName), string(manifest)); err != nil {
		return fmt.Errorf("writing manifest to file: %s", err)
	}
	fmt.Printf("Sample %s project has been created\n", p.Runtime)
	fmt.Printf("%s/%s\t\t- function code\n%s/%s\t\t- service manifest\n", path, sample.source, path, manifestName)
	fmt.Printf("You can deploy this project using \"tm deploy -f %s --wait\" command\n", path)
	return nil
}
Generate accept Project object and creates tm-deployable project structure
with all required manifests, functions, etc
package generate
import (
	"fmt"
	"strings"
	"github.com/triggermesh/tm/pkg/client"
	"github.com/triggermesh/tm/pkg/file"
	"gopkg.in/yaml.v2"
)
type Project struct {
	Name      string
	Namespace string
	Runtime   string
}