Class: Kitchen::Terraform::ClientVersionVerifier

Inherits:
Object
  • Object
show all
Includes:
Dry::Monads::Either::Mixin
Defined in:
lib/kitchen/terraform/client_version_verifier.rb

Overview

Verifies that the output of the Terraform Client version subcommand indicates a supported version of Terraform.

Instance Method Summary collapse

Instance Method Details

#verify(version_output:) ⇒ ::Dry::Monads::Either

Verifies output from the Terraform Client version subcommand against the support version.

Supported

Terraform version ~> 0.10.2.

Parameters:

  • version_output (::String)

    the Terraform Client version subcommand output.

Returns:

  • (::Dry::Monads::Either)

    the result of the function.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/kitchen/terraform/client_version_verifier.rb', line 31

def verify(version_output:)
  Right(
    ::Gem::Version
      .new(
        version_output
          .slice(
            /v(\d+\.\d+\.\d+)/,
            1
          )
      )
  ).bind do |version|
    if requirement.satisfied_by? version
      Right "Terraform version #{version} is supported"
    else
      Left "Terraform version #{version} is not supported; upgrade to Terraform version ~> 0.10.2"
    end
  end
end