Skip to content

Commit

Permalink
Fix secrets repr issue
Browse files Browse the repository at this point in the history
- Change id_attribute to Id
- add new property id
- add name fallback

Fixes docker#2025
  • Loading branch information
feliperuhland committed Nov 28, 2019
1 parent 52d030d commit 514bfd0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docker/models/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@

class Secret(Model):
"""A secret."""
id_attribute = 'ID'
id_attribute = 'Id'

def __repr__(self):
return "<%s: '%s'>" % (self.__class__.__name__, self.name)

@property
def id(self):
return self.attrs[Secret.id_attribute]

@property
def name(self):
return self.attrs['Spec']['Name']
"""
Create secret only returns Id field, so if the name field is not
present, it will show id value instead.
Issue #2025
"""
if self.attrs.get('Spec', {}).get('Name'):
return self.attrs['Spec']['Name']

return self.id

def remove(self):
"""
Expand Down

0 comments on commit 514bfd0

Please sign in to comment.