boltops-tools / rspec-terraspace Goto Github PK
View Code? Open in Web Editor NEWTerraspace RSpec support
License: Apache License 2.0
Terraspace RSpec support
License: Apache License 2.0
With latest terraspace and terraspace-rspec releases (2.2.7 and 0.3.2) bundle exec terraspace new test my_stack --type stack
is broken.
/home/alex/.rvm/gems/ruby-3.1.2/gems/rspec-terraspace-0.3.2/lib/templates/stack/test/Gemfile.tt:4:in `template': undefined method `build_gemfile'
The build_gemfile
helper still in use by rspec-terraspace here (and here) was removed in refactor done in boltops-tools/terraspace#312
Thanks,
Alex
This helper only seems to be usable in a very limited number of cases.
For example, if called with the name of a module as shown in the example here, it'll return the first resource in that module only.
I've spent some time trying to work on an improved version, but have got a bit stuck.
The code currently relies on terraform state pull
and redirects the output into a file that is then parsed. This state doesn't contain the resource addresses and this makes it harder to extract specific resources.
If we used terraform show -json
, the output will contain resource addresses that the helper could use instead. The output format is documented here.
And this is where I'm getting stuck.
run("show #{@mod.name} -json > #{state_path}")
doesn't behave the same as run("state pull #{@mod.name} > #{state_path}")
The output doesn't get redirected to the file and gets displayed in the terminal only (leaving an empty file).
I'm assuming this is something to do with how terraspace show
and terraspace state
are implemented differently here??
(state has its own subclass)
Unfortunately, terraform show
doesn't have any -out
option, so redirecting the output (or consuming it directly) is the only option.
I think it is the correct interface to terraform though. From the docs terraform state show
docs...
The output of terraform state show is intended for human consumption, not programmatic consumption. To extract state data for use in other software, use terraform show -json and decode the result using the documented structure.
If I could get this command to 'work' and capture the output via terraspace then I'm happy to work on updating and testing a new (or updated) state_resource
helper.
The test helpers support both module-level and project-level tests. See:
Link is broken
I would very much like to use Rspec for testing, but this seems like a placeholder repository for now. Is that the case?
Hey, I've encountered an issue with an easy fix.
In project.rb
, the detect_type
function will fail if Dir.pwd
does not contain a trailing slash (as is the case on my system). A simple ? after the slash in the regex fixes this issue.
md = dir.match(%r{app/(stacks|modules)/(.*)?/?})
If you want I can create a PR for this as well, unless you prefer a different solution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.