Add worker resource to perms table (#2241)

pull/2242/head
Jeff Mitchell 4 years ago committed by GitHub
parent a537491cbc
commit 79440c5d82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -76,6 +76,7 @@ func main() {
session,
target,
user,
worker,
)
fileContents, err := ioutil.ReadFile(permsFile)
@ -253,16 +254,9 @@ func sortedKeys(in map[string]string) []string {
return out
}
func clActions(typ string) []*Action {
func lActions(typ string) []*Action {
listVersion := strings.TrimPrefix(strings.TrimPrefix(typ, "an "), "a ")
return []*Action{
{
Name: "create",
Description: fmt.Sprintf("Create %s", typ),
Examples: []string{
"type=<type>;actions=create",
},
},
{
Name: "list",
Description: fmt.Sprintf("List %ss", listVersion),
@ -273,6 +267,18 @@ func clActions(typ string) []*Action {
}
}
func clActions(typ string) []*Action {
return append([]*Action{
{
Name: "create",
Description: fmt.Sprintf("Create %s", typ),
Examples: []string{
"type=<type>;actions=create",
},
},
}, lActions(typ)...)
}
func rudActions(typ string, pin bool) []*Action {
ret := []*Action{
{
@ -828,3 +834,37 @@ var user = &Resource{
},
},
}
var worker = &Resource{
Type: "Worker",
Scopes: []string{"Global"},
Endpoints: []*Endpoint{
{
Path: "/workers",
Params: map[string]string{
"Type": "workers",
},
Actions: append(
lActions("a worker"),
&Action{
Name: "create:worker-led",
Description: "Create a worker using the worker-led workflow",
Examples: []string{
"type=<type>;actions=create",
"type=<type>;actions=create:worker-led",
},
},
),
},
{
Path: "/workers/<id>",
Params: map[string]string{
"ID": "<id>",
"Type": "workers",
},
Actions: append(
rudActions("a worker", false),
),
},
},
}

@ -1442,6 +1442,99 @@ documentation](https://www.boundaryproject.io/api-docs) for guidance.
</ul>
</td>
</tr>
<tr>
<td rowSpan="2">Worker</td>
<td rowSpan="2">
<ul>
<li>Global</li>
</ul>
</td>
<td>
<code>/workers</code>
</td>
<td>
<ul>
<li>Type</li>
<ul>
<li>
<code>workers</code>
</li>
</ul>
</ul>
</td>
<td>
<ul>
<li>
<code>list</code>: List workers
</li>
<ul>
<li>
<code>type=&lt;type&gt;;actions=list</code>
</li>
</ul>
<li>
<code>create:worker-led</code>: Create a worker using the worker-led workflow
</li>
<ul>
<li>
<code>type=&lt;type&gt;;actions=create</code>
</li>
<li>
<code>type=&lt;type&gt;;actions=create:worker-led</code>
</li>
</ul>
</ul>
</td>
</tr>
<tr>
<td>
<code>/workers/&lt;id&gt;</code>
</td>
<td>
<ul>
<li>ID</li>
<ul>
<li>
<code>&lt;id&gt;</code>
</li>
</ul>
<li>Type</li>
<ul>
<li>
<code>workers</code>
</li>
</ul>
</ul>
</td>
<td>
<ul>
<li>
<code>read</code>: Read a worker
</li>
<ul>
<li>
<code>id=&lt;id&gt;;actions=read</code>
</li>
</ul>
<li>
<code>update</code>: Update a worker
</li>
<ul>
<li>
<code>id=&lt;id&gt;;actions=update</code>
</li>
</ul>
<li>
<code>delete</code>: Delete a worker
</li>
<ul>
<li>
<code>id=&lt;id&gt;;actions=delete</code>
</li>
</ul>
</ul>
</td>
</tr>
</tbody>
</table>

Loading…
Cancel
Save