-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1d5110
commit 21325c1
Showing
8 changed files
with
86 additions
and
98 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,13 @@ | ||
package install | ||
|
||
type InstallRequest struct { | ||
RequestID string | ||
ReleaseName string | ||
ReleaseNamespace string | ||
ChartPath string | ||
} | ||
|
||
type InstallReponse struct { | ||
Status bool | ||
ReleaseStatus string | ||
} |
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,67 @@ | ||
package install | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
"helm.sh/helm/v3/cmd/servercontext" | ||
"helm.sh/helm/v3/pkg/action" | ||
"helm.sh/helm/v3/pkg/chart" | ||
"helm.sh/helm/v3/pkg/chart/loader" | ||
) | ||
|
||
func Handler() http.Handler { | ||
return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { | ||
|
||
res.Header().Set("Content-Type", "application/json") | ||
defer req.Body.Close() | ||
|
||
var request InstallRequest | ||
decoder := json.NewDecoder(req.Body) | ||
decoder.UseNumber() | ||
|
||
if err := decoder.Decode(&request); err != nil { | ||
fmt.Printf("error in request: %v", err) | ||
return | ||
} | ||
|
||
request.RequestID = req.Header.Get("Request-Id") | ||
request.ReleaseName = req.Header.Get("Release-Name") | ||
request.ReleaseNamespace = req.Header.Get("Release-Namespace") | ||
request.ChartPath = req.Header.Get("Chart-Path") | ||
|
||
install := action.NewInstall(servercontext.App().ActionConfig) | ||
install.ReleaseName = request.ReleaseName | ||
install.Namespace = request.ReleaseNamespace | ||
|
||
cp, err := install.ChartPathOptions.LocateChart(request.ChartPath, servercontext.App().Config) | ||
if err != nil { | ||
fmt.Printf("error in locating chart: %v", err) | ||
return | ||
} | ||
|
||
var requestedChart *chart.Chart | ||
if requestedChart, err = loader.Load(cp); err != nil { | ||
fmt.Printf("error in loading chart: %v", err) | ||
return | ||
} | ||
|
||
var vals map[string]interface{} | ||
release, err := install.Run(requestedChart, vals) | ||
if err != nil { | ||
fmt.Printf("error in installing chart: %v", err) | ||
return | ||
} | ||
|
||
response := InstallReponse{Status: true, ReleaseStatus: string(release.Info.Status)} | ||
|
||
payload, err := json.Marshal(response) | ||
if err != nil { | ||
fmt.Printf("error parsing response %v", err) | ||
return | ||
} | ||
|
||
res.Write(payload) | ||
}) | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.