// UsageTemplate returns usage template for the command.
976415
func (c *Command) UsageTemplate() string {
	if c.usageTemplate != "" {
		return c.usageTemplate
	}

	if c.HasParent() {
		return c.parent.UsageTemplate()
	}
	return `Usage:{{if .Runnable}}
  {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
  {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}

Aliases:
  {{.NameAndAliases}}{{end}}{{if .HasExample}}

Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}

Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
  {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}

Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}

Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}

Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
  {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}

Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`
}
777005
func (f *Facade) DeployTemplate(ctx datastore.Context, poolID string, templateID string, deploymentID string) ([]string, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.DeployTemplate"))
	alog := f.auditLogger.Message(ctx, "Deploying Service Template").
		Action(audit.Deploy).ID(templateID).Type(servicetemplate.GetType()).
		WithFields(logrus.Fields{"poolid": poolID, "deploymentid": deploymentID})
	logger := plog.WithFields(logrus.Fields{
		"poolid":       poolID,
		"templateid":   templateID,
		"deploymentid": deploymentID,
	})
	// add an entry for reporting status
	deployment, err := f.deployments.NewPendingDeployment(deploymentID, templateID, poolID)
	if err != nil {
		return nil, alog.Error(err)
	}
	defer f.deployments.DeletePendingDeployment(deploymentID)

	deployment.UpdateStatus("deploy_loading_template|" + templateID)
	template, err := f.templateStore.Get(ctx, templateID)
	if err != nil {
		logger.WithError(err).Error("Unable to load template")
		return nil, alog.Error(err)
	}

	//check that deployment id does not already exist
	logger = logger.WithField("template", template.Name)
	if svcs, err := f.serviceStore.GetServicesByDeployment(ctx, deploymentID); err != nil {
		logger.WithError(err).Error("Unable to validate deploymentID while deploying")
		return nil, alog.Error(err)
	} else if len(svcs) > 0 {
		return nil, alog.Error(fmt.Errorf("deployment ID %s is already in use", deploymentID))
	}

	//now that we know the template name, set it in the status
	deployment.SetTemplateName(template.Name)

	deployment.UpdateStatus("deploy_loading_resource_pool|" + poolID)
	pool, err := f.GetResourcePool(ctx, poolID)
	if err != nil {
		logger.WithError(err).Error("Unable to load resource pool")
		return nil, alog.Error(err)
	}
	if pool == nil {
		return nil, alog.Error(fmt.Errorf("poolid %s not found", poolID))
	}

	var statusUpdater = func(status string) {
		deployment.UpdateStatus(status)
	}

	tenantIDs := make([]string, len(template.Services))
	for i, sd := range template.Services {
		logger.WithField("servicename", sd.Name).Info("Deploying service")
		tenantID, err := f.deployService(ctx, "", "", deploymentID, poolID, false, sd, statusUpdater)
		if err != nil {
			logger.WithError(err).Error("Could not deploy application")
			return nil, alog.Error(err)
		}
		if err := f.dfs.Create(tenantID); err != nil {
			logger.WithError(err).WithField("tenantid", tenantID).Error("Could not initialize volume for tenant")
			return nil, alog.Error(err)
		}
		tenantIDs[i] = tenantID
	}

	// Update the logstash filters for the deployed services
	if err := f.ReloadLogstashConfig(ctx); err != nil {
		logger.WithError(err).Error("Could not reload logstash configs after deploying")
	}

	alog.Succeeded()
	return tenantIDs, nil
}
35519
func (_m *ClientInterface) DeployTemplate(request servicetemplate.ServiceTemplateDeploymentRequest) ([]string, error) {
	ret := _m.Called(request)

	var r0 []string
	if rf, ok := ret.Get(0).(func(servicetemplate.ServiceTemplateDeploymentRequest) []string); ok {
		r0 = rf(request)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]string)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(servicetemplate.ServiceTemplateDeploymentRequest) error); ok {
		r1 = rf(request)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
304447
func (g *gomplate) runTemplate(t *tplate) error {
	tmpl, err := t.toGoTemplate(g)
	if err != nil {
		return err
	}

	switch t.target.(type) {
	case io.Closer:
		if t.target != os.Stdout {
			// nolint: errcheck
			defer t.target.(io.Closer).Close()
		}
	}
	err = tmpl.Execute(t.target, g.context)
	return err
}
248732
func (s *SendTemplatedEmailInput) SetTemplate(v string) *SendTemplatedEmailInput {
	s.Template = &v
	return s
}
1229006
func NewTemplate(separator string, pattern string, defaultTags map[string]string) (*Template, error) {
	parts := strings.Split(pattern, separator)
	hasMeasurement := false
	template := &Template{
		separator:   separator,
		parts:       parts,
		defaultTags: defaultTags,
	}

	for _, part := range parts {
		if strings.HasPrefix(part, "measurement") {
			hasMeasurement = true
		}
		if part == "measurement*" {
			template.greedyMeasurement = true
		} else if part == "field*" {
			template.greedyField = true
		}
	}

	if !hasMeasurement {
		return nil, fmt.Errorf("no measurement specified for template. %q", pattern)
	}

	return template, nil
}
131249
func (r *Registry) Template(name string) (Template, bool) {
	for _, t := range r.Templates {
		if t.Node.Name == name {
			return t, true
		}
	}
	return Template{}, false
}
602242
func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
	return t.tmpl.ExecuteTemplate(wr, name, data)
}
898277
func NewTemplate() *Template {
	return &Template{
		AWSTemplateFormatVersion: "2010-09-09",
		Description:              "",
		Metadata:                 map[string]interface{}{},
		Parameters:               map[string]interface{}{},
		Mappings:                 map[string]interface{}{},
		Conditions:               map[string]interface{}{},
		Resources:                Resources{},
		Outputs:                  map[string]interface{}{},
	}
}
791164
func (s *Server) DeployTemplate(request servicetemplate.ServiceTemplateDeploymentRequest, response *[]string) error  {
	tenantIDs, err := s.f.DeployTemplate(s.context(), request.PoolID, request.TemplateID, request.DeploymentID)
	if err != nil {
		return err
	}
	*response = tenantIDs
	return nil
}
1110056
func (s *Store) GetTemplate(context.Context, string) ([]byte, error) {
	return nil, fmt.Errorf("not supported")
}
537026
func ExecuteTemplate(tmpl ExecutableTemplate, data interface{}) string {
	var b bytes.Buffer
	if err := tmpl.Execute(&b, data); err != nil {
		utilLog.Error("ExecuteTemplate: Execute failed", "error", err)
	}
	return b.String()
}
463201
func MainUsageTemplate() string {
	sections := []string{
		"\n\n",
		SectionVars,
		SectionAliases,
		SectionExamples,
		SectionSubcommands,
		SectionFlags,
		SectionUsage,
		SectionTipsHelp,
		SectionTipsGlobalOptions,
	}
	return strings.TrimRightFunc(strings.Join(sections, ""), unicode.IsSpace)
}
1317423
func (q TemplateQuery) Template(name string) TemplateQuery {
	q.template = name
	return q
}
1085192
func Template(runOnStartup bool) POption {
	return func(p *POptions) {
		p.template = true
		p.runOnStartup = runOnStartup
	}
}
527012
func (s *CreateTemplateInput) SetTemplate(v *Template) *CreateTemplateInput {
	s.Template = v
	return s
}
847795
func (g *generator) TextTemplate(s string, data interface{}, opts ...TemplateOption) (string, error) {
	templateFuncs := template.FuncMap{
		"formatDoc":        formatDoc,
		"goCase":           goCase,
		"goName":           goName,
		"import":           g.Import,
		"isHashable":       isHashable,
		"setUsesMap":       setUsesMap,
		"isPrimitiveType":  isPrimitiveType,
		"isStructType":     isStructType,
		"newNamespace":     g.Namespace.Child,
		"newVar":           g.Namespace.Child().NewName,
		"typeName":         curryGenerator(typeName, g),
		"typeReference":    curryGenerator(typeReference, g),
		"typeReferencePtr": curryGenerator(typeReferencePtr, g),
		"fromWire":         curryGenerator(g.w.FromWire, g),
		"fromWirePtr":      curryGenerator(g.w.FromWirePtr, g),
		"toWire":           curryGenerator(g.w.ToWire, g),
		"toWirePtr":        curryGenerator(g.w.ToWirePtr, g),
		"typeCode":         curryGenerator(TypeCode, g),
		"equals":           curryGenerator(g.e.Equals, g),
		"equalsPtr":        curryGenerator(g.e.EqualsPtr, g),
		"zapEncodeBegin":   curryGenerator(g.z.zapEncodeBegin, g),
		"zapEncodeEnd":     g.z.zapEncodeEnd,
		"zapEncoder":       curryGenerator(g.z.zapEncoder, g),
		"zapMarshaler":     curryGenerator(g.z.zapMarshaler, g),
		"zapMarshalerPtr":  curryGenerator(g.z.zapMarshalerPtr, g),
	}

	tmpl := template.New("thriftrw").Delims("<", ">").Funcs(templateFuncs)
	for _, opt := range opts {
		tmpl = opt(g, tmpl)
	}

	tmpl, err := tmpl.Parse(s)
	if err != nil {
		return "", err
	}

	buff := bytes.Buffer{}
	if err := tmpl.Execute(&buff, data); err != nil {
		return "", err
	}

	return buff.String(), nil

}