* See the License for the specific language governing permissions and
* limitations under the License.
*/
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"github.com/sirupsen/logrus"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/kube"
"github.com/sirupsen/logrus"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/kube"
-// Constants to be taken from deployment file
-const (
- releaseNamespace = "default"
- chartPath = "/go/release/charts/"
- kubeconfigPath = "/go/release/kubeconfig/"
+// Variables to be defined in deployment file
+var (
+ chartPath = os.Getenv("CHART_PATH")
+ kubeconfigPath = os.Getenv("KUBECONFIG_DIR_PATH")
+ releaseNamespace = os.Getenv("RELEASE_NAMESPACE")
if exists {
return &HelmClient{hostIP: hostIP, kubeconfig: kubeconfigPath + hostIP, logger: logger}, nil
} else {
if exists {
return &HelmClient{hostIP: hostIP, kubeconfig: kubeconfigPath + hostIP, logger: logger}, nil
} else {
return nil, err
}
}
// Install a given helm chart
func (hc *HelmClient) installChart(helmPkg bytes.Buffer) (string, error) {
return nil, err
}
}
// Install a given helm chart
func (hc *HelmClient) installChart(helmPkg bytes.Buffer) (string, error) {
// Create temporary file to hold helm chart
file, err := os.Create(chartPath + "temp.tar.gz")
if err != nil {
// Create temporary file to hold helm chart
file, err := os.Create(chartPath + "temp.tar.gz")
if err != nil {
// Write input bytes to temp file
_, err = helmPkg.WriteTo(file)
if err != nil {
// Write input bytes to temp file
_, err = helmPkg.WriteTo(file)
if err != nil {
return "", err
}
// Load the file to chart
chart, err := loader.Load(chartPath + "temp.tar.gz")
if err != nil {
return "", err
}
// Load the file to chart
chart, err := loader.Load(chartPath + "temp.tar.gz")
if err != nil {
actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace,
os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace,
os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
// Prepare action config and uninstall chart
actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace,
os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
// Prepare action config and uninstall chart
actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace,
os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
- hc.logger.Info("Successfully uninstalled chart with release name: %s. Response Info: %s", res.Release.Name, res.Info)
+ hc.logger.Infof("Successfully uninstalled chart with release name: %s. Response Info: %s", res.Release.Name, res.Info)
actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace,
os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
actionConfig := new(action.Configuration)
if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace,
os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {