This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Doctor Checks to Driver and Verifier (#494)
* Fix README links * Add driver doctor * Check for empty systems with doctor * Fix references to Test Kitchen * Add note about familiarity with Test Kitchen * Add note about `kitchen doctor` command * Ensure doctor checks driver and verifier * Clarify doctor output * Add kitchen doctor acceptance test * Add doctor to changelog --------- Co-authored-by: Aaron Lane <2400330-aaron-lane@users.noreply.gitlab.com>
- Loading branch information
1 parent
463ec19
commit 694e621
Showing
12 changed files
with
301 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright 2016-2021 Copado NCS LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
module Kitchen | ||
module Terraform | ||
module Driver | ||
# Doctor checks for driver configuration errors. | ||
class Doctor | ||
# #call executes the action. | ||
# | ||
# @param config [Hash] the configuration of the driver. | ||
# @return [Boolean] +true+ if any errors are found; +false+ if no errors are found. | ||
def call(config:) | ||
errors = false | ||
client = config.fetch :client | ||
|
||
if !::File.exist? client | ||
errors = true | ||
logger.error "#{instance_name}.driver.client '#{client}' does not exist" | ||
end | ||
if !::File.executable? client | ||
errors = true | ||
logger.error "#{instance_name}.driver.client '#{client}' is not executable" | ||
end | ||
|
||
errors | ||
end | ||
|
||
# #initialize prepares a new instance of the class. | ||
# | ||
# @param instance_name [String] the name of the Kitchen instance. | ||
# @param logger [Kitchen::Logger] a logger for logging messages. | ||
# @option config [String] :client the pathname of the Terraform client. | ||
# @return [Kitchen::Terraform::Driver::Doctor] | ||
def initialize(instance_name:, logger:) | ||
self.instance_name = instance_name | ||
self.logger = logger | ||
end | ||
|
||
private | ||
|
||
attr_accessor :logger, :instance_name | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright 2016-2021 Copado NCS LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
module Kitchen | ||
module Terraform | ||
module Verifier | ||
# Doctor checks for verifier configuration errors. | ||
class Doctor | ||
# #call executes the action. | ||
# | ||
# @param config [Hash] the configuration of the verifier. | ||
# @return [Boolean] +true+ if any errors are found; +false+ if no errors are found. | ||
def call(config:) | ||
errors = false | ||
systems = config.fetch :systems | ||
|
||
if systems.empty? | ||
errors = true | ||
logger.error "#{instance_name}.verifier.systems is empty" | ||
end | ||
|
||
errors | ||
end | ||
|
||
# #initialize prepares a new instance of the class. | ||
# | ||
# @param instance_name [String] the name of the Kitchen instance. | ||
# @param logger [Kitchen::Logger] a logger for logging messages. | ||
# @option config [String] :client the pathname of the Terraform client. | ||
# @return [Kitchen::Terraform::Verifier::Doctor] | ||
def initialize(instance_name:, logger:) | ||
self.instance_name = instance_name | ||
self.logger = logger | ||
end | ||
|
||
private | ||
|
||
attr_accessor :logger, :instance_name | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.