-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into css_updates
- Loading branch information
Showing
16 changed files
with
510 additions
and
590 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
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 |
---|---|---|
@@ -1,2 +0,0 @@ | ||
* @anton-sidelnikov | ||
* @artem-lifshits | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package addons | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract" | ||
) | ||
|
||
// CreateOpts contains all the values needed to create a new addon | ||
type CreateOpts struct { | ||
// API type, fixed value Addon | ||
Kind string `json:"kind" required:"true"` | ||
// API version, fixed value v3 | ||
ApiVersion string `json:"apiVersion" required:"true"` | ||
// Metadata required to create an addon | ||
Metadata CreateMetadata `json:"metadata" required:"true"` | ||
// specifications to create an addon | ||
Spec RequestSpec `json:"spec" required:"true"` | ||
} | ||
|
||
type CreateMetadata struct { | ||
Annotations CreateAnnotations `json:"annotations" required:"true"` | ||
} | ||
|
||
type CreateAnnotations struct { | ||
AddonInstallType string `json:"addon.install/type" required:"true"` | ||
} | ||
|
||
// Specifications to create an addon | ||
type RequestSpec struct { | ||
// For the addon version. | ||
Version string `json:"version" required:"true"` | ||
// Cluster ID. | ||
ClusterID string `json:"clusterID" required:"true"` | ||
// Addon Template Name. | ||
AddonTemplateName string `json:"addonTemplateName" required:"true"` | ||
// Addon Parameters | ||
Values Values `json:"values" required:"true"` | ||
} | ||
|
||
// Create accepts a CreateOpts struct and uses the values to create a new | ||
// addon. | ||
func Create(client *golangsdk.ServiceClient, opts CreateOpts, clusterId string) (*Addon, error) { | ||
b, err := build.RequestBody(opts, "") | ||
if err != nil { | ||
return nil, err | ||
} | ||
// POST /api/v3/addons | ||
raw, err := client.Post(CCEServiceURL(client, clusterId, "addons"), b, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{201}, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res Addon | ||
return &res, extract.Into(raw.Body, &res) | ||
} |
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,24 @@ | ||
package addons | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
) | ||
|
||
// Delete will permanently delete a particular addon based on its unique ID. | ||
func Delete(client *golangsdk.ServiceClient, addonId, clusterId string) error { | ||
// DELETE /api/v3/addons/{id}?cluster_id={cluster_id} | ||
url, err := golangsdk.NewURLBuilder().WithEndpoints("addons", addonId).WithQueryParams(&ClusterIdQueryParam{ClusterId: clusterId}).Build() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = client.Delete(CCEServiceURL(client, clusterId, url.String()), &golangsdk.RequestOpts{ | ||
OkCodes: []int{200}, | ||
MoreHeaders: map[string]string{"Content-Type": "application/json"}, | ||
JSONBody: nil, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
Oops, something went wrong.