Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
8f38d12c
Commit
8f38d12c
authored
6 years ago
by
Martin Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
cmd_capabilities.py: Port to new client channel helpers
#144
parent
120b8458
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/_app/commands/cmd_capabilities.py
+24
-25
24 additions, 25 deletions
buildgrid/_app/commands/cmd_capabilities.py
with
24 additions
and
25 deletions
buildgrid/_app/commands/cmd_capabilities.py
+
24
−
25
View file @
8f38d12c
...
...
@@ -14,12 +14,13 @@
import
sys
from
urllib.parse
import
urlparse
import
click
import
grpc
from
google.protobuf
import
json_format
from
buildgrid.client.authentication
import
setup_channel
from
buildgrid.client.capabilities
import
CapabilitiesInterface
from
buildgrid._exceptions
import
InvalidArgumentError
from
..cli
import
pass_context
...
...
@@ -27,32 +28,30 @@ from ..cli import pass_context
@click.command
(
name
=
'
capabilities
'
,
short_help
=
"
Capabilities service.
"
)
@click.option
(
'
--remote
'
,
type
=
click
.
STRING
,
default
=
'
http://localhost:50051
'
,
show_default
=
True
,
help
=
"
Remote execution server
'
s URL (port defaults to 50051 if no specified).
"
)
@click.option
(
'
--auth-token
'
,
type
=
click
.
Path
(
exists
=
True
,
dir_okay
=
False
),
default
=
None
,
help
=
"
Authorization token for the remote.
"
)
@click.option
(
'
--client-key
'
,
type
=
click
.
Path
(
exists
=
True
,
dir_okay
=
False
),
default
=
None
,
help
=
"
Private client key for TLS (PEM-encoded)
"
)
help
=
"
Private client key for TLS (PEM-encoded)
.
"
)
@click.option
(
'
--client-cert
'
,
type
=
click
.
Path
(
exists
=
True
,
dir_okay
=
False
),
default
=
None
,
help
=
"
Public client certificate for TLS (PEM-encoded)
"
)
help
=
"
Public client certificate for TLS (PEM-encoded)
.
"
)
@click.option
(
'
--server-cert
'
,
type
=
click
.
Path
(
exists
=
True
,
dir_okay
=
False
),
default
=
None
,
help
=
"
Public server certificate for TLS (PEM-encoded)
"
)
help
=
"
Public server certificate for TLS (PEM-encoded)
.
"
)
@click.option
(
'
--instance-name
'
,
type
=
click
.
STRING
,
default
=
'
main
'
,
show_default
=
True
,
help
=
"
Targeted farm instance name.
"
)
@pass_context
def
cli
(
context
,
remote
,
instance_name
,
client_key
,
client_cert
,
server_cert
):
click
.
echo
(
"
Getting capabilities...
"
)
url
=
urlparse
(
remote
)
remote
=
'
{}:{}
'
.
format
(
url
.
hostname
,
url
.
port
or
50051
)
instance_name
=
instance_name
if
url
.
scheme
==
'
http
'
:
channel
=
grpc
.
insecure_channel
(
remote
)
else
:
credentials
=
context
.
load_client_credentials
(
client_key
,
client_cert
,
server_cert
)
if
not
credentials
:
click
.
echo
(
"
ERROR: no TLS keys were specified and no defaults could be found.
"
,
err
=
True
)
sys
.
exit
(
-
1
)
channel
=
grpc
.
secure_channel
(
remote
,
credentials
)
interface
=
CapabilitiesInterface
(
channel
)
response
=
interface
.
get_capabilities
(
instance_name
)
click
.
echo
(
response
)
def
cli
(
context
,
remote
,
instance_name
,
auth_token
,
client_key
,
client_cert
,
server_cert
):
"""
Entry point for the bgd-capabilities CLI command group.
"""
try
:
context
.
channel
,
_
=
setup_channel
(
remote
,
auth_token
=
auth_token
,
client_key
=
client_key
,
client_cert
=
client_cert
)
except
InvalidArgumentError
as
e
:
click
.
echo
(
"
Error: {}.
"
.
format
(
e
),
err
=
True
)
sys
.
exit
(
-
1
)
context
.
instance_name
=
instance_name
interface
=
CapabilitiesInterface
(
context
.
channel
)
response
=
interface
.
get_capabilities
(
context
.
instance_name
)
click
.
echo
(
json_format
.
MessageToJson
(
response
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment