Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
bb80d33e
Commit
bb80d33e
authored
7 years ago
by
Armon Dadgar
Browse files
Options
Download
Email Patches
Plain Diff
agent: thread ACLs for Job Register
parent
efe7fe89
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/api.go
+6
-0
api/api.go
api/jobs.go
+3
-0
api/jobs.go
command/agent/job_endpoint.go
+3
-1
command/agent/job_endpoint.go
command/agent/job_endpoint_test.go
+30
-0
command/agent/job_endpoint_test.go
with
42 additions
and
1 deletion
+42
-1
api/api.go
+
6
-
0
View file @
bb80d33e
...
...
@@ -41,6 +41,9 @@ type QueryOptions struct {
// Set HTTP parameters on the query.
Params
map
[
string
]
string
// SecretID is the secret ID of an ACL token
SecretID
string
}
// WriteOptions are used to parameterize a write
...
...
@@ -48,6 +51,9 @@ type WriteOptions struct {
// Providing a datacenter overwrites the region provided
// by the Config
Region
string
// SecretID is the secret ID of an ACL token
SecretID
string
}
// QueryMeta is used to return meta data about a query
...
...
This diff is collapsed.
Click to expand it.
api/jobs.go
+
3
-
0
View file @
bb80d33e
...
...
@@ -692,6 +692,9 @@ func (j *Job) AddPeriodicConfig(cfg *PeriodicConfig) *Job {
type
WriteRequest
struct
{
// The target region for this write
Region
string
// SecretID is the secret ID of an ACL token
SecretID
string
}
// JobValidateRequest is used to validate a job
...
...
This diff is collapsed.
Click to expand it.
command/agent/job_endpoint.go
+
3
-
1
View file @
bb80d33e
...
...
@@ -349,6 +349,7 @@ func (s *HTTPServer) jobUpdate(resp http.ResponseWriter, req *http.Request,
return
nil
,
CodedError
(
400
,
"Job ID does not match name"
)
}
s
.
parseRegion
(
req
,
&
args
.
Region
)
s
.
parseToken
(
req
,
&
args
.
SecretID
)
sJob
:=
ApiJobToStructJob
(
args
.
Job
)
...
...
@@ -357,7 +358,8 @@ func (s *HTTPServer) jobUpdate(resp http.ResponseWriter, req *http.Request,
EnforceIndex
:
args
.
EnforceIndex
,
JobModifyIndex
:
args
.
JobModifyIndex
,
WriteRequest
:
structs
.
WriteRequest
{
Region
:
args
.
WriteRequest
.
Region
,
Region
:
args
.
WriteRequest
.
Region
,
SecretID
:
args
.
WriteRequest
.
SecretID
,
},
}
var
out
structs
.
JobRegisterResponse
...
...
This diff is collapsed.
Click to expand it.
command/agent/job_endpoint_test.go
+
30
-
0
View file @
bb80d33e
...
...
@@ -171,6 +171,36 @@ func TestHTTP_JobsRegister(t *testing.T) {
})
}
func
TestHTTP_JobsRegister_ACL
(
t
*
testing
.
T
)
{
t
.
Parallel
()
httpACLTest
(
t
,
nil
,
func
(
s
*
TestAgent
)
{
// Create the job
job
:=
api
.
MockJob
()
args
:=
api
.
JobRegisterRequest
{
Job
:
job
,
WriteRequest
:
api
.
WriteRequest
{
Region
:
"global"
,
},
}
buf
:=
encodeReq
(
args
)
// Make the HTTP request
req
,
err
:=
http
.
NewRequest
(
"PUT"
,
"/v1/jobs"
,
buf
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %v"
,
err
)
}
respW
:=
httptest
.
NewRecorder
()
setToken
(
req
,
s
.
Token
)
// Make the request
obj
,
err
:=
s
.
Server
.
JobsRequest
(
respW
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %v"
,
err
)
}
assert
.
NotNil
(
t
,
obj
)
})
}
func
TestHTTP_JobsRegister_Defaulting
(
t
*
testing
.
T
)
{
t
.
Parallel
()
httpTest
(
t
,
nil
,
func
(
s
*
TestAgent
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment