Skip to content

Commit

Permalink
resources/v1/clusters: remove cluster update
Browse files Browse the repository at this point in the history
Limes no longer has a PUT endpoint for cluster.
  • Loading branch information
talal committed Dec 5, 2020
1 parent 149286e commit fd76120
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 76 deletions.
31 changes: 0 additions & 31 deletions resources/v1/clusters/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package clusters

import (
"github.com/gophercloud/gophercloud"
"github.com/sapcc/limes"
)

// ListOptsBuilder allows extensions to add additional parameters to the List request.
Expand Down Expand Up @@ -77,33 +76,3 @@ func Get(c *gophercloud.ServiceClient, clusterID string, opts GetOptsBuilder) (r
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}

// UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateOptsBuilder interface {
ToClusterUpdateMap() (map[string]interface{}, error)
}

// UpdateOpts contains parameters to update a cluster.
type UpdateOpts struct {
Services []limes.ServiceCapacityRequest `json:"services"`
}

// ToClusterUpdateMap formats a UpdateOpts into a request body.
func (opts UpdateOpts) ToClusterUpdateMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "cluster")
}

// Update modifies the attributes of a cluster.
func Update(c *gophercloud.ServiceClient, clusterID string, opts UpdateOptsBuilder) (r UpdateResult) {
url := updateURL(c, clusterID)
b, err := opts.ToClusterUpdateMap()
if err != nil {
r.Err = err
return
}
resp, err := c.Put(url, b, nil, &gophercloud.RequestOpts{
OkCodes: []int{202},
})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
6 changes: 0 additions & 6 deletions resources/v1/clusters/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ type CommonResult struct {
gophercloud.Result
}

// UpdateResult is the result of an Update operation. Call its appropriate
// ExtractErr method to extract the error from the result.
type UpdateResult struct {
gophercloud.ErrResult
}

// ExtractClusters interprets a CommonResult as a slice of Clusters.
func (r CommonResult) ExtractClusters() ([]limes.ClusterReport, error) {
var s struct {
Expand Down
11 changes: 0 additions & 11 deletions resources/v1/clusters/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,3 @@ func HandleGetClusterSuccessfully(t *testing.T) {
fmt.Fprintf(w, clusterJSON)
})
}

// HandleUpdateClusterSuccessfully creates an HTTP handler at `/v1/clusters/:cluster_id` on the
// test handler mux that tests cluster update.
func HandleUpdateClusterSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/clusters/germany", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)

w.WriteHeader(http.StatusAccepted)
})
}
24 changes: 0 additions & 24 deletions resources/v1/clusters/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,30 +305,6 @@ func TestGetFilteredCluster(t *testing.T) {
th.CheckDeepEquals(t, expected, actual)
}

func TestUpdateCluster(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleUpdateClusterSuccessfully(t)

unit := limes.UnitBytes
opts := clusters.UpdateOpts{
Services: []limes.ServiceCapacityRequest{
{Type: "shared", Resources: []limes.ResourceCapacityRequest{
{
Name: "stuff",
Capacity: 99,
Unit: &unit,
Comment: "I got 99 problems, but a cluster ain't one.",
},
}},
},
}

// if update succeeds then a 202 (no error) is returned.
err := clusters.Update(fake.ServiceClient(), "germany", opts).ExtractErr()
th.AssertNoErr(t, err)
}

func p2i64(x int64) *int64 {
return &x
}
4 changes: 0 additions & 4 deletions resources/v1/clusters/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ func listURL(client *gophercloud.ServiceClient) string {
func getURL(client *gophercloud.ServiceClient, clusterID string) string {
return client.ServiceURL("clusters", clusterID)
}

func updateURL(client *gophercloud.ServiceClient, clusterID string) string {
return client.ServiceURL("clusters", clusterID)
}

0 comments on commit fd76120

Please sign in to comment.