UffizziCloud / uffizzi_cli

The command-line interface for the Uffizzi API
Apache License 2.0
87 stars 46 forks source link

uffizzi project create #77

Open gadkins opened 2 years ago

gadkins commented 2 years ago

Tell us about your request Implement support for creating projects via $ uffizzi project create subcommand.

Which service(s) is this request for? uffizzi_cli

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? A user or automation (e.g. GitHub Action) should be able to create Uffizzi projects.

Describe the solution you'd like

$ uffizzi project create help (also `--help`, `-h`) 

UFFIZZI-PROJECT-CREATE()

NAME
    uffizzi-projec-create - Creates a new project

SYNOPSIS
    uffizzi project create [--name=NAME] [--slug=SLUG]
         [--description=DESCRIPTION] [UFFIZZI_WIDE_FLAG ...] 

DESCRIPTION
    Create new project.

    This command can fail for the following reasons:  
        - The project --description is too long.
        - The project --name flag is not specified.
        - The project --slug is malformed or used by another project. 

    For more information on the uffizzi project command, see:
    https:/github.com/UffizziCloud/uffizzi_cli

FLAGS
    --description=DESCRIPTION
       Description for the project you want to create. Max of 256 
       characters.

    --name=NAME
       Name for the project you want to create. 

    --slug=SLUG
       A URL-compatible name. Do not include whitespaces or special 
       characters. Project slugs must be globally unique across all 
       Uffizzi projects. 

UFFIZZI WIDE FLAGS
    These flags are available to all commands: --project. Run $ uffizzi 
    help for details.

EXAMPLES
    To create a new project with name My App, project slug my-app, and
    description "My first project", run:

        $ uffizzi project create --name="My App" --slug="my-app" \
          --description="My first project"

Are you currently working around the issue? The user must use a single default project

Additional context N/A

NealArw commented 2 years ago
  1. bundle exec uffizzi project create --name=test_1 --slug=slug_2 --description=desc_1 returns an error:
bash-5.1# bundle exec uffizzi project create --name=test_1 --slug=slug_2 --description=desc_1
bundler: failed to load command: uffizzi (/bundle_cache/ruby/3.0.0/bin/uffizzi)
/gem/lib/uffizzi/clients/api/api_client.rb:32:in `create_project': undefined method `make_post_request' for Uffizzi::HttpClient:Class (NoMethodError)
    from /gem/lib/uffizzi/cli/project.rb:72:in `handle_create_command'
    from /gem/lib/uffizzi/cli/project.rb:47:in `run'
    from /gem/lib/uffizzi/cli/project.rb:30:in `create'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:116:in `invoke'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:243:in `block in subcommand'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /gem/lib/uffizzi/cli.rb:70:in `dispatch'
    from /bundle_cache/ruby/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
    from /gem/exe/uffizzi:5:in `<top (required)>'
    from /bundle_cache/ruby/3.0.0/bin/uffizzi:25:in `load'
    from /bundle_cache/ruby/3.0.0/bin/uffizzi:25:in `<top (required)>'
    from /usr/local/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in `load'
    from /usr/local/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in `kernel_load'
    from /usr/local/lib/ruby/3.0.0/bundler/cli/exec.rb:23:in `run'
    from /usr/local/lib/ruby/3.0.0/bundler/cli.rb:478:in `exec'
    from /usr/local/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /usr/local/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /usr/local/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from /usr/local/lib/ruby/3.0.0/bundler/cli.rb:31:in `dispatch'
    from /usr/local/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /usr/local/lib/ruby/3.0.0/bundler/cli.rb:25:in `start'
    from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.32/libexec/bundle:49:in `block in <top (required)>'
    from /usr/local/lib/ruby/3.0.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
    from /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.32/libexec/bundle:37:in `<top (required)>'
    from /usr/local/bundle/bin/bundle:23:in `load'
    from /usr/local/bundle/bin/bundle:23:in `<main>'
bash-5.1#
moklidia commented 2 years ago

The error was caused by qa conflicts

NealArw commented 2 years ago

@gadkins Hi!

We have some questions:

  1. Which parameters should be required for command uffizzi project create? Both name and slug?
  2. Should we generate a unique slug if the user does not specify it? Like in the UI version of the site?
moklidia commented 2 years ago

@NealArw Added automatic slug generation in case the slug option is missing

NealArw commented 2 years ago

@gadkins Hi!

We add automatic slug generation in case the slug option is missing. I think we need to add this information in the help for the command?

p.s. Slug will be automatically generated in the format like in UI project_name-random_string

NealArw commented 2 years ago

TESTED - OK

bash-5.1# bundle exec uffizzi project create --name=test_4 --slug=slug_4 --description=descr_4
Project test_4 was successfully created
bash-5.1# bundle exec uffizzi project create --name=test_5 --description=descr_5
Project test_5 was successfully created
bash-5.1# bundle exec uffizzi project list
test_5-tuffzf
slug_4
test_3-w0sahm
test_2-q8rn7e
test_1-tkrvq
test-lvqkhl
default
bash-5.1#
image
gadkins commented 2 years ago

@NealArw We can add this line:

A URL-compatible name. Do not include whitespaces or special characters. Project slugs must be globally unique across all Uffizzi projects. If a slug is not provided, Uffizzi will automatically generate one.
NealArw commented 2 years ago

@moklidia Please, add text from the https://github.com/UffizziCloud/uffizzi_cli/issues/77#issuecomment-1126092884

NealArw commented 2 years ago

TESTED - OK

bash-5.1# bundle exec uffizzi project create --name=test_1
Project test_1 was successfully created

bash-5.1# bundle exec uffizzi project list
test_1-c9ccpe
default

bash-5.1# bundle exec uffizzi project create --name=test_2 --slug=test_2_slug
Project test_2 was successfully created

bash-5.1# bundle exec uffizzi project list
test_2_slug
test_1-c9ccpe
default

bash-5.1# bundle exec uffizzi project create --name=test_3 --description=test_3_description
Project test_3 was successfully created

bash-5.1# bundle exec uffizzi project list
test_3-ehubow
test_2_slug
test_1-c9ccpe
default
image
AnnaPochepina commented 2 years ago

verified in production