Skip to content

Commit

Permalink
Merge pull request #73 from rightscale/IV-4475_add_rl10_docker_support
Browse files Browse the repository at this point in the history
IV-4475 - Add RL10 Docker integration support
  • Loading branch information
douglaswth committed Apr 21, 2016
2 parents fc48e44 + 047f004 commit 315bea8
Show file tree
Hide file tree
Showing 7 changed files with 310 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Unreleased changes
------------------
* Add --retry flag. Specifies number of retry attempts for non-successful API responses(500, 503, and timeouts only)
* cm15: Add RightScriptAttachment actions. Add RightScript delete and update_source actions.
* rl10: Add Docker integration actions.

v5.0.2 / 2016-02-05
-------------------
Expand Down
104 changes: 104 additions & 0 deletions rl10/codegen_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,110 @@ func (loc *DebugCookbookPathLocator) Delete() error {
return nil
}

/****** DockerControl ******/

// Manipulate the Docker integration in RightLink 10
type DockerControl struct {
}

//===== Locator

// DockerControlLocator exposes the DockerControl resource actions.
type DockerControlLocator struct {
Href
api *API
}

// DockerControlLocator builds a locator from the given href.
func (api *API) DockerControlLocator(href string) *DockerControlLocator {
return &DockerControlLocator{Href(href), api}
}

//===== Actions

// GET /rll/docker/control
//
// Show Docker integration features
func (loc *DockerControlLocator) Show() (string, error) {
var res string
var params rsapi.APIParams
var p rsapi.APIParams
uri, err := loc.ActionPath("DockerControl", "show")
if err != nil {
return res, err
}
req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p)
if err != nil {
return res, err
}
resp, err := loc.api.PerformRequest(req)
if err != nil {
return res, err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
respBody, _ := ioutil.ReadAll(resp.Body)
sr := string(respBody)
if sr != "" {
sr = ": " + sr
}
return res, fmt.Errorf("invalid response %s%s", resp.Status, sr)
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return res, err
}
res = string(respBody)
return res, err
}

// PUT /rll/docker/control
//
// Enable/disable Docker integration features
func (loc *DockerControlLocator) Update(options rsapi.APIParams) (string, error) {
var res string
var params rsapi.APIParams
params = rsapi.APIParams{}
var dockerHostOpt = options["docker_host"]
if dockerHostOpt != nil {
params["docker_host"] = dockerHostOpt
}
var enableDockerOpt = options["enable_docker"]
if enableDockerOpt != nil {
params["enable_docker"] = enableDockerOpt
}
var p rsapi.APIParams
uri, err := loc.ActionPath("DockerControl", "update")
if err != nil {
return res, err
}
req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p)
if err != nil {
return res, err
}
resp, err := loc.api.PerformRequest(req)
if err != nil {
return res, err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
respBody, _ := ioutil.ReadAll(resp.Body)
sr := string(respBody)
if sr != "" {
sr = ": " + sr
}
return res, fmt.Errorf("invalid response %s%s", resp.Status, sr)
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return res, err
}
res = string(respBody)
return res, err
}

/****** Env ******/

// Manipulate global script environment variables
Expand Down
72 changes: 72 additions & 0 deletions rl10/codegen_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,78 @@ var GenMetadata = map[string]*metadata.Resource{
},
},
},
"DockerControl": &metadata.Resource{
Name: "DockerControl",
Description: `Manipulate the Docker integration in RightLink 10`,
Identifier: "",
Actions: []*metadata.Action{
&metadata.Action{
Name: "show",
Description: `Show Docker integration features`,
PathPatterns: []*metadata.PathPattern{
&metadata.PathPattern{
HTTPMethod: "GET",
Pattern: "/rll/docker/control",
Variables: []string{},
Regexp: regexp.MustCompile(`/rll/docker/control`),
},
},
CommandFlags: []*metadata.ActionParam{},
APIParams: []*metadata.ActionParam{},
},

&metadata.Action{
Name: "update",
Description: `Enable/disable Docker integration features`,
PathPatterns: []*metadata.PathPattern{
&metadata.PathPattern{
HTTPMethod: "PUT",
Pattern: "/rll/docker/control",
Variables: []string{},
Regexp: regexp.MustCompile(`/rll/docker/control`),
},
},
CommandFlags: []*metadata.ActionParam{
&metadata.ActionParam{
Name: "docker_host",
Description: ``,
Type: "string",
Location: metadata.QueryParam,
Mandatory: false,
NonBlank: false,
},
&metadata.ActionParam{
Name: "enable_docker",
Description: ``,
Type: "string",
Location: metadata.QueryParam,
Mandatory: false,
NonBlank: false,
ValidValues: []string{"none", "tags", "all"},
},
},
APIParams: []*metadata.ActionParam{
&metadata.ActionParam{
Name: "docker_host",
Description: ``,
Type: "string",
Location: metadata.QueryParam,
Mandatory: false,
NonBlank: false,
},
&metadata.ActionParam{
Name: "enable_docker",
Description: ``,
Type: "string",
Location: metadata.QueryParam,
Mandatory: false,
NonBlank: false,
ValidValues: []string{"none", "tags", "all"},
},
},
},
},
},
"Env": &metadata.Resource{
Name: "Env",
Description: `Manipulate global script environment variables`,
Expand Down
28 changes: 28 additions & 0 deletions rl10/design/resources/docker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Resources
class DockerControl
include Praxis::ResourceDefinition

description 'Manipulate the Docker integration in RightLink 10'
media_type 'text/plain'

routing do
prefix '/rll/docker/control'
end

action :show do
description 'Show Docker integration features'
routing { get '' }
response :ok
end

action :update do
description 'Enable/disable Docker integration features'
routing { put '' }
params do
attribute :enable_docker, Attributor::String, required: false, values: ['none', 'tags', 'all']
attribute :docker_host, String, required: false
end
response :ok
end
end
end
5 changes: 5 additions & 0 deletions rl10/docs/api/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"name": "Resources::DebugCookbookPath",
"media_type": "Praxis-SimpleMediaType"
},
"DockerControl": {
"controller": "Resources-DockerControl",
"name": "Resources::DockerControl",
"media_type": "Praxis-SimpleMediaType"
},
"Env": {
"controller": "Resources-Env",
"name": "Resources::Env",
Expand Down
96 changes: 96 additions & 0 deletions rl10/docs/api/unversioned/resources/Resources-DockerControl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"description": "Manipulate the Docker integration in RightLink 10",
"media_type": "Praxis-SimpleMediaType",
"actions": [
{
"description": "Show Docker integration features",
"name": "show",
"metadata": {
},
"urls": [
{
"verb": "GET",
"path": "/rll/docker/control",
"version": "n/a"
}
],
"responses": {
"ok": {
"description": "Standard response for successful HTTP requests.",
"status": 200,
"headers": {
},
"media_type": {
"identifier": "text/plain"
}
}
}
},
{
"description": "Enable/disable Docker integration features",
"name": "update",
"metadata": {
},
"urls": [
{
"verb": "PUT",
"path": "/rll/docker/control",
"version": "n/a"
}
],
"params": {
"type": {
"name": "Struct",
"id": null,
"key": {
"type": {
"name": "Symbol",
"id": "Attributor-Symbol"
}
},
"attributes": {
"enable_docker": {
"values": [
"none",
"tags",
"all"
],
"required": false,
"type": {
"name": "String",
"id": "Attributor-String"
},
"source": "query"
},
"docker_host": {
"required": false,
"type": {
"name": "String",
"id": "Attributor-String"
},
"source": "query"
}
}
},
"example": {
"enable_docker": "all",
"docker_host": "specified"
}
},
"responses": {
"ok": {
"description": "Standard response for successful HTTP requests.",
"status": 200,
"headers": {
},
"media_type": {
"identifier": "text/plain"
}
}
}
}
],
"name": "Resources::DockerControl",
"metadata": {
}
}
4 changes: 4 additions & 0 deletions rl10/docs/api/unversioned/version_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"name": "Resources::DebugCookbookPath",
"friendly_name": "DebugCookbookPath"
},
"Resources-DockerControl": {
"name": "Resources::DockerControl",
"friendly_name": "DockerControl"
},
"Resources-Env": {
"name": "Resources::Env",
"friendly_name": "Env"
Expand Down

0 comments on commit 315bea8

Please sign in to comment.