1 # TODO: Tags should be a proper class, so that we can distinguish whether
2 # something is already a tag or not. For example, 'user-foo' is a valid
3 # username, but is ambiguous with the already-tagged username 'foo'.
6 def _prefix(prefix
, s
):
7 if s
and not s
.startswith(prefix
):
8 return '{}{}'.format(prefix
, s
)
13 if s
and s
.startswith(prefix
):
14 return s
[len(prefix
):]
18 def cloud(cloud_name
):
19 return _prefix('cloud-', cloud_name
)
22 def credential(cloud
, user
, credential_name
):
23 credential_string
= '{}_{}_{}'.format(cloud
, user
, credential_name
)
24 return _prefix('cloudcred-', credential_string
)
27 def model(cloud_name
):
28 return _prefix('model-', cloud_name
)
32 return _prefix('user-', username
)
35 def application(app_name
):
36 return _prefix('application-', app_name
)