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

Specifying -c or --config during berks upload does nothing... #201

Merged
merged 2 commits into from Nov 11, 2012
Merged

Specifying -c or --config during berks upload does nothing... #201

merged 2 commits into from Nov 11, 2012

Conversation

sethvargo
Copy link
Contributor

The only way to upload a cookbook to Chef Server is to continuously overwrite the ~/.berkshelf/config.json file. This is not very feasible when working with multiple Chef Server installations.

It always reads the ~/.berkshelf/config.json, regardless of the flag being specified.

@sethvargo
Copy link
Contributor Author

Also see #202

@reset
Copy link
Contributor

reset commented Nov 11, 2012

Hey Seth,

You should be able to specify the -c flag pointing to a different Berks config. Is that not working?

Jamie Winsor
@resetexistence

On Nov 10, 2012, at 9:51 PM, Seth Vargo notifications@github.com wrote:

The only way to upload a cookbook to Chef Server is to continuously overwrite the ~/.berkshelf/config.json file. This is not very feasible when working with multiple Chef Server installations.


Reply to this email directly or view it on GitHub.

@sethvargo
Copy link
Contributor Author

Hey Jamie,

It doesn't appear to be working. This PR removes the attr_writer and defines an actual method for setting the path. Example:

# lib/berkshelf/cli.rb
def initialize(*args)
  super(*args)

  puts "@options[:config] was #{@options[:config]}" # add
  if @options[:config]
    unless File.exist?(@options[:config])
      raise BerksConfigNotFound, "You specified a path to a configuration file that did not exist: '#{@options[:config]}'"
    end
    puts "Setting Berkshelf::Config.path = #{@options[:config]}" # add
    Berkshelf::Config.path = @options[:config]
    puts "Berkshelf::Config.path is now #{@options[:config]}" # add
  end

  Berkshelf.set_format @options[:format]
  @options = options.dup # unfreeze frozen options Hash from Thor
end

Running bundle exec berks upload -c ./config.json will print:

@options[:config] was ./config.json
Setting Berkshelf::Config.path = ./config.json
Berkshelf::Config.path is now /Users/svargo/.berkshelf/config.json

The argument is clearly passed, but the path= method was not working with attr_writer. Take a look at the PR and let me know what you think.

@reset
Copy link
Contributor

reset commented Nov 11, 2012

@sethvargo good catch - the writer should definitely expand the path when assigning.

reset added a commit that referenced this pull request Nov 11, 2012
Specifying -c or --config during `berks upload` does nothing...
@reset reset merged commit 1b2e797 into berkshelf:master Nov 11, 2012
@sethvargo
Copy link
Contributor Author

<3

@berkshelf berkshelf locked and limited conversation to collaborators Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants