Skip to content
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.

Allow users to omit the optional verification hashes #9

Merged
merged 4 commits into from
Jul 31, 2017

Conversation

MerlinDMC
Copy link
Contributor

As described in the configuration spec verification is optional for files and configuration append/replace sources.

This PR does only push the Hash back into the ignition configuration if the verification option was set in the terraform configuration. That way the config validation does not throw malformed hash specifier errors if one would omit the verification option.

Copy link
Contributor

@grubernaut grubernaut left a comment

Choose a reason for hiding this comment

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

LGTM, couple of minor nits

func TestIngnitionFileAppendNoVerification(t *testing.T) {
testIgnition(t, `
data "ignition_config" "test" {
append {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit: odd spacing here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That one was copied down from the original tests :)
I've changed them all to tabs so they should look nice.

h, err := buildHash(d.Get("source.0.verification").(string))
if err != nil {
return "", err
verification := d.Get("source.0.verification").(string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use the helper function GetOk() here. ie:

if v, ok := d.GetOk("source.0.verification"); ok {
  h, err := buildHash(v.(string))
  if err != nil {
    return "", err
  }
  hash = &h
}

Copy link
Contributor

@grubernaut grubernaut left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@grubernaut grubernaut merged commit 8af5270 into hashicorp:master Jul 31, 2017
@MerlinDMC MerlinDMC deleted the verification-optional branch July 31, 2017 17:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants