Skip to content

Commit

Permalink
✨ feat(secrets): adds v2 secrets
Browse files Browse the repository at this point in the history
This commit introduces support for V2 secrets

BREAKING CHANGE: Secret of type "Source Secret" will be depreicated
  • Loading branch information
RomilShah committed Aug 9, 2023
1 parent de7289c commit 3bcf4e1
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 430 deletions.
58 changes: 1 addition & 57 deletions riocli/jsonschema/schemas/secret-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ definitions:
default: Docker
enum:
- Docker
- Git
required:
- type
dependencies:
Expand All @@ -70,62 +69,6 @@ definitions:
docker:
type: object
"$ref": "#/definitions/docker"
- properties:
type:
enum:
- Git
git:
type: object
"$ref": "#/definitions/git"

git:
type: object
properties:
authMethod:
type: string
default: HTTP/S Basic Auth
enum:
- HTTP/S Basic Auth
- HTTP/S Token Auth
- SSH Auth

dependencies:
authMethod:
oneOf:
- properties:
authMethod:
type: string
enum:
- HTTP/S Basic Auth
username:
type: string
password:
type: string
caCert:
type: string
required:
- username
- password
- properties:
authMethod:
type: string
enum:
- HTTP/S Token Auth
token:
type: string
caCert:
type: string
required:
- token
- properties:
authMethod:
type: string
enum:
- SSH Auth
privateKey:
type: string
required:
- privateKey
docker:
type: object
properties:
Expand All @@ -139,6 +82,7 @@ definitions:
email:
type: string
required:
- registry
- username
- password
- email
5 changes: 1 addition & 4 deletions riocli/secret/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
from click_help_colors import HelpColorsGroup

from riocli.constants import Colors
from riocli.secret.create import create_secret

from riocli.secret.delete import delete_secret
from riocli.secret.import_secret import import_secret
from riocli.secret.inspect import inspect_secret
from riocli.secret.list import list_secrets

Expand All @@ -35,8 +34,6 @@ def secret() -> None:
pass


secret.add_command(create_secret)
secret.add_command(delete_secret)
secret.add_command(list_secrets)
secret.add_command(inspect_secret)
secret.add_command(import_secret)
50 changes: 0 additions & 50 deletions riocli/secret/create.py

This file was deleted.

8 changes: 4 additions & 4 deletions riocli/secret/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import click
from click_help_colors import HelpColorsCommand

from riocli.config import new_client
from riocli.config import new_v2_client
from riocli.constants import Colors, Symbols
from riocli.secret.util import name_to_guid
from riocli.utils.spinner import with_spinner
from click_help_colors import HelpColorsCommand

@click.command(
'delete',
Expand All @@ -41,8 +41,8 @@ def delete_secret(force: str, secret_name: str, secret_guid: str, spinner=None)
abort=True)

try:
client = new_client()
client.delete_secret(secret_guid)
client = new_v2_client(with_project=True)
client.delete_secret(secret_name)
spinner.text = click.style('Secret deleted successfully.', fg=Colors.GREEN)
spinner.green.ok(Symbols.SUCCESS)
except Exception as e:
Expand Down
44 changes: 0 additions & 44 deletions riocli/secret/docker_secret.py

This file was deleted.

106 changes: 0 additions & 106 deletions riocli/secret/import_secret.py

This file was deleted.

22 changes: 5 additions & 17 deletions riocli/secret/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.
import click
from click_help_colors import HelpColorsCommand
from rapyuta_io import Secret
from munch import unmunchify

from riocli.config import new_client
from riocli.config import new_v2_client
from riocli.constants import Colors
from riocli.secret.util import name_to_guid
from riocli.utils import inspect_with_format
Expand All @@ -36,21 +36,9 @@ def inspect_secret(format_type: str, secret_name: str, secret_guid: str) -> None
Inspect a secret
"""
try:
client = new_client()
secret = client.get_secret(secret_guid)
data = make_secret_inspectable(secret)
inspect_with_format(data, format_type)
client = new_v2_client()
secret = client.get_secret(secret_name)
inspect_with_format(unmunchify(secret), format_type)
except Exception as e:
click.secho(str(e), fg=Colors.RED)
raise SystemExit(1)


def make_secret_inspectable(obj: Secret) -> dict:
return {
'created_at': obj.created_at,
'creator': obj.creator,
'guid': obj.guid,
'name': obj.name,
'project': obj.project_guid,
'secret_type': obj.secret_type.value,
}
Loading

0 comments on commit 3bcf4e1

Please sign in to comment.