-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move all generated resource in one parent folder
- Loading branch information
1 parent
3c9db0f
commit 0f86215
Showing
6 changed files
with
79 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
) | ||
|
||
func Run(dir string, config Generator) error { | ||
return config.Generate(dir) | ||
tempDir, err := ioutil.TempDir("", ".kustomization-generator-") | ||
if err != nil { | ||
return fmt.Errorf("preparing temporary folder failed: %v", err) | ||
} | ||
defer os.RemoveAll(tempDir) | ||
|
||
kustomization, err := config.Generate(tempDir) | ||
if err != nil { | ||
return err | ||
} | ||
for i, res := range kustomization.Resources { | ||
kustomization.Resources[i] = path.Join("generated", res) | ||
} | ||
err = writeYamlFile(path.Join(dir, "kustomization.yaml"), kustomization) | ||
if err != nil { | ||
return fmt.Errorf("writing kustomization failed: %v", err) | ||
} | ||
|
||
os.RemoveAll(path.Join(dir, "generated")) | ||
if err != nil { | ||
return fmt.Errorf("clearing generated files failed: %v", err) | ||
} | ||
err = copyDir(tempDir, path.Join(dir, "generated")) | ||
if err != nil { | ||
return fmt.Errorf("copying generated files failed: %v", err) | ||
} | ||
|
||
return nil | ||
} |