X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=mecm%2Fmepm%2Fapplcm%2Fk8shelm%2Fpkg%2Fplugin%2Fhelmclient.go;h=2ec232853d83f83e7854c4d8ac85dc48756930e2;hb=246be669d7a8109bfc7ce3d7101268a248854be4;hp=eae3c039db0cab015bbc0163913d0e072894f03e;hpb=e363ff9fc0e8d060a3da53e44a95f1dbf0d84d3f;p=ealt-edge.git diff --git a/mecm/mepm/applcm/k8shelm/pkg/plugin/helmclient.go b/mecm/mepm/applcm/k8shelm/pkg/plugin/helmclient.go index eae3c03..2ec2328 100644 --- a/mecm/mepm/applcm/k8shelm/pkg/plugin/helmclient.go +++ b/mecm/mepm/applcm/k8shelm/pkg/plugin/helmclient.go @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package plugin import ( @@ -25,13 +26,14 @@ import ( "os" ) -// 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") ) + // Helm client type HelmClient struct { hostIP string @@ -53,7 +55,7 @@ func NewHelmClient(hostIP string, logger *logrus.Logger) (*HelmClient, error) { // Install a given helm chart func (hc *HelmClient) installChart(helmPkg bytes.Buffer) (string, error) { - hc.logger.Info("Inside helm client") + hc.logger.Debug("Inside helm client") // Create temporary file to hold helm chart file, err := os.Create(chartPath + "temp.tar.gz") @@ -84,11 +86,11 @@ func (hc *HelmClient) installChart(helmPkg bytes.Buffer) (string, error) { actionConfig := new(action.Configuration) if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace, os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) { - fmt.Sprintf(format, v) + fmt.Sprintf(format, v) }); err != nil { hc.logger.Errorf("Unable to initialize action config Err: %s", err) return "", err - } + } // Prepare chart install action and install chart installer := action.NewInstall(actionConfig) @@ -99,7 +101,7 @@ func (hc *HelmClient) installChart(helmPkg bytes.Buffer) (string, error) { hc.logger.Errorf("Unable to install chart with release name: %s. Err: %s", relName, err) return "", err } - hc.logger.Info("Successfully create chart with release name: %s", relName) + hc.logger.Infof("Successfully create chart with release name: %s", relName) return rel.Name, err } @@ -109,11 +111,11 @@ func (hc *HelmClient) uninstallChart(relName string) (error) { actionConfig := new(action.Configuration) if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace, os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) { - fmt.Sprintf(format, v) + fmt.Sprintf(format, v) }); err != nil { hc.logger.Errorf("Unable to initialize action config Err: %s", err) return err - } + } ui := action.NewUninstall(actionConfig) res, err := ui.Run(relName); @@ -121,7 +123,7 @@ func (hc *HelmClient) uninstallChart(relName string) (error) { hc.logger.Errorf("Unable to uninstall chart with release name: %s. Err: %s", relName, err) return err } - 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) return nil } @@ -130,8 +132,8 @@ func (hc *HelmClient) queryChart(relName string) (string, error) { actionConfig := new(action.Configuration) if err := actionConfig.Init(kube.GetConfig(hc.kubeconfig, "", releaseNamespace), releaseNamespace, os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) { - fmt.Sprintf(format, v) - }); err != nil { + fmt.Sprintf(format, v) + }); err != nil { hc.logger.Errorf("Unable to initialize action config Err: %s", err) return "", err } @@ -152,5 +154,4 @@ func fileExists(filename string) (bool, error) { return false, err } return !info.IsDir(), nil -} - +} \ No newline at end of file