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

terraform: add flexkube_containers resource #66

Merged
merged 2 commits into from
Mar 10, 2020

Conversation

invidian
Copy link
Member

@invidian invidian commented Mar 2, 2020

As a preparation to resolve #40 and #42, to have some basic patterns defined, which can be then used in more complex scenarios.

TODOs:

  • Add tests
  • Add support for all other parameters

Follow-up work:

  • Make sure Terraform does not leak secrets (we might skip 1:1 scheme mapping in favor of more secret-friendly one)

@invidian
Copy link
Member Author

invidian commented Mar 3, 2020

Sample output:
Selection_137

@codecov
Copy link

codecov bot commented Mar 4, 2020

Codecov Report

Merging #66 into master will decrease coverage by 0.74%.
The diff coverage is 92.24%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #66      +/-   ##
==========================================
- Coverage   84.03%   83.29%   -0.75%     
==========================================
  Files          36       57      +21     
  Lines        2186     2909     +723     
==========================================
+ Hits         1837     2423     +586     
- Misses        257      385     +128     
- Partials       92      101       +9
Impacted Files Coverage Δ
pkg/container/containers.go 68.32% <100%> (+0.58%) ⬆️
cmd/terraform-provider-flexkube/flexkube/ssh.go 100% <100%> (ø)
...rraform-provider-flexkube/flexkube/config_files.go 100% <100%> (ø)
.../terraform-provider-flexkube/flexkube/container.go 100% <100%> (ø)
cmd/terraform-provider-flexkube/flexkube/ports.go 100% <100%> (ø)
...orm-provider-flexkube/flexkube/container_status.go 100% <100%> (ø)
cmd/terraform-provider-flexkube/flexkube/docker.go 100% <100%> (ø)
...md/terraform-provider-flexkube/flexkube/runtime.go 100% <100%> (ø)
...vider-flexkube/flexkube/hostconfiguredcontainer.go 100% <100%> (ø)
cmd/terraform-provider-flexkube/flexkube/util.go 68.93% <100%> (ø)
... and 29 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92e8545...a4d0da1. Read the comment docs.

@codeclimate
Copy link

codeclimate bot commented Mar 5, 2020

Code Climate has analyzed commit a4d0da1 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 88.9% (50% is the threshold).

This pull request will bring the total coverage in the repository to 81.3% (-2.7% change).

View more on Code Climate.

@invidian
Copy link
Member Author

invidian commented Mar 5, 2020

Support for all features has been added. Current issues:

  • destroy doesn't seem to destroy all the containers
  • SSH password and private key leak into the SSH plan

@invidian
Copy link
Member Author

invidian commented Mar 5, 2020

SSH password and private key leak into the SSH plan

I have an idea how to address that, despite hashicorp/terraform-plugin-sdk#201. TL; DR we can have 2 different computed scheme. One which holds all the information needed for running, with Sensitive: true on the top, so it never shows to the user and 2nd one, almost identical to the first one, but with sanitized sensitive fields like password, private_key, perhaps config_files as well. This will allow to provide user a nice UX, without compromising the security.

@invidian
Copy link
Member Author

invidian commented Mar 7, 2020

destroy doesn't seem to destroy all the containers

This has been addressed in #75.

@invidian
Copy link
Member Author

invidian commented Mar 7, 2020

SSH password and private key leak into the SSH plan

Now also resolved.

Next step: don't serialize empty fields, so they don't pollute the output.

@invidian invidian force-pushed the terraform-container-runner branch 2 times, most recently from 7606c12 to 7b1ab6c Compare March 7, 2020 23:35
@invidian invidian marked this pull request as ready for review March 8, 2020 00:18
@invidian
Copy link
Member Author

invidian commented Mar 8, 2020

Next step: don't serialize empty fields, so they don't pollute the output.

That doesn't seem to be possible.

@invidian
Copy link
Member Author

invidian commented Mar 8, 2020

TODOs:

  • move all scheme code to separate package
  • add comments for all functions
  • verify, that scheme works properly with other resources. E.g. apiloadbalancer has very simple configuration and should be easy to test

Regarding failing tests, it seems that when adding large amount of code, it is not possible to satisfy Code Climate total coverage change, even though the diff coverage is >90%. Codecov is doing a better job here and it compares absolute coverage with relative coverage, so the test passes. I'll perhaps disable coverage checks for codeclimate, as they doesn't seem as valuable as Codecov ones.

@invidian
Copy link
Member Author

invidian commented Mar 8, 2020

Awesome 🎉

Selection_140

@invidian
Copy link
Member Author

invidian commented Mar 8, 2020

Regarding failing tests, it seems that when adding large amount of code, it is not possible to satisfy Code Climate total coverage change, even though the diff coverage is >90%. Codecov is doing a better job here and it compares absolute coverage with relative coverage, so the test passes. I'll perhaps disable coverage checks for codeclimate, as they doesn't seem as valuable as Codecov ones.

Disabled.

verify, that scheme works properly with other resources. E.g. apiloadbalancer has very simple configuration and should be easy to test

Done for apiloadbalancer, as seen on the screenshot above.

@invidian invidian force-pushed the terraform-container-runner branch 4 times, most recently from c7a8711 to c93c764 Compare March 10, 2020 00:20
This commit adds 'flexkube_containers' resource, which allows to deploy
any containers using Flexkube using Terraform.

Resource scheme fully implements Flexkube state and configuration
scheme, which will be a base for improving other resources, to provide
proper UI for the user, so they can see, what configuration has been
generated based on simple provided configuration.

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
So there is nothing created for the container, nothing will be
persistent to the state.

Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
@invidian invidian merged commit b01630c into flexkube:master Mar 10, 2020
@invidian invidian deleted the terraform-container-runner branch March 10, 2020 00:43
@invidian invidian added this to the 0.1.1 milestone Mar 10, 2020
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

Successfully merging this pull request may close these issues.

Improve Terraform providers
1 participant