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

its_container block os detection #2

Closed
nanliu opened this issue Dec 21, 2016 · 6 comments
Closed

its_container block os detection #2

nanliu opened this issue Dec 21, 2016 · 6 comments
Assignees

Comments

@nanliu
Copy link

nanliu commented Dec 21, 2016

So if I attempt to use dockerspec using docker compose with serverspec os detection:

describe docker_compose(compose_yml) do
  its_container(:mysql) do
    if os[:family] == 'redhat'
       describe ...
    end
  end
end

This results in the following error gems/specinfra-2.64.0/lib/specinfra/helper/os.rb:30:in 'detect_os': Specinfra failed os detection. (NotImplementedError). Digging a bit deeper, this is because when specinfra attempts to obtain uname via Specinfra.backend.run_command('uname -m') the docker_compose backend is missing information on which container to execute the command.

Looking at the docker_compose backend, the container settings comes from get_config(:docker_compose_container).to_s, the only problem is I'm not sure how to restore this context in rspec/resources/its_container.rb so the Specinfra.backend.run_command method runs successfully. Any hints or suggestions on how to fix this?

p.s.

If I set the :docker_compose_container, os[:family] works:

set :docker_compose_container, :mysql

os[:family]

but I'm hoping to get it working in the its_container block so this works with any container.

@zuazo zuazo added the bug label Dec 21, 2016
@zuazo zuazo added Type: Bug and removed bug labels Jan 27, 2017
@zuazo
Copy link
Owner

zuazo commented Jan 28, 2017

@nanliu sorry for my delayed answer and thank you for all your information. I'm going to try to search for a way to implement it correctly. But, as you have already seen, it is not an easy task.

@nanliu
Copy link
Author

nanliu commented Jan 30, 2017

@zuazo, thanks for looking into this. I will take another crack at this issue as well.

I recently presented a talk for Portland Docker user group regarding how to use dockerspec in a container.

This project received lots of positive feedback, and people were really interested in trying it out. I found the source code of the project to be very well documented, but most people attending wasn't aware of Ruby API docs, so maybe worth including a link in the README to: http://www.rubydoc.info/github/zuazo/dockerspec/Dockerspec

@zuazo
Copy link
Owner

zuazo commented Jan 31, 2017

@nanliu thank you, man 🍺 I don't know what to say. I'm glad to know that this little hack can be useful to others 😃 I can add a link to your presentation in the README if you want.

As for the documentation, the first badge in the README points to the documentation of the released gem:

Documentation

Your link (http://www.rubydoc.info/github/zuazo/dockerspec/Dockerspec) is for the master branch documentation.

But if you think the link to the documentation might be clearer in another way, or should we write it down elsewhere, feel free to send a PR. I will accept it with open arms. Maybe we should link both the released and master documentation at the beginning of the README?

FYI: Whatever progress I make on the OS detection subject, I will write it here.

@zuazo
Copy link
Owner

zuazo commented Mar 20, 2017

Hi @nanliu:

Sorry for the delay in my answer. Following your comments and recommendations:

Thanks for your help!

@nanliu
Copy link
Author

nanliu commented Mar 20, 2017

Thanks for fixing this!

@zuazo
Copy link
Owner

zuazo commented Mar 20, 2017

Released in 0.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants