package customtemplates
import (
"errors"
"regexp"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/dataservices"
)
func populateGitConfig(tx dataservices.DataStoreTx, template *portainer.CustomTemplate) {
if template.Artifact == nil || len(template.Artifact.Files) == 0 {
return
}
file := template.Artifact.Files[0]
src, err := tx.Source().Read(file.SourceID)
if err != nil || src.Git == nil {
return
}
cfg := *src.Git
cfg.ReferenceName = file.Ref
cfg.ConfigFilePath = file.Path
cfg.ConfigHash = file.Hash
if cfg.Authentication != nil {
sanitized := *cfg.Authentication
sanitized.Password = ""
cfg.Authentication = &sanitized
}
template.GitConfig = &cfg
}
// IsValidNote reports whether note is safe to display. Notes containing
tags are rejected.
func IsValidNote(note string) bool {
if len(note) == 0 {
return true
}
match, _ := regexp.MatchString("![]()