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

WIP: Add synced_folder_opts to puppet provisioner #10345 #10370

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

calbrecht
Copy link

@calbrecht calbrecht commented Nov 3, 2018

Provide the possibility to configure the synced folders
created by the puppet and chef provisioner with options
supported by any of the existing synced folder plugins.

Deprecate synced_folder_type and synced_folder_args.

See #10345

@todo test provisioner/puppet.rb

Provide the possibility to configure the synced folders
created by the puppet provisioner with options supported
by any of the existing synced folder plugins.

Deprecate synced_folder_type and synced_folder_args.
@calbrecht calbrecht force-pushed the provisioners-synced-folder-opts branch from b005239 to 8b7a467 Compare November 3, 2018 17:37
Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution to Vagrant! So far so good! I know it's a WIP pull request but I left some feedback for you. Let me know if you have any questions about what I wrote. Thanks! 🎉

plugins/provisioners/puppet/config/puppet.rb Outdated Show resolved Hide resolved
plugins/provisioners/puppet/config/puppet.rb Show resolved Hide resolved
plugins/provisioners/puppet/config/puppet.rb Show resolved Hide resolved
@calbrecht
Copy link
Author

@briancain thanks for your feedback, i appreciate it. :) Nevertheless some points i disagree, but will comment on them separtely. 🎉

if @config.environment_path.is_a?(Array)
# Share the environments directory with the guest
if @config.environment_path[0].to_sym == :host
root_config.vm.synced_folder(
File.expand_path(@config.environment_path[1], root_path),
environments_guest_path, folder_opts)
environments_guest_path, @config.synced_folder_opts)
Copy link
Author

Choose a reason for hiding this comment

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

These calls i really would like to test with some sort of integration test, at least against a mocked root_config.vm.synced_folder method, but did not find any good copy-paste template for it so to understand what i have to do here. Maybe you know of some place i can peak a solution to test this?

Copy link
Member

Choose a reason for hiding this comment

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

You should be able to mock this up with Rspec. Unfortunately the puppet provisioner is very sparse on tests :( You'll want to create a new describe context for this classes rspec tests around the #configure method. Ideally here I would want to mock up that a given double called vm received the method :synced_folder with the specific config options. That will be good enough locally for unit tests.

Something like

describe "#configure" do
  let(:vm) { double("vm") }
  let(:root_config) { double("root_config" } # This should actually be real when writing this test, not just pseudo code
...
  it "configures the provisioner" do
    # other stuff probably goes here!!
    expect(vm).to receive(:synced_folder).with("/path/to/the/manifest", {type=>"nfs", other=>"keys"})

    subject.configure(root_config)
  end
end

This is super basic and missing a lot of what would probably be required 😅 But that is basically how I would test that the right thing is being passed to the #synced_folder function to be stored as a config.

Copy link
Member

Choose a reason for hiding this comment

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

You will also probably need to ensure that the double vm is the right class and not just a double? Since it's apart of root_config, you'll likely need to do a bit of mocking to ensure that it is a VagrantPlugins::Kernel_V2::VMConfig type. But anyway, hopefully that gives you a good idea 👀

Copy link
Author

Choose a reason for hiding this comment

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

Yes, exactly :) Thanks very much, because it would have been tedious to search this together without knowing what to do in a new language :) Very much appreciated 👍

@calbrecht
Copy link
Author

calbrecht commented Nov 5, 2018

I know it's a WIP pull request but I left some feedback for you.

No need to apologize, in fact i was hoping to get some feedback soon that's why i created this PR early. Maybe next time i'll have to pull feedback more actively :)

@briancain briancain added this to the 2.2 milestone Nov 16, 2018
@briancain briancain self-assigned this Nov 16, 2018
@calbrecht calbrecht changed the title WIP: Add synced_folder_opts to puppet and chef provisioner #10345 WIP: Add synced_folder_opts to puppet provisioner #10345 Nov 30, 2018
@briancain
Copy link
Member

@calbrecht - Hey there! I was just curious if you needed anymore help finishing this up, or if you needed to hand it off. Thanks! :)

@hashicorp-cla
Copy link

hashicorp-cla commented Jan 15, 2019

CLA assistant check
All committers have signed the CLA.

@calbrecht
Copy link
Author

@briancain thank you very much for getting back on me.

To be honest, i got distracted by the fact that, for me, the isolated_environment is not really isolated and is pulling the plugins from my actual installation home folder (which makes running the "integration" tests that are left to implement so tedious) and eventually lost interest in writing the remaining tests after trying and failing to fix the isolation for good.

@soapy1 soapy1 changed the base branch from master to main October 19, 2020 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants