Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSFS | NC | CLI | CLI commands responses & errors refactor, --show_secrets and lstat linux fix #7655

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

romayalon
Copy link
Contributor

@romayalon romayalon commented Dec 11, 2023

Explain the changes

This PR suggests changing all cli responses / errors written to stdout to be of json format. notice that help will be printed only by help command, and no longer be available after printing errors.
create/update/status commands will result a json containing Status of the manipulated entity.
list command will result a json containing List of the listed entities.:

Example 1:
  "response": {
    "code": "AccountCreated",
    "reply": {
      "name": "account2",
      "email": "account2@noobaa.io",
      "creation_date": "2023-12-11T15:07:31.886Z",
      "access_keys": [
        {
          "access_key": "bcd",
          "secret_key": "234"
        }
      ],
      "nsfs_account_config": {
        "uid": 222,
        "gid": 222,
        "new_buckets_path": "/private/tmp/test_bucketspace_fs/root_path_manage_nsfs/new_buckets_path_user2/"
      }
    }
  }

EXAMPLE 2: 
node src/cmd/manage_nsfs account add --name project1 --email project1@gmail.com --access_key pr1 --secret_key pr1 --new_buckets_path /root/project1-data --uid "1602" --gid "1996" 2> /dev/null
{
  "error": {
    "code": "InvalidAccountNewBucketsPath",
    "message": "Account's new_buckets_path should be a valid and existing directory path",
    "detail": "/root/project1-data"
  }
}

  1. Added manage_nsfs_cli_errors.js and manage_nsfs_cli_responsed.js in order to have a well defined errors and responses of the manage cli commands.
  2. manage_nsfs.js -
    2.1. added write_stdout_response() and throw_cli_error() functions in order to have a single place where we write to stdout.
    2.2. replaced all stdout.write() calls to call the new functions while specifying the new error/response type.
    2.3. some refactoring of is_undefined(value), the validation functions.
    2.4. added --show-secrets flag.

Issues: Fixed #xxx / Gap #xxx

Testing Instructions:

  • Doc added/updated
  • Tests added

Copy link
Contributor

@naveenpaul1 naveenpaul1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@romayalon romayalon force-pushed the romy-fix-symlink-linux branch 5 times, most recently from 8f2212d to 26c4d7d Compare December 18, 2023 16:41
Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants