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

Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
  • Loading branch information
feliperuhland committed Feb 25, 2021
1 parent d29122a commit ed8bb55
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docker/models/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@

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

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

@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 ed8bb55

Please sign in to comment.