|
|
@@ -12,6 +12,7 @@ import (
|
|
|
"github.com/porter-dev/porter/api/types"
|
|
|
"github.com/porter-dev/porter/internal/helm"
|
|
|
"github.com/porter-dev/porter/internal/models"
|
|
|
+ "github.com/stefanmcshane/helm/pkg/chart"
|
|
|
)
|
|
|
|
|
|
type CreateStackHandler struct {
|
|
|
@@ -94,3 +95,41 @@ func (c *CreateStackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
w.WriteHeader(http.StatusCreated)
|
|
|
}
|
|
|
+
|
|
|
+func createChartFromDependencies(deps []types.Dependency) (*chart.Chart, error) {
|
|
|
+ metadata := &chart.Metadata{
|
|
|
+ Name: "umbrella",
|
|
|
+ Description: "Web application that is exposed to external traffic.",
|
|
|
+ Version: "0.96.0",
|
|
|
+ APIVersion: "v2",
|
|
|
+ Home: "https://getporter.dev/",
|
|
|
+ Icon: "https://user-images.githubusercontent.com/65516095/111255214-07d3da80-85ed-11eb-99e2-fddcbdb99bdb.png",
|
|
|
+ Keywords: []string{
|
|
|
+ "porter",
|
|
|
+ "application",
|
|
|
+ "service",
|
|
|
+ "umbrella",
|
|
|
+ },
|
|
|
+ Type: "application",
|
|
|
+ Dependencies: createChartDependencies(deps),
|
|
|
+ }
|
|
|
+
|
|
|
+ // create a new chart object with the metadata
|
|
|
+ c := &chart.Chart{
|
|
|
+ Metadata: metadata,
|
|
|
+ }
|
|
|
+ return c, nil
|
|
|
+}
|
|
|
+
|
|
|
+func createChartDependencies(deps []types.Dependency) []*chart.Dependency {
|
|
|
+ var chartDependencies []*chart.Dependency
|
|
|
+ for _, d := range deps {
|
|
|
+ chartDependencies = append(chartDependencies, &chart.Dependency{
|
|
|
+ Name: d.Name,
|
|
|
+ Alias: d.Alias,
|
|
|
+ Version: d.Version,
|
|
|
+ Repository: d.Repository,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return chartDependencies
|
|
|
+}
|