Skip to content

Commit

Permalink
fix generator error, test generator
Browse files Browse the repository at this point in the history
  • Loading branch information
arti-shalb committed Jun 20, 2024
1 parent 913b9e9 commit 2b2e9a1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,10 @@ jobs:
run: |
export KUBE_CONTEXT=$(kubectl config current-context)
cd tests/k8s/ && cdev apply --force -l debug && cdev destroy --force -l debug
- name: Run project generator tests
run: |
mkdir tmp
cd tmp
cdev project create https://github.com/shalb/cdev-do-k8
ls
4 changes: 0 additions & 4 deletions internal/project/ui/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,6 @@ func ClearScreen() {
func GetTemplateGenerators(tmplSrc string) (tmplDir string, err error) {
if !config.Global.UseCache {
utils.RemoveDirContent(config.Global.TemplatesCacheDir)
err = os.Remove(config.Global.TemplatesCacheDir)
if err != nil {
return
}
}
err = os.MkdirAll(config.Global.TemplatesCacheDir, os.ModePerm)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/secrets/aws_secretmanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (s *smDriver) Create(files map[string][]byte) error {
command := fmt.Sprintf("%s %s", editor, filename)
err = runner.RunWithTty(command)
if err != nil {
os.Remove(filename)
os.RemoveAll(filename)
return fmt.Errorf("secrets: create secret: %v", err.Error())
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/secrets/sops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ func (s *sopsDriver) Create(files map[string][]byte) error {
command := fmt.Sprintf("sops -e --encrypted-regex ^encrypted_data$ -i %s", filename)
err = runner.RunWithTty(command)
if err != nil {
os.Remove(filename)
os.RemoveAll(filename)
return fmt.Errorf("create sops secret: %v", err.Error())
}
command = fmt.Sprintf("sops %s", filename)
err = runner.RunWithTty(command)
if err != nil && err.Error() != "exit status 200" {
os.Remove(filename)
os.RemoveAll(filename)
log.Debugf("err %+v", err)
return fmt.Errorf("create sops secret: %v", err.Error())
}
Expand Down
10 changes: 1 addition & 9 deletions internal/units/shell/common/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
"github.com/shalb/cluster.dev/pkg/utils"
)

// CreateCodeDir generate all terraform code for project.
// createCodeDir generate all terraform code for project.
func (u *Unit) createCodeDir() error {

err := os.Mkdir(u.CacheDir, 0755)
if err != nil {
log.Debugf("build unit '%v': mkdir '%v': '%v'", u.Name(), u.CacheDir, err.Error())
Expand All @@ -23,13 +22,6 @@ func (u *Unit) createCodeDir() error {
return fmt.Errorf("read unit '%v': creating cache: '%v'", u.Name(), err.Error())
}
}
// for _, f := range *m.CreateFiles {
// if m.ProjectPtr.CheckContainsMarkers(f.Content) {
// log.Debugf("Unprocessed markers:\n %+v", f.Content)
// return fmt.Errorf("misuse of functions in a template: unit: '%s.%s'", m.StackPtr.Name, m.MyName)
// }
// }

return u.CreateFiles.WriteFiles(u.CacheDir)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/k8s/kube-helm/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ _p: &provider_aws
- aws:
region: {{ .variables.region }}

name: local-template
name: k8s-helm
kind: StackTemplate
cliVersion: "~>0.9.2"
units:
Expand Down

0 comments on commit 2b2e9a1

Please sign in to comment.