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

Function: pdk new module my_module does not work when a user name contains non-alphanumeric characters #106

Closed
davinhanlon opened this issue Jun 26, 2017 · 4 comments

Comments

@davinhanlon
Copy link

My user name contains a dot (it is: davin.hanlon). When I try to create a new module using the 'pdk new module' command I get an error, as below. This is due to the presence of the dot in my username.

davin:~ davin.hanlon$ pdk new module harrumph
pdk (INFO): Creating new module: harrumph
/Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/lib/pdk/module/metadata.rb:101:in validate_name': Invalid 'name' field in metadata.json: the namespace contains non-alphanumeric characters (ArgumentError) from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/lib/pdk/module/metadata.rb:77:in process_name'
from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/lib/pdk/module/metadata.rb:64:in update!' from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/lib/pdk/module/metadata.rb:41:in initialize'
from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/lib/pdk/generators/module.rb:35:in new' from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/lib/pdk/generators/module.rb:35:in invoke'
from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/lib/pdk/cli/new/module.rb:41:in block (2 levels) in <module:CLI>' from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/cri-2.9.1/lib/cri/command.rb:319:in run_this'
from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/cri-2.9.1/lib/cri/command.rb:264:in run' from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/cri-2.9.1/lib/cri/command.rb:282:in run'
from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/cri-2.9.1/lib/cri/command.rb:282:in run' from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/lib/pdk/cli.rb:14:in run'
from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/gems/pdk-0.2.0/exe/pdk:5:in <top (required)>' from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/bin/pdk:23:in load'
from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/bin/pdk:23:in <main>' from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in eval'
from /Users/davin.hanlon/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `

'

@DavidS DavidS added the bug label Jun 26, 2017
@DavidS
Copy link
Contributor

DavidS commented Jun 26, 2017

Thanks for your report, we'll look into it!

Apparently

'name' => "#{Etc.getlogin}-#{opts[:name]}",
needs to be fixed to create a legal namespace, i.e. strip everything not matching
!(string =~ %r{\A([a-z][a-z0-9_]*)(::[a-z][a-z0-9_]*)*\Z}).nil?

@scotje
Copy link
Contributor

scotje commented Jun 26, 2017

I think #103 will probably resolve this?

@DavidS
Copy link
Contributor

DavidS commented Jun 27, 2017

@scotje nope, the validation fails during initialisation, way before anything #103 touches. I've added a simple test to #108, we can continue there.

@DavidS
Copy link
Contributor

DavidS commented Jun 28, 2017

This was fixed by #108

@DavidS DavidS closed this as completed Jun 28, 2017
@DavidS DavidS changed the title Function: pdk new module my_mdule does not work when a user name contains non-alphanumeric characters Function: pdk new module my_module does not work when a user name contains non-alphanumeric characters Jun 28, 2017
@DavidS DavidS removed the bug label Jun 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants