-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding charts release package with direct execution to charts-build-s…
…cripts binary
1 parent
c440437
commit 2ef133d
Showing
1 changed file
with
61 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package charts | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
|
||
ecmConfig "github.com/rancher/ecm-distro-tools/cmd/release/config" | ||
) | ||
|
||
// ListLifecycleStatus prints the lifecycle status of the charts | ||
func ListLifecycleStatus(ctx context.Context, c *ecmConfig.ChartsRelease, branch, chart string) error { | ||
|
||
var branchArg, chartArg string = "", "" | ||
|
||
branchArg = "--branch-version=" + branch | ||
if chart != "" { | ||
chartArg = "--chart=" + chart | ||
} | ||
|
||
err := executeChartsBuildScripts(c.Workspace, "lifecycle-status", branchArg, chartArg) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("generated log files for inspection at: \n%s\n", c.Workspace+"/logs/") | ||
return nil | ||
} | ||
|
||
func executeChartsBuildScripts(chartsRepoPath string, args ...string) error { | ||
// save current working dir | ||
ecmWorkDir, err := os.Getwd() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// change working dir to the charts repo | ||
err = os.Chdir(chartsRepoPath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
bin := strings.Join([]string{chartsRepoPath, "bin", "charts-build-scripts"}, string(os.PathSeparator)) | ||
|
||
cmd := exec.Command(bin, args...) | ||
output, err := cmd.CombinedOutput() | ||
if err != nil { | ||
return fmt.Errorf("failed to execute charts-build-scripts: %w, output: %s", err, output) | ||
} | ||
fmt.Printf("charts-build-scripts output: %s\n", output) | ||
|
||
// Change back working dir for the caller | ||
err = os.Chdir(ecmWorkDir) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |