Skip to content

Commit

Permalink
Merge pull request #9 from zostay/custom-files-location
Browse files Browse the repository at this point in the history
Add files_dir configuration
  • Loading branch information
zostay authored Aug 9, 2024
2 parents e55a8c4 + a99b605 commit 13ecca2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type Cluster struct {
// which are applied to the cluster.
KubeDir string `mapstructure:"kube_dir"`

// FilesDir tells genifiest where to locate files that are loaded when
// templating using the files template function.
FilesDir string `mapstructure:"files_dir"`

// SourceDir tells genifest where to find the source files to use for
// generating the deployment resources.
SourceDir string `mapstructure:"source_dir"`
Expand Down
13 changes: 12 additions & 1 deletion pkg/config/lazyTools.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package config
import (
"context"
"fmt"
"path/filepath"
"strings"
"text/template"

"github.com/zostay/genifest/pkg/client/aws/iam"
Expand Down Expand Up @@ -77,8 +79,17 @@ func (t *LazyTools) makeFuncMap(
KeeperName: t.c.Ghost.Keeper,
}

filesRoot := t.cf.CloudHome
if filesDir := t.c.FilesDir; filesDir != "" {
if strings.HasPrefix(filesDir, "/") {
filesRoot = filesDir
} else {
filesRoot = filepath.Join(filesRoot, filesDir)
}
}

file := func(app, path string) (string, error) {
return tmpltools.File(t.cf.CloudHome, app, path)
return tmpltools.File(filesRoot, app, path)
}

applyTemplate := func(name, data string) (string, error) {
Expand Down

0 comments on commit 13ecca2

Please sign in to comment.