Explorar o código

clean up terminology

Alexander Belanger %!s(int64=5) %!d(string=hai) anos
pai
achega
224e6d678a

+ 49 - 48
docs/API.md

@@ -13,12 +13,12 @@
   - [`POST /api/logout`](#post-apilogout)
   - [`PUT /api/users/{id}`](#put-apiusersid)
   - [`DELETE /api/users/{id}`](#delete-apiusersid)
-- [`/api/charts`](#apicharts)
-  - [`GET /api/charts`](#get-apicharts)
-  - [`GET /api/charts/{name}/history`](#get-apichartsnamehistory)
-  - [`GET /api/charts/{name}/{revision}`](#get-apichartsnamerevision)
-  - [`POST /api/charts/rollback/{name}/{revision}`](#post-apichartsrollbacknamerevision)
-  - [`POST /api/charts/{name}/upgrade`](#post-apichartsnameupgrade)
+- [`/api/releases`](#apireleases)
+  - [`GET /api/releases`](#get-apireleases)
+  - [`GET /api/releases/{name}/history`](#get-apireleasesnamehistory)
+  - [`GET /api/releases/{name}/{revision}`](#get-apireleasesnamerevision)
+  - [`POST /api/releases/{name}/rollback/{revision}`](#post-apireleasesnamerollbackrevision)
+  - [`POST /api/releases/{name}/upgrade`](#post-apireleasesnameupgrade)
 - [`/api/k8s`](#apik8s)
   - [`GET /api/k8s/namespaces`](#get-apik8snamespaces)
 
@@ -419,11 +419,11 @@ User object with only the id field. Other fields are empty - with values in para
     }
     ```
 
-### `/api/charts`
+### `/api/releases`
 
-#### `GET /api/charts`
+#### `GET /api/releases`
 
-**Description:** Gets a list of charts for a current context and a kubeconfig retrieved from the user's ID. 
+**Description:** Gets a list of releases for a current context and a kubeconfig retrieved from the user's ID. 
 
 **URL parameters:** N/A
 
@@ -446,7 +446,7 @@ User object with only the id field. Other fields are empty - with values in para
 **Successful Response Body**: the full body is determined by the [release specification](https://pkg.go.dev/helm.sh/helm/v3@v3.3.4/pkg/release#Release): listed here is a subset of fields deemed to be most relevant. Note that all of the top-level fields are optional.
 
 ```js
-[]Chart{
+[]Release{
   // Name is the name of the release
   "name": String,
   "info": Info{
@@ -459,21 +459,21 @@ User object with only the id field. Other fields are empty - with values in para
     // Status is the current state of the release
     "status": String("unknown"|"deployed"|"uninstalled"|"superseded"|"failed"|"uninstalling"|"pending-install"|"pending-upgrade"|"pending-rollback")
   },
-  "chart": Chart{
+  "release": Release{
     "metadata": Metadata{
-      // The name of the chart
+      // The name of the release
       "name": String,
       // The URL to a relevant project page, git repo, or contact person
       "home": String,
-      // Sources is a list of URLs to the source code of this chart
+      // Sources is a list of URLs to the source code of this release
       "sources": []String,
-      // A SemVer 2 conformant version string of the chart
+      // A SemVer 2 conformant version string of the release
       "version": String,
-      // A one-sentence description of the chart
+      // A one-sentence description of the release
       "description": String,
       // The URL to an icon file.
       "icon": String,
-      // The API Version of this chart.
+      // The API Version of this release.
       "apiVersion": String,
     },
     "templates": []File{
@@ -482,11 +482,11 @@ User object with only the id field. Other fields are empty - with values in para
       // Data is the template as byte data.
       "data": String
     },
-    // Values are default config for this chart.
+    // Values are default config for this release.
     "values": Map[String]{}
   },
-  // The set of extra Values added to the chart, which override the 
-  // default values inside of the chart
+  // The set of extra Values added to the release, which override the 
+  // default values inside of the release
   "config": Map[String]{},
   // Manifest is the string representation of the rendered template
   "manifest": String,
@@ -501,9 +501,9 @@ User object with only the id field. Other fields are empty - with values in para
 
 **Errors:** TBD
 
-#### `GET /api/charts/{name}/history`
+#### `GET /api/releases/{name}/history`
 
-**Description:** Gets a history of revisions for a given deployed chart based on the release `name`.
+**Description:** Gets a history of revisions for a given deployed release based on the release `name`.
 
 **URL parameters:** 
 
@@ -527,7 +527,7 @@ User object with only the id field. Other fields are empty - with values in para
 **Successful Response Body**: the full body is determined by the [release specification](https://pkg.go.dev/helm.sh/helm/v3@v3.3.4/pkg/release#Release): listed here is a subset of fields deemed to be most relevant. Note that all of the top-level fields are optional.
 
 ```js
-[]Chart{
+[]Release{
   // Name is the name of the release
   "name": String,
   "info": Info{
@@ -540,21 +540,21 @@ User object with only the id field. Other fields are empty - with values in para
     // Status is the current state of the release
     "status": String("unknown"|"deployed"|"uninstalled"|"superseded"|"failed"|"uninstalling"|"pending-install"|"pending-upgrade"|"pending-rollback")
   },
-  "chart": Chart{
+  "release": Release{
     "metadata": Metadata{
-      // The name of the chart
+      // The name of the release
       "name": String,
       // The URL to a relevant project page, git repo, or contact person
       "home": String,
-      // Sources is a list of URLs to the source code of this chart
+      // Sources is a list of URLs to the source code of this release
       "sources": []String,
-      // A SemVer 2 conformant version string of the chart
+      // A SemVer 2 conformant version string of the release
       "version": String,
-      // A one-sentence description of the chart
+      // A one-sentence description of the release
       "description": String,
       // The URL to an icon file.
       "icon": String,
-      // The API Version of this chart.
+      // The API Version of this release.
       "apiVersion": String,
     },
     "templates": []File{
@@ -563,11 +563,11 @@ User object with only the id field. Other fields are empty - with values in para
       // Data is the template as byte data.
       "data": String
     },
-    // Values are default config for this chart.
+    // Values are default config for this release.
     "values": Map[String]{}
   },
-  // The set of extra Values added to the chart, which override the 
-  // default values inside of the chart
+  // The set of extra Values added to the release, which override the 
+  // default values inside of the release
   "config": Map[String]{},
   // Manifest is the string representation of the rendered template
   "manifest": String,
@@ -582,9 +582,9 @@ User object with only the id field. Other fields are empty - with values in para
 
 **Errors:** TBD
 
-#### `GET /api/charts/{name}/{revision}`
+#### `GET /api/releases/{name}/{revision}`
 
-**Description:** Gets a single chart for a current context and a kubeconfig retrieved from the user's ID based on a **name** and **revision**. To retrieve the latest deployed chart, set **revision** to 0. 
+**Description:** Gets a single release for a current context and a kubeconfig retrieved from the user's ID based on a **name** and **revision**. To retrieve the latest deployed release, set **revision** to 0. 
 
 **URL parameters:** 
 
@@ -609,7 +609,7 @@ User object with only the id field. Other fields are empty - with values in para
 **Successful Response Body**: the full body is determined by the [release specification](https://pkg.go.dev/helm.sh/helm/v3@v3.3.4/pkg/release#Release): listed here is a subset of fields deemed to be most relevant. Note that all of the top-level fields are optional.
 
 ```js
-Chart{
+Release{
   // Name is the name of the release
   "name": String,
   "info": Info{
@@ -622,21 +622,21 @@ Chart{
     // Status is the current state of the release
     "status": String("unknown"|"deployed"|"uninstalled"|"superseded"|"failed"|"uninstalling"|"pending-install"|"pending-upgrade"|"pending-rollback")
   },
-  "chart": Chart{
+  "release": Release{
     "metadata": Metadata{
-      // The name of the chart
+      // The name of the release
       "name": String,
       // The URL to a relevant project page, git repo, or contact person
       "home": String,
-      // Sources is a list of URLs to the source code of this chart
+      // Sources is a list of URLs to the source code of this release
       "sources": []String,
-      // A SemVer 2 conformant version string of the chart
+      // A SemVer 2 conformant version string of the release
       "version": String,
-      // A one-sentence description of the chart
+      // A one-sentence description of the release
       "description": String,
       // The URL to an icon file.
       "icon": String,
-      // The API Version of this chart.
+      // The API Version of this release.
       "apiVersion": String,
     },
     "templates": []File{
@@ -645,11 +645,11 @@ Chart{
       // Data is the template as byte data.
       "data": String
     },
-    // Values are default config for this chart.
+    // Values are default config for this release.
     "values": Map[String]{}
   },
-  // The set of extra Values added to the chart, which override the 
-  // default values inside of the chart
+  // The set of extra Values added to the release, which override the 
+  // default values inside of the release
   "config": Map[String]{},
   // Manifest is the string representation of the rendered template
   "manifest": String,
@@ -664,14 +664,13 @@ Chart{
 
 **Errors:** TBD
 
-#### `POST /api/charts/rollback/{name}/{revision}`
+#### `POST /api/releases/{name}/rollback`
 
 **Description:** Rolls a release back to a specified revision. 
 
 **URL parameters:** 
 
 - `name` The name of the release.
-- `revision` The number of the release. 
 
 **Query parameters:** N/A
 
@@ -684,7 +683,9 @@ Chart{
   // The name of the context in the kubeconfig being used
   "context": String,
   // The Helm storage option to use
-  "storage": String("secret"|"configmap"|"memory")
+  "storage": String("secret"|"configmap"|"memory"),
+  // The revision number of the desired rollback target
+  "revision": Number
 }
 ```
 
@@ -729,9 +730,9 @@ Chart{
 
 **Errors:** TBD
 
-#### `POST /api/charts/{name}/upgrade`
+#### `POST /api/releases/{name}/upgrade`
 
-**Description:** Upgrades a chart with new `values.yaml`. 
+**Description:** Upgrades a release with new `values.yaml`. 
 
 **URL parameters:** 
 

+ 1 - 0
go.sum

@@ -1279,6 +1279,7 @@ k8s.io/component-base v0.18.8/go.mod h1:00frPRDas29rx58pPCxNkhUfPbwajlyyvu8ruNgS
 k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
 k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
 k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
+k8s.io/helm v1.2.1 h1:Ny4wgW4p7X3tFXR34PziNkUxw2pV0G1DIFmI1QRDdo0=
 k8s.io/helm v2.16.12+incompatible h1:K2zhF8+B85Ya1n7n3eH34xwwp5qNUM42TBFENDZJT7w=
 k8s.io/helm v2.16.12+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
 k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=

+ 0 - 107
internal/forms/chart.go

@@ -1,107 +0,0 @@
-package forms
-
-import (
-	"net/url"
-	"strconv"
-
-	"github.com/porter-dev/porter/internal/helm"
-	"github.com/porter-dev/porter/internal/repository"
-)
-
-// ChartForm is the generic base type for CRUD operations on charts
-type ChartForm struct {
-	*helm.Form
-}
-
-// PopulateHelmOptionsFromQueryParams populates fields in the ChartForm using the passed
-// url.Values (the parsed query params)
-func (cf *ChartForm) PopulateHelmOptionsFromQueryParams(vals url.Values) {
-	if context, ok := vals["context"]; ok && len(context) == 1 {
-		cf.Context = context[0]
-	}
-
-	if namespace, ok := vals["namespace"]; ok && len(namespace) == 1 {
-		cf.Namespace = namespace[0]
-	}
-
-	if storage, ok := vals["storage"]; ok && len(storage) == 1 {
-		cf.Storage = storage[0]
-	}
-}
-
-// PopulateHelmOptionsFromUserID uses the passed user ID to populate the HelmOptions object
-func (cf *ChartForm) PopulateHelmOptionsFromUserID(userID uint, repo repository.UserRepository) error {
-	user, err := repo.ReadUser(userID)
-
-	if err != nil {
-		return err
-	}
-
-	cf.AllowedContexts = user.ContextToSlice()
-	cf.KubeConfig = user.RawKubeConfig
-
-	return nil
-}
-
-// ListChartForm represents the accepted values for listing Helm charts
-type ListChartForm struct {
-	*ChartForm
-	*helm.ListFilter
-}
-
-// PopulateListFromQueryParams populates fields in the ListChartForm using the passed
-// url.Values (the parsed query params)
-func (lcf *ListChartForm) PopulateListFromQueryParams(vals url.Values) {
-	if namespace, ok := vals["namespace"]; ok && len(namespace) == 1 {
-		lcf.ListFilter.Namespace = namespace[0]
-	}
-
-	if limit, ok := vals["limit"]; ok && len(limit) == 1 {
-		if limitInt, err := strconv.ParseInt(limit[0], 10, 64); err == nil {
-			lcf.ListFilter.Limit = int(limitInt)
-		}
-	}
-
-	if skip, ok := vals["skip"]; ok && len(skip) == 1 {
-		if skipInt, err := strconv.ParseInt(skip[0], 10, 64); err == nil {
-			lcf.ListFilter.Skip = int(skipInt)
-		}
-	}
-
-	if byDate, ok := vals["byDate"]; ok && len(byDate) == 1 {
-		if byDateBool, err := strconv.ParseBool(byDate[0]); err == nil {
-			lcf.ListFilter.ByDate = byDateBool
-		}
-	}
-
-	if statusFilter, ok := vals["statusFilter"]; ok {
-		lcf.ListFilter.StatusFilter = statusFilter
-	}
-}
-
-// GetChartForm represents the accepted values for getting a single Helm chart
-type GetChartForm struct {
-	*ChartForm
-	Name     string `json:"name" form:"required"`
-	Revision int    `json:"revision"`
-}
-
-// ListChartHistoryForm represents the accepted values for getting a single Helm chart
-type ListChartHistoryForm struct {
-	*ChartForm
-	Name string `json:"name" form:"required"`
-}
-
-// RollbackChartForm represents the accepted values for getting a single Helm chart
-type RollbackChartForm struct {
-	*ChartForm
-	Name     string `json:"name" form:"required"`
-	Revision int    `json:"revision" form:"required"`
-}
-
-// UpgradeChartForm represents the accepted values for updating a Helm chart
-type UpgradeChartForm struct {
-	*ChartForm
-	Name   string `json:"name" form:"required"`
-	Values string `json:"values" form:"required"`
-}

+ 1 - 1
internal/forms/k8s.go

@@ -12,7 +12,7 @@ type K8sForm struct {
 	*kubernetes.OutOfClusterConfig
 }
 
-// PopulateK8sOptionsFromQueryParams populates fields in the ChartForm using the passed
+// PopulateK8sOptionsFromQueryParams populates fields in the ReleaseForm using the passed
 // url.Values (the parsed query params)
 func (kf *K8sForm) PopulateK8sOptionsFromQueryParams(vals url.Values) {
 	if context, ok := vals["context"]; ok && len(context) == 1 {

+ 107 - 0
internal/forms/release.go

@@ -0,0 +1,107 @@
+package forms
+
+import (
+	"net/url"
+	"strconv"
+
+	"github.com/porter-dev/porter/internal/helm"
+	"github.com/porter-dev/porter/internal/repository"
+)
+
+// ReleaseForm is the generic base type for CRUD operations on releases
+type ReleaseForm struct {
+	*helm.Form
+}
+
+// PopulateHelmOptionsFromQueryParams populates fields in the ReleaseForm using the passed
+// url.Values (the parsed query params)
+func (rf *ReleaseForm) PopulateHelmOptionsFromQueryParams(vals url.Values) {
+	if context, ok := vals["context"]; ok && len(context) == 1 {
+		rf.Context = context[0]
+	}
+
+	if namespace, ok := vals["namespace"]; ok && len(namespace) == 1 {
+		rf.Namespace = namespace[0]
+	}
+
+	if storage, ok := vals["storage"]; ok && len(storage) == 1 {
+		rf.Storage = storage[0]
+	}
+}
+
+// PopulateHelmOptionsFromUserID uses the passed user ID to populate the HelmOptions object
+func (rf *ReleaseForm) PopulateHelmOptionsFromUserID(userID uint, repo repository.UserRepository) error {
+	user, err := repo.ReadUser(userID)
+
+	if err != nil {
+		return err
+	}
+
+	rf.AllowedContexts = user.ContextToSlice()
+	rf.KubeConfig = user.RawKubeConfig
+
+	return nil
+}
+
+// ListReleaseForm represents the accepted values for listing Helm releases
+type ListReleaseForm struct {
+	*ReleaseForm
+	*helm.ListFilter
+}
+
+// PopulateListFromQueryParams populates fields in the ListReleaseForm using the passed
+// url.Values (the parsed query params)
+func (lrf *ListReleaseForm) PopulateListFromQueryParams(vals url.Values) {
+	if namespace, ok := vals["namespace"]; ok && len(namespace) == 1 {
+		lrf.ListFilter.Namespace = namespace[0]
+	}
+
+	if limit, ok := vals["limit"]; ok && len(limit) == 1 {
+		if limitInt, err := strconv.ParseInt(limit[0], 10, 64); err == nil {
+			lrf.ListFilter.Limit = int(limitInt)
+		}
+	}
+
+	if skip, ok := vals["skip"]; ok && len(skip) == 1 {
+		if skipInt, err := strconv.ParseInt(skip[0], 10, 64); err == nil {
+			lrf.ListFilter.Skip = int(skipInt)
+		}
+	}
+
+	if byDate, ok := vals["byDate"]; ok && len(byDate) == 1 {
+		if byDateBool, err := strconv.ParseBool(byDate[0]); err == nil {
+			lrf.ListFilter.ByDate = byDateBool
+		}
+	}
+
+	if statusFilter, ok := vals["statusFilter"]; ok {
+		lrf.ListFilter.StatusFilter = statusFilter
+	}
+}
+
+// GetReleaseForm represents the accepted values for getting a single Helm release
+type GetReleaseForm struct {
+	*ReleaseForm
+	Name     string `json:"name" form:"required"`
+	Revision int    `json:"revision"`
+}
+
+// ListReleaseHistoryForm represents the accepted values for getting a single Helm release
+type ListReleaseHistoryForm struct {
+	*ReleaseForm
+	Name string `json:"name" form:"required"`
+}
+
+// RollbackReleaseForm represents the accepted values for getting a single Helm release
+type RollbackReleaseForm struct {
+	*ReleaseForm
+	Name     string `json:"name" form:"required"`
+	Revision int    `json:"revision" form:"required"`
+}
+
+// UpgradeReleaseForm represents the accepted values for updating a Helm release
+type UpgradeReleaseForm struct {
+	*ReleaseForm
+	Name   string `json:"name" form:"required"`
+	Values string `json:"values" form:"required"`
+}

+ 2 - 2
internal/helm/agent.go

@@ -47,8 +47,8 @@ func (a *Agent) GetReleaseHistory(
 	return cmd.Run(name)
 }
 
-// UpgradeChart upgrades a specific chart using a string of values.yaml
-func (a *Agent) UpgradeChart(
+// UpgradeRelease upgrades a specific release with new values.yaml
+func (a *Agent) UpgradeRelease(
 	name string,
 	values string,
 ) (*release.Release, error) {

+ 2 - 2
internal/helm/agent_test.go

@@ -283,7 +283,7 @@ var upgradeTests = []listReleaseTest{
 	},
 }
 
-func TestUpgradeChart(t *testing.T) {
+func TestUpgradeRelease(t *testing.T) {
 	for _, tc := range upgradeTests {
 		agent := newAgentFixture(t, tc.namespace)
 		makeReleases(t, agent, tc.releases)
@@ -292,7 +292,7 @@ func TestUpgradeChart(t *testing.T) {
 		// namespace, so we have to reset the namespace of the storage driver
 		agent.ActionConfig.Releases.Driver.(*driver.Memory).SetNamespace(tc.namespace)
 
-		agent.UpgradeChart("wordpress", "")
+		agent.UpgradeRelease("wordpress", "")
 
 		releases, err := agent.GetReleaseHistory("wordpress")
 

+ 2 - 2
server/api/k8s_handler.go

@@ -21,14 +21,14 @@ func (app *App) HandleListNamespaces(w http.ResponseWriter, r *http.Request) {
 	session, err := app.store.Get(r, app.cookieName)
 
 	if err != nil {
-		app.handleErrorFormDecoding(err, ErrChartDecode, w)
+		app.handleErrorFormDecoding(err, ErrReleaseDecode, w)
 		return
 	}
 
 	vals, err := url.ParseQuery(r.URL.RawQuery)
 
 	if err != nil {
-		app.handleErrorFormDecoding(err, ErrChartDecode, w)
+		app.handleErrorFormDecoding(err, ErrReleaseDecode, w)
 		return
 	}
 

+ 48 - 55
server/api/chart_handler.go → server/api/release_handler.go

@@ -11,18 +11,18 @@ import (
 	"github.com/porter-dev/porter/internal/helm"
 )
 
-// Enumeration of chart API error codes, represented as int64
+// Enumeration of release API error codes, represented as int64
 const (
-	ErrChartDecode ErrorCode = iota + 600
-	ErrChartValidateFields
-	ErrChartReadData
+	ErrReleaseDecode ErrorCode = iota + 600
+	ErrReleaseValidateFields
+	ErrReleaseReadData
 )
 
 // HandleListReleases retrieves a list of releases for a cluster
 // with various filter options
 func (app *App) HandleListReleases(w http.ResponseWriter, r *http.Request) {
-	form := &forms.ListChartForm{
-		ChartForm: &forms.ChartForm{
+	form := &forms.ListReleaseForm{
+		ReleaseForm: &forms.ReleaseForm{
 			Form: &helm.Form{},
 		},
 		ListFilter: &helm.ListFilter{},
@@ -31,8 +31,8 @@ func (app *App) HandleListReleases(w http.ResponseWriter, r *http.Request) {
 	agent, err := app.getAgentFromQueryParams(
 		w,
 		r,
-		form.ChartForm,
-		form.ChartForm.PopulateHelmOptionsFromQueryParams,
+		form.ReleaseForm,
+		form.ReleaseForm.PopulateHelmOptionsFromQueryParams,
 		form.PopulateListFromQueryParams,
 	)
 
@@ -44,23 +44,23 @@ func (app *App) HandleListReleases(w http.ResponseWriter, r *http.Request) {
 	releases, err := agent.ListReleases(form.Namespace, form.ListFilter)
 
 	if err != nil {
-		app.handleErrorRead(err, ErrChartReadData, w)
+		app.handleErrorRead(err, ErrReleaseReadData, w)
 		return
 	}
 
 	if err := json.NewEncoder(w).Encode(releases); err != nil {
-		app.handleErrorFormDecoding(err, ErrChartDecode, w)
+		app.handleErrorFormDecoding(err, ErrReleaseDecode, w)
 		return
 	}
 }
 
-// HandleGetChart retrieves a single chart based on a name and revision
-func (app *App) HandleGetChart(w http.ResponseWriter, r *http.Request) {
+// HandleGetRelease retrieves a single release based on a name and revision
+func (app *App) HandleGetRelease(w http.ResponseWriter, r *http.Request) {
 	name := chi.URLParam(r, "name")
 	revision, err := strconv.ParseUint(chi.URLParam(r, "revision"), 0, 64)
 
-	form := &forms.GetChartForm{
-		ChartForm: &forms.ChartForm{
+	form := &forms.GetReleaseForm{
+		ReleaseForm: &forms.ReleaseForm{
 			Form: &helm.Form{},
 		},
 		Name:     name,
@@ -70,8 +70,8 @@ func (app *App) HandleGetChart(w http.ResponseWriter, r *http.Request) {
 	agent, err := app.getAgentFromQueryParams(
 		w,
 		r,
-		form.ChartForm,
-		form.ChartForm.PopulateHelmOptionsFromQueryParams,
+		form.ReleaseForm,
+		form.ReleaseForm.PopulateHelmOptionsFromQueryParams,
 	)
 
 	// errors are handled in app.getAgentFromQueryParams
@@ -82,22 +82,22 @@ func (app *App) HandleGetChart(w http.ResponseWriter, r *http.Request) {
 	release, err := agent.GetRelease(form.Name, form.Revision)
 
 	if err != nil {
-		app.handleErrorRead(err, ErrChartReadData, w)
+		app.handleErrorRead(err, ErrReleaseReadData, w)
 		return
 	}
 
 	if err := json.NewEncoder(w).Encode(release); err != nil {
-		app.handleErrorFormDecoding(err, ErrChartDecode, w)
+		app.handleErrorFormDecoding(err, ErrReleaseDecode, w)
 		return
 	}
 }
 
-// HandleListChartHistory retrieves a history of charts based on a chart name
-func (app *App) HandleListChartHistory(w http.ResponseWriter, r *http.Request) {
+// HandleListReleaseHistory retrieves a history of releases based on a release name
+func (app *App) HandleListReleaseHistory(w http.ResponseWriter, r *http.Request) {
 	name := chi.URLParam(r, "name")
 
-	form := &forms.ListChartHistoryForm{
-		ChartForm: &forms.ChartForm{
+	form := &forms.ListReleaseHistoryForm{
+		ReleaseForm: &forms.ReleaseForm{
 			Form: &helm.Form{},
 		},
 		Name: name,
@@ -106,8 +106,8 @@ func (app *App) HandleListChartHistory(w http.ResponseWriter, r *http.Request) {
 	agent, err := app.getAgentFromQueryParams(
 		w,
 		r,
-		form.ChartForm,
-		form.ChartForm.PopulateHelmOptionsFromQueryParams,
+		form.ReleaseForm,
+		form.ReleaseForm.PopulateHelmOptionsFromQueryParams,
 	)
 
 	// errors are handled in app.getAgentFromQueryParams
@@ -118,22 +118,22 @@ func (app *App) HandleListChartHistory(w http.ResponseWriter, r *http.Request) {
 	release, err := agent.GetReleaseHistory(form.Name)
 
 	if err != nil {
-		app.handleErrorFormValidation(err, ErrChartValidateFields, w)
+		app.handleErrorFormValidation(err, ErrReleaseValidateFields, w)
 		return
 	}
 
 	if err := json.NewEncoder(w).Encode(release); err != nil {
-		app.handleErrorFormDecoding(err, ErrChartDecode, w)
+		app.handleErrorFormDecoding(err, ErrReleaseDecode, w)
 		return
 	}
 }
 
-// HandleUpgradeChart upgrades a chart with new values.yaml
-func (app *App) HandleUpgradeChart(w http.ResponseWriter, r *http.Request) {
+// HandleUpgradeRelease upgrades a release with new values.yaml
+func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
 	name := chi.URLParam(r, "name")
 
-	form := &forms.UpgradeChartForm{
-		ChartForm: &forms.ChartForm{
+	form := &forms.UpgradeReleaseForm{
+		ReleaseForm: &forms.ReleaseForm{
 			Form: &helm.Form{},
 		},
 		Name: name,
@@ -144,10 +144,10 @@ func (app *App) HandleUpgradeChart(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	agent, err := app.getAgentFromChartForm(
+	agent, err := app.getAgentFromReleaseForm(
 		w,
 		r,
-		form.ChartForm,
+		form.ReleaseForm,
 	)
 
 	// errors are handled in app.getAgentFromBodyParams
@@ -155,7 +155,7 @@ func (app *App) HandleUpgradeChart(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	_, err = agent.UpgradeChart(form.Name, form.Values)
+	_, err = agent.UpgradeRelease(form.Name, form.Values)
 
 	if err != nil {
 		app.handleErrorInternal(err, w)
@@ -165,22 +165,15 @@ func (app *App) HandleUpgradeChart(w http.ResponseWriter, r *http.Request) {
 	w.WriteHeader(http.StatusOK)
 }
 
-// HandleRollbackChart rolls a release back to a specified revision
-func (app *App) HandleRollbackChart(w http.ResponseWriter, r *http.Request) {
+// HandleRollbackRelease rolls a release back to a specified revision
+func (app *App) HandleRollbackRelease(w http.ResponseWriter, r *http.Request) {
 	name := chi.URLParam(r, "name")
-	revision, err := strconv.ParseUint(chi.URLParam(r, "revision"), 0, 64)
-
-	if err != nil {
-		app.handleErrorFormDecoding(err, ErrChartDecode, w)
-		return
-	}
 
-	form := &forms.RollbackChartForm{
-		ChartForm: &forms.ChartForm{
+	form := &forms.RollbackReleaseForm{
+		ReleaseForm: &forms.ReleaseForm{
 			Form: &helm.Form{},
 		},
-		Name:     name,
-		Revision: int(revision),
+		Name: name,
 	}
 
 	if err := json.NewDecoder(r.Body).Decode(form); err != nil {
@@ -188,10 +181,10 @@ func (app *App) HandleRollbackChart(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
-	agent, err := app.getAgentFromChartForm(
+	agent, err := app.getAgentFromReleaseForm(
 		w,
 		r,
-		form.ChartForm,
+		form.ReleaseForm,
 	)
 
 	// errors are handled in app.getAgentFromBodyParams
@@ -212,19 +205,19 @@ func (app *App) HandleRollbackChart(w http.ResponseWriter, r *http.Request) {
 // ------------------------ Release handler helper functions ------------------------ //
 
 // getAgentFromQueryParams uses the query params to populate a form, and then
-// passes that form to the underlying app.getAgentFromChartForm to create a new
+// passes that form to the underlying app.getAgentFromReleaseForm to create a new
 // Helm agent.
 func (app *App) getAgentFromQueryParams(
 	w http.ResponseWriter,
 	r *http.Request,
-	form *forms.ChartForm,
+	form *forms.ReleaseForm,
 	// populate uses the query params to populate a form
 	populate ...func(vals url.Values),
 ) (*helm.Agent, error) {
 	vals, err := url.ParseQuery(r.URL.RawQuery)
 
 	if err != nil {
-		app.handleErrorFormDecoding(err, ErrChartDecode, w)
+		app.handleErrorFormDecoding(err, ErrReleaseDecode, w)
 		return nil, err
 	}
 
@@ -232,15 +225,15 @@ func (app *App) getAgentFromQueryParams(
 		f(vals)
 	}
 
-	return app.getAgentFromChartForm(w, r, form)
+	return app.getAgentFromReleaseForm(w, r, form)
 }
 
-// getAgentFromChartForm uses a non-validated form to construct a new Helm agent based on
+// getAgentFromReleaseForm uses a non-validated form to construct a new Helm agent based on
 // the userID found in the session and the options required by the Helm agent.
-func (app *App) getAgentFromChartForm(
+func (app *App) getAgentFromReleaseForm(
 	w http.ResponseWriter,
 	r *http.Request,
-	form *forms.ChartForm,
+	form *forms.ReleaseForm,
 ) (*helm.Agent, error) {
 	// read the session in order to generate the Helm agent
 	session, err := app.store.Get(r, app.cookieName)
@@ -258,7 +251,7 @@ func (app *App) getAgentFromChartForm(
 
 	// validate the form
 	if err := app.validator.Struct(form); err != nil {
-		app.handleErrorFormValidation(err, ErrChartValidateFields, w)
+		app.handleErrorFormValidation(err, ErrReleaseValidateFields, w)
 		return nil, err
 	}
 

+ 74 - 73
server/api/chart_handler_test.go → server/api/release_handler_test.go

@@ -18,16 +18,16 @@ import (
 )
 
 type releaseStub struct {
-	name         string
-	namespace    string
-	version      int
-	chartVersion string
-	status       release.Status
+	name           string
+	namespace      string
+	version        int
+	releaseVersion string
+	status         release.Status
 }
 
 // ------------------------- TEST TYPES AND MAIN LOOP ------------------------- //
 
-type chartTest struct {
+type releaseTest struct {
 	initializers []func(tester *tester)
 	namespace    string
 	msg          string
@@ -37,10 +37,10 @@ type chartTest struct {
 	expStatus    int
 	expBody      string
 	useCookie    bool
-	validators   []func(c *chartTest, tester *tester, t *testing.T)
+	validators   []func(c *releaseTest, tester *tester, t *testing.T)
 }
 
-func testChartRequests(t *testing.T, tests []*chartTest, canQuery bool) {
+func testReleaseRequests(t *testing.T, tests []*releaseTest, canQuery bool) {
 	for _, c := range tests {
 		// create a new tester
 		tester := newTester(canQuery)
@@ -86,14 +86,14 @@ func testChartRequests(t *testing.T, tests []*chartTest, canQuery bool) {
 
 // ------------------------- TEST FIXTURES AND FUNCTIONS  ------------------------- //
 
-var listChartsTests = []*chartTest{
-	&chartTest{
+var listReleasesTests = []*releaseTest{
+	&releaseTest{
 		initializers: []func(tester *tester){
-			initDefaultCharts,
+			initDefaultReleases,
 		},
-		msg:    "List charts",
+		msg:    "List releases",
 		method: "GET",
-		endpoint: "/api/charts?" + url.Values{
+		endpoint: "/api/releases?" + url.Values{
 			"namespace":    []string{""},
 			"context":      []string{"context-test"},
 			"storage":      []string{"memory"},
@@ -104,20 +104,20 @@ var listChartsTests = []*chartTest{
 		}.Encode(),
 		body:      "",
 		expStatus: http.StatusOK,
-		expBody:   releaseStubsToChartJSON(sampleReleaseStubs),
+		expBody:   releaseStubsToReleaseJSON(sampleReleaseStubs),
 		useCookie: true,
-		validators: []func(c *chartTest, tester *tester, t *testing.T){
-			chartReleaseArrBodyValidator,
+		validators: []func(c *releaseTest, tester *tester, t *testing.T){
+			releaseReleaseArrBodyValidator,
 		},
 	},
-	&chartTest{
+	&releaseTest{
 		initializers: []func(tester *tester){
-			initDefaultCharts,
+			initDefaultReleases,
 		},
-		msg:       "List charts",
+		msg:       "List releases",
 		method:    "GET",
 		namespace: "default",
-		endpoint: "/api/charts?" + url.Values{
+		endpoint: "/api/releases?" + url.Values{
 			"namespace":    []string{"default"},
 			"context":      []string{"context-test"},
 			"storage":      []string{"memory"},
@@ -128,84 +128,84 @@ var listChartsTests = []*chartTest{
 		}.Encode(),
 		body:      "",
 		expStatus: http.StatusOK,
-		expBody: releaseStubsToChartJSON([]releaseStub{
+		expBody: releaseStubsToReleaseJSON([]releaseStub{
 			sampleReleaseStubs[0],
 			sampleReleaseStubs[2],
 		}),
 		useCookie: true,
-		validators: []func(c *chartTest, tester *tester, t *testing.T){
-			chartReleaseArrBodyValidator,
+		validators: []func(c *releaseTest, tester *tester, t *testing.T){
+			releaseReleaseArrBodyValidator,
 		},
 	},
 }
 
-func TestHandleListCharts(t *testing.T) {
-	testChartRequests(t, listChartsTests, true)
+func TestHandleListReleases(t *testing.T) {
+	testReleaseRequests(t, listReleasesTests, true)
 }
 
-var getChartTests = []*chartTest{
-	&chartTest{
+var getReleaseTests = []*releaseTest{
+	&releaseTest{
 		initializers: []func(tester *tester){
-			initDefaultCharts,
+			initDefaultReleases,
 		},
-		msg:       "Get charts",
+		msg:       "Get releases",
 		method:    "GET",
 		namespace: "default",
-		endpoint: "/api/charts/airwatch/1?" + url.Values{
+		endpoint: "/api/releases/airwatch/1?" + url.Values{
 			"namespace": []string{""},
 			"context":   []string{"context-test"},
 			"storage":   []string{"memory"},
 		}.Encode(),
 		body:      "",
 		expStatus: http.StatusOK,
-		expBody:   releaseStubToChartJSON(sampleReleaseStubs[0]),
+		expBody:   releaseStubToReleaseJSON(sampleReleaseStubs[0]),
 		useCookie: true,
-		validators: []func(c *chartTest, tester *tester, t *testing.T){
-			chartReleaseBodyValidator,
+		validators: []func(c *releaseTest, tester *tester, t *testing.T){
+			releaseReleaseBodyValidator,
 		},
 	},
 }
 
-func TestHandleGetChart(t *testing.T) {
-	testChartRequests(t, getChartTests, true)
+func TestHandleGetRelease(t *testing.T) {
+	testReleaseRequests(t, getReleaseTests, true)
 }
 
-var listChartHistoryTests = []*chartTest{
-	&chartTest{
+var listReleaseHistoryTests = []*releaseTest{
+	&releaseTest{
 		initializers: []func(tester *tester){
-			initHistoryCharts,
+			initHistoryReleases,
 		},
-		msg:       "List chart history",
+		msg:       "List release history",
 		method:    "GET",
 		namespace: "default",
-		endpoint: "/api/charts/wordpress/history?" + url.Values{
+		endpoint: "/api/releases/wordpress/history?" + url.Values{
 			"namespace": []string{""},
 			"context":   []string{"context-test"},
 			"storage":   []string{"memory"},
 		}.Encode(),
 		body:      "",
 		expStatus: http.StatusOK,
-		expBody:   releaseStubsToChartJSON(historyReleaseStubs),
+		expBody:   releaseStubsToReleaseJSON(historyReleaseStubs),
 		useCookie: true,
-		validators: []func(c *chartTest, tester *tester, t *testing.T){
-			chartReleaseArrBodyValidator,
+		validators: []func(c *releaseTest, tester *tester, t *testing.T){
+			releaseReleaseArrBodyValidator,
 		},
 	},
 }
 
-func TestHandleListChartHistory(t *testing.T) {
-	testChartRequests(t, listChartHistoryTests, true)
+func TestHandleListReleaseHistory(t *testing.T) {
+	testReleaseRequests(t, listReleaseHistoryTests, true)
 }
 
-var upgradeChartTests = []*chartTest{
-	&chartTest{
+var upgradeReleaseTests = []*releaseTest{
+	&releaseTest{
 		initializers: []func(tester *tester){
-			initHistoryCharts,
+			initHistoryReleases,
 		},
 		msg:       "Upgrade relase",
 		method:    "POST",
 		namespace: "default",
-		endpoint:  "/api/charts/wordpress/upgrade",
+		endpoint:  "/api/releases/wordpress/upgrade",
 		body: `
 			{
 				"namespace": "default",
@@ -217,11 +217,11 @@ var upgradeChartTests = []*chartTest{
 		expStatus: http.StatusOK,
 		expBody:   ``,
 		useCookie: true,
-		validators: []func(c *chartTest, tester *tester, t *testing.T){
-			func(c *chartTest, tester *tester, t *testing.T) {
+		validators: []func(c *releaseTest, tester *tester, t *testing.T){
+			func(c *releaseTest, tester *tester, t *testing.T) {
 				req, err := http.NewRequest(
 					"GET",
-					"/api/charts/wordpress/3?"+url.Values{
+					"/api/releases/wordpress/3?"+url.Values{
 						"namespace": []string{"default"},
 						"context":   []string{"context-test"},
 						"storage":   []string{"memory"},
@@ -241,7 +241,7 @@ var upgradeChartTests = []*chartTest{
 				gotBody := &release.Release{}
 				expBody := &release.Release{}
 
-				expBodyJSON := releaseStubToChartJSON(releaseStub{"wordpress", "default", 3, "1.0.2", release.StatusDeployed})
+				expBodyJSON := releaseStubToReleaseJSON(releaseStub{"wordpress", "default", 3, "1.0.2", release.StatusDeployed})
 
 				json.Unmarshal(rr2.Body.Bytes(), gotBody)
 				json.Unmarshal([]byte(expBodyJSON), expBody)
@@ -270,34 +270,35 @@ var upgradeChartTests = []*chartTest{
 	},
 }
 
-func TestUpgradeChart(t *testing.T) {
-	testChartRequests(t, upgradeChartTests, true)
+func TestUpgradeRelease(t *testing.T) {
+	testReleaseRequests(t, upgradeReleaseTests, true)
 }
 
-var rollbackChartTests = []*chartTest{
-	&chartTest{
+var rollbackReleaseTests = []*releaseTest{
+	&releaseTest{
 		initializers: []func(tester *tester){
-			initHistoryCharts,
+			initHistoryReleases,
 		},
 		msg:       "Rollback relase",
 		method:    "POST",
 		namespace: "default",
-		endpoint:  "/api/charts/rollback/wordpress/1",
+		endpoint:  "/api/releases/wordpress/rollback",
 		body: `
 			{
 				"namespace": "default",
 				"context": "context-test",
-				"storage": "memory"
+				"storage": "memory",
+				"revision": 1
 			}
 		`,
 		expStatus: http.StatusOK,
 		expBody:   ``,
 		useCookie: true,
-		validators: []func(c *chartTest, tester *tester, t *testing.T){
-			func(c *chartTest, tester *tester, t *testing.T) {
+		validators: []func(c *releaseTest, tester *tester, t *testing.T){
+			func(c *releaseTest, tester *tester, t *testing.T) {
 				req, err := http.NewRequest(
 					"GET",
-					"/api/charts/wordpress/3?"+url.Values{
+					"/api/releases/wordpress/3?"+url.Values{
 						"namespace": []string{"default"},
 						"context":   []string{"context-test"},
 						"storage":   []string{"memory"},
@@ -317,7 +318,7 @@ var rollbackChartTests = []*chartTest{
 				gotBody := &release.Release{}
 				expBody := &release.Release{}
 
-				expBodyJSON := releaseStubToChartJSON(releaseStub{"wordpress", "default", 3, "1.0.1", release.StatusDeployed})
+				expBodyJSON := releaseStubToReleaseJSON(releaseStub{"wordpress", "default", 3, "1.0.1", release.StatusDeployed})
 
 				fmt.Println(rr2.Body.String())
 
@@ -339,13 +340,13 @@ var rollbackChartTests = []*chartTest{
 	},
 }
 
-func TestRollbackChart(t *testing.T) {
-	testChartRequests(t, rollbackChartTests, true)
+func TestRollbackRelease(t *testing.T) {
+	testReleaseRequests(t, rollbackReleaseTests, true)
 }
 
 // ------------------------- INITIALIZERS AND VALIDATORS ------------------------- //
 
-func initDefaultCharts(tester *tester) {
+func initDefaultReleases(tester *tester) {
 	initUserDefault(tester)
 
 	agent := tester.app.TestAgents.HelmAgent
@@ -357,7 +358,7 @@ func initDefaultCharts(tester *tester) {
 	agent.ActionConfig.Releases.Driver.(*driver.Memory).SetNamespace("")
 }
 
-func initHistoryCharts(tester *tester) {
+func initHistoryReleases(tester *tester) {
 	initUserDefault(tester)
 
 	agent := tester.app.TestAgents.HelmAgent
@@ -380,7 +381,7 @@ var historyReleaseStubs = []releaseStub{
 	releaseStub{"wordpress", "default", 2, "1.0.2", release.StatusDeployed},
 }
 
-func releaseStubsToChartJSON(rels []releaseStub) string {
+func releaseStubsToReleaseJSON(rels []releaseStub) string {
 	releases := make([]*release.Release, 0)
 
 	for _, r := range rels {
@@ -394,7 +395,7 @@ func releaseStubsToChartJSON(rels []releaseStub) string {
 	return string(str)
 }
 
-func releaseStubToChartJSON(r releaseStub) string {
+func releaseStubToReleaseJSON(r releaseStub) string {
 	rel := releaseStubToRelease(r)
 
 	str, _ := json.Marshal(rel)
@@ -412,7 +413,7 @@ func releaseStubToRelease(r releaseStub) *release.Release {
 		},
 		Chart: &chart.Chart{
 			Metadata: &chart.Metadata{
-				Version: r.chartVersion,
+				Version: r.releaseVersion,
 				Icon:    "https://example.com/icon.png",
 			},
 		},
@@ -429,7 +430,7 @@ func makeReleases(agent *helm.Agent, rels []releaseStub) {
 	}
 }
 
-func chartReleaseBodyValidator(c *chartTest, tester *tester, t *testing.T) {
+func releaseReleaseBodyValidator(c *releaseTest, tester *tester, t *testing.T) {
 	gotBody := &release.Release{}
 	expBody := &release.Release{}
 
@@ -442,7 +443,7 @@ func chartReleaseBodyValidator(c *chartTest, tester *tester, t *testing.T) {
 	}
 }
 
-func chartReleaseArrBodyValidator(c *chartTest, tester *tester, t *testing.T) {
+func releaseReleaseArrBodyValidator(c *releaseTest, tester *tester, t *testing.T) {
 	gotBody := &[]release.Release{}
 	expBody := &[]release.Release{}
 

+ 6 - 6
server/router/router.go

@@ -27,12 +27,12 @@ func New(a *api.App, store sessions.Store, cookieName string) *chi.Mux {
 		r.Method("GET", "/auth/check", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleAuthCheck, l)))
 		r.Method("POST", "/logout", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleLogoutUser, l)))
 
-		// /api/charts routes
-		r.Method("GET", "/charts", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleListReleases, l)))
-		r.Method("GET", "/charts/{name}/history", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleListChartHistory, l)))
-		r.Method("POST", "/charts/{name}/upgrade", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleUpgradeChart, l)))
-		r.Method("GET", "/charts/{name}/{revision}", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleGetChart, l)))
-		r.Method("POST", "/charts/rollback/{name}/{revision}", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleRollbackChart, l)))
+		// /api/releases routes
+		r.Method("GET", "/releases", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleListReleases, l)))
+		r.Method("GET", "/releases/{name}/history", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleListReleaseHistory, l)))
+		r.Method("POST", "/releases/{name}/upgrade", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleUpgradeRelease, l)))
+		r.Method("GET", "/releases/{name}/{revision}", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleGetRelease, l)))
+		r.Method("POST", "/releases/{name}/rollback", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleRollbackRelease, l)))
 
 		// /api/k8s routes
 		r.Method("GET", "/k8s/namespaces", auth.BasicAuthenticate(requestlog.NewHandler(a.HandleListNamespaces, l)))