-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide a new install command to generate a helm chart
this PR refactors the openshift-template generation logic from `install render` and introduces a helm chart generator on top of that. helm is the preferred way of deploying services for ARO HCP related services. https://issues.redhat.com/browse/ARO-11084 Signed-off-by: Gerd Oberlechner <goberlec@redhat.com>
- Loading branch information
Showing
7 changed files
with
242 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package install | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func ExecuteTestHelmCommand(args []string) ([]byte, error) { | ||
// append helm to args | ||
args = append([]string{"helm"}, args...) | ||
cmd := NewCommand() | ||
cmd.SetArgs(args) | ||
b := bytes.NewBufferString("") | ||
cmd.SetOut(b) | ||
err := cmd.Execute() | ||
if err != nil { | ||
return []byte{}, err | ||
} | ||
return io.ReadAll(b) | ||
} | ||
|
||
func TestHelmCommand(t *testing.T) { | ||
// create a folder to hold test data and delete it afterwards | ||
tmpDir, err := os.MkdirTemp("", "test") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(tmpDir) | ||
|
||
_, err = ExecuteTestHelmCommand([]string{"--output-dir", tmpDir}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// check if the output directory exists | ||
if _, err := os.Stat(tmpDir); os.IsNotExist(err) { | ||
t.Fatalf("Output directory %s does not exist", tmpDir) | ||
} | ||
|
||
// check if the crds directory exists ... | ||
for _, dir := range []string{"crds", "templates"} { | ||
dirPath := tmpDir + "/" + dir | ||
if _, err := os.Stat(dirPath); os.IsNotExist(err) { | ||
t.Fatalf("%s directory %s does not exist", dir, dirPath) | ||
} | ||
files, err := os.ReadDir(dirPath) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if len(files) == 0 { | ||
t.Fatalf("%s directory is empty", dirPath) | ||
} | ||
} | ||
|
||
// check if the Chart.yaml file exists | ||
chartPath := tmpDir + "/Chart.yaml" | ||
if _, err := os.Stat(chartPath); os.IsNotExist(err) { | ||
t.Fatalf("Chart.yaml file %s does not exist", chartPath) | ||
} | ||
|
||
// check if the values.yaml file exists | ||
valuesPath := tmpDir + "/values.yaml" | ||
if _, err := os.Stat(valuesPath); os.IsNotExist(err) { | ||
t.Fatalf("values.yaml file %s does not exist", valuesPath) | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.