// GetTemplate returns template with given name
502245
func (p *Plugin) GetTemplate(name string) (*process.Template, error) {
	if p.tReader == nil {
		return nil, errors.Errorf("cannot read process template %s: reader is nil (no path was defined)", name)
	}
	templates, err := p.tReader.GetAllTemplates()
	if err != nil {
		return nil, err
	}
	for _, tmp := range templates {
		if tmp.Name == name {
			return tmp, nil
		}
	}
	return nil, nil
}
851419
func (a *Client) GetTemplatesLibrary(params *GetTemplatesLibraryParams, authInfo runtime.ClientAuthInfoWriter) (*GetTemplatesLibraryOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetTemplatesLibraryParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "GetTemplatesLibrary",
		Method:             "GET",
		PathPattern:        "/templates/library",
		ProducesMediaTypes: []string{"application/json", "application/x-gzip"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetTemplatesLibraryReader{formats: a.formats},
		AuthInfo:           authInfo,
	})
	if err != nil {
		return nil, err
	}
	return result.(*GetTemplatesLibraryOK), nil
}
870670
func getPipelineTemplateAction(client *gocd.Client, c *cli.Context) (r interface{}, resp *gocd.APIResponse, err error) {
	var name string
	if name = c.String("template-name"); name == "" {
		return nil, nil, NewFlagError("template-name")
	}

	pt, resp, err := client.PipelineTemplates.Get(context.Background(), name)
	if resp.HTTP.StatusCode != 404 {
		pt.RemoveLinks()
	}
	return pt, resp, err
}
1140150
func ProcessTemplate(t T, templateContent string, value interface{}) string {
	tmp, err := template.New("temporary").Parse(templateContent)
	if err != nil {
		logfatal(t, sfatalf("failed to parse:%v", err))
		return ""
	}
	var buf bytes.Buffer
	err = tmp.Execute(&buf, value)
	if err != nil {
		logfatal(t, sfatalf("failed to execute template:%v", err))
		return ""
	}
	return buf.String()
}
813646
func (s *TemplatesService) GetTemplate(accountID string, templateIdentifier string) (*templateResponse, error) {
	path := versioned(templatePath(accountID, templateIdentifier))
	templateResponse := &templateResponse{}

	resp, err := s.client.get(path, templateResponse)
	if err != nil {
		return nil, err
	}

	templateResponse.HttpResponse = resp
	return templateResponse, nil
}
904353
func (client *Client) DeleteTemplate(ctx context.Context, templateID string) error {
	return client.request(ctx, "DELETE", "templates/"+templateID, nil, nil)
}
1336180
func GenerateTemplate(filename, templateSource string, args map[string]interface{}) (err error) {
	tmpl := template.Must(template.New("").Parse(templateSource))

	var b bytes.Buffer
	if err = tmpl.Execute(&b, args); err != nil {
		return NewBuildIfError(err, "ExecuteTemplate: Execute failed")
	}
	sourceCode := b.String()
	filePath := filepath.Dir(filename)
	if !DirExists(filePath) {
		err = os.MkdirAll(filePath, 0777)
		if err != nil && !os.IsExist(err) {
			return NewBuildIfError(err, "Failed to make directory", "dir", filePath)
		}
	}

	// Create the file
	file, err := os.Create(filename)
	if err != nil {
		Logger.Fatal("Failed to create file", "error", err)
		return
	}
	defer func() {
		_ = file.Close()
	}()

	if _, err = file.WriteString(sourceCode); err != nil {
		Logger.Fatal("Failed to write to file: ", "error", err)
	}

	return
}
663375
func NewTemplate(context *context.Context) *Template {
	tpl := new(Template)
	tpl.Context = context
	return tpl
}
81071
func (c *brokerTemplateInstances) Get(name string, options v1.GetOptions) (result *template.BrokerTemplateInstance, err error) {
	result = &template.BrokerTemplateInstance{}
	err = c.client.Get().
		Resource("brokertemplateinstances").
		Name(name).
		VersionedParams(&options, scheme.ParameterCodec).
		Do().
		Into(result)
	return
}
1037852
func GetTemplateMetaObject(obj runtime.Object) (metav1.Object, bool) {
	switch r := obj.(type) {

	case *kapi.PodTemplate:
		return &r.Template.ObjectMeta, true
	case *corev1.PodTemplate:
		return &r.Template.ObjectMeta, true

	case *kapi.ReplicationController:
		if r.Spec.Template != nil {
			return &r.Spec.Template.ObjectMeta, true
		}
	case *corev1.ReplicationController:
		if r.Spec.Template != nil {
			return &r.Spec.Template.ObjectMeta, true
		}

	case *apps.DaemonSet:
		return &r.Spec.Template.ObjectMeta, true
	case *extensionsv1beta1.DaemonSet:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1.DaemonSet:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1beta2.DaemonSet:
		return &r.Spec.Template.ObjectMeta, true

	case *apps.Deployment:
		return &r.Spec.Template.ObjectMeta, true
	case *extensionsv1beta1.Deployment:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1.Deployment:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1beta1.Deployment:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1beta2.Deployment:
		return &r.Spec.Template.ObjectMeta, true

	case *apps.ReplicaSet:
		return &r.Spec.Template.ObjectMeta, true
	case *extensionsv1beta1.ReplicaSet:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1.ReplicaSet:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1beta2.ReplicaSet:
		return &r.Spec.Template.ObjectMeta, true

	case *batch.Job:
		return &r.Spec.Template.ObjectMeta, true
	case *batchv1.Job:
		return &r.Spec.Template.ObjectMeta, true

	case *batch.CronJob:
		return &r.Spec.JobTemplate.Spec.Template.ObjectMeta, true
	case *batchv2alpha1.CronJob:
		return &r.Spec.JobTemplate.Spec.Template.ObjectMeta, true
	case *batchv1beta1.CronJob:
		return &r.Spec.JobTemplate.Spec.Template.ObjectMeta, true

	case *batch.JobTemplate:
		return &r.Template.Spec.Template.ObjectMeta, true
	case *batchv2alpha1.JobTemplate:
		return &r.Template.Spec.Template.ObjectMeta, true
	case *batchv1beta1.JobTemplate:
		return &r.Template.Spec.Template.ObjectMeta, true

	case *apps.StatefulSet:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1.StatefulSet:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1beta1.StatefulSet:
		return &r.Spec.Template.ObjectMeta, true
	case *kappsv1beta2.StatefulSet:
		return &r.Spec.Template.ObjectMeta, true

	case *securityapi.PodSecurityPolicySubjectReview:
		return &r.Spec.Template.ObjectMeta, true
	case *securityv1.PodSecurityPolicySubjectReview:
		return &r.Spec.Template.ObjectMeta, true

	case *securityapi.PodSecurityPolicySelfSubjectReview:
		return &r.Spec.Template.ObjectMeta, true
	case *securityv1.PodSecurityPolicySelfSubjectReview:
		return &r.Spec.Template.ObjectMeta, true

	case *securityapi.PodSecurityPolicyReview:
		return &r.Spec.Template.ObjectMeta, true
	case *securityv1.PodSecurityPolicyReview:
		return &r.Spec.Template.ObjectMeta, true

	case *appsapi.DeploymentConfig:
		if r.Spec.Template != nil {
			return &r.Spec.Template.ObjectMeta, true
		}
	case *appsv1.DeploymentConfig:
		if r.Spec.Template != nil {
			return &r.Spec.Template.ObjectMeta, true
		}
	}
	return nil, false
}
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()
}
720752
func getTemplateBundle(templatePath string) *templates.Bundle {
	return &templates.Bundle{
		Loader:          templates.FileSystemLoader(templatePath),
		DebugMode:       info.IsDevAppServer,
		DefaultTemplate: "base",
		DefaultArgs: func(c context.Context, e *templates.Extra) (templates.Args, error) {
			loginURL, err := auth.LoginURL(c, e.Request.URL.RequestURI())
			if err != nil {
				return nil, err
			}
			logoutURL, err := auth.LogoutURL(c, e.Request.URL.RequestURI())
			if err != nil {
				return nil, err
			}

			project := e.Params.ByName("project")
			group := e.Params.ByName("group")

			return templates.Args{
				"AppVersion":  strings.Split(info.VersionID(c), ".")[0],
				"IsAnonymous": auth.CurrentIdentity(c) == identity.AnonymousIdentity,
				"User":        auth.CurrentUser(c),
				"LoginURL":    loginURL,
				"LogoutURL":   logoutURL,
				"CurrentTime": clock.Now(c),
				"Analytics":   analytics.Snippet(c),
				"RequestID":   info.RequestID(c),
				"Request":     e.Request,
				"Navi":        ProjectLinks(c, project, group),
				"ProjectID":   project,
			}, nil
		},
		FuncMap: funcMap,
	}
}
984825
func (s *TemplatesService) GetTemplateRecord(accountID string, templateIdentifier string, templateRecordID int64) (*templateRecordResponse, error) {
	path := versioned(templateRecordPath(accountID, templateIdentifier, templateRecordID))
	templateRecordResponse := &templateRecordResponse{}

	resp, err := s.client.get(path, templateRecordResponse)
	if err != nil {
		return nil, err
	}

	templateRecordResponse.HttpResponse = resp
	return templateRecordResponse, nil
}
1356418
func (t *Repository) Get(name string) (*template.Template, error) {
	templ, found := t.templates[name]

	if !found {
		return templ, fmt.Errorf("Template doesn't exist %s", name)
	}

	return t.addDependencies(templ)
}
127500
func (s OSS) GetURLTemplate(option *media_library.Option) (path string) {
	if path = option.Get("URL"); path == "" {
		path = "/{{class}}/{{primary_key}}/{{column}}/{{filename_with_hash}}"
	}

	path = "//" + getEndpoint(option) + path

	return
}
93526
func (s *TemplateService) CopyTemplate(p *CopyTemplateParams) (*CopyTemplateResponse, error) {
	resp, err := s.cs.newRequest("copyTemplate", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r CopyTemplateResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
1110056
func (s *Store) GetTemplate(context.Context, string) ([]byte, error) {
	return nil, fmt.Errorf("not supported")
}