Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
cli
Merge requests
!4
Fix
#4
: lazy password evaluation
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix
#4
: lazy password evaluation
4-lazy-password
into
master
Overview
0
Commits
1
Pipelines
2
Changes
2
Merged
Agate
requested to merge
4-lazy-password
into
master
6 years ago
Overview
0
Commits
1
Pipelines
2
Changes
2
Expand
Closes
#4 (closed)
Mimics django's lazy string behaviour.
0
0
Merge request reports
Compare
master
version 1
9467107e
6 years ago
master (base)
and
latest version
latest version
768f2701
1 commit,
6 years ago
version 1
9467107e
1 commit,
6 years ago
2 files
+
48
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
funkwhale_cli/cli.py
+
30
−
1
Options
@@ -88,6 +88,35 @@ RAW_DECORATOR = click.option(
"
--raw
"
,
is_flag
=
True
,
help
=
"
Directly output JSON returned by the happy
"
)
class
lazy_credential
():
"""
A proxy object to request access to the proxy object at the later possible point,
cf #4
"""
def
__init__
(
self
,
*
args
):
self
.
args
=
args
self
.
_cached_value
=
None
@property
def
value
(
self
):
if
self
.
_cached_value
:
return
self
.
_cached_value
v
=
keyring
.
get_password
(
*
self
.
args
)
self
.
_cached_value
=
v
return
v
def
__str__
(
self
):
return
str
(
self
.
value
)
def
__eq__
(
self
,
other
):
return
self
.
value
==
other
def
__repr__
(
self
):
return
str
(
self
.
value
)
def
__bool__
(
self
):
return
bool
(
self
.
value
)
def
set_server
(
ctx
,
url
,
token
):
ctx
.
ensure_object
(
dict
)
@@ -96,7 +125,7 @@ def set_server(ctx, url, token):
ctx
.
obj
[
"
SERVER_NETLOC
"
]
=
parsed
.
netloc
ctx
.
obj
[
"
SERVER_PROTOCOL
"
]
=
parsed
.
scheme
try
:
token
=
token
or
keyring
.
get_password
(
url
,
"
_
"
)
token
=
token
or
lazy_credential
(
url
,
"
_
"
)
except
ValueError
as
e
:
raise
click
.
ClickException
(
"
Error while retrieving password from keyring: {}. Your password may be incorrect.
"
.
format
(
e
.
args
[
0
]))
except
Exception
as
e
:
Loading