conftest-yaml/run-conftest.rb
def check_yaml_files
  client = GithubClient.new

  # Assume rego policies are in the ./policy directory, unless user supplied a
  # different location
  policy_dir = ENV.fetch("POLICY_DIR", "policy")

  # Get any additional command-line options for conftest
  conftest_options = ENV.fetch("CONFTEST_OPTIONS", "")

  # We want to test all files, rather than exiting on the first failure, so that
  # the user can see all problems reported in the log. So, we collect all the
  # exit statuses of the conftest commands.
  cmd_statuses = yaml_files_in_pr(client).map { |file|
    cmd = "conftest test -p #{policy_dir} #{conftest_options} #{file}"
    command_status(cmd)
  }

  # Fail the action if conftest failed any YAML files
  exit 1 unless cmd_statuses.all?
end
# Test all the YAML files in this PR to ensure they comply with our Rego
# policies
Test all the YAML files in this PR to ensure they comply with our Rego
policies
Test all the YAML files in this PR to ensure they comply with our Rego policies
def check_yaml_files
  client = GithubClient.new
  policy_dir = ENV.fetch("POLICY_DIR", "policy")
  conftest_options = ENV.fetch("CONFTEST_OPTIONS", "")
  cmd_statuses = yaml_files_in_pr(client).map { |file|
    cmd = "conftest test -p #{policy_dir} #{conftest_options} #{file}"
    command_status(cmd)
  }
  exit 1 unless cmd_statuses.all?
end
def check_yaml_files client = GithubClient . new policy_dir = ENV . fetch ( "POLICY_DIR" , "policy" ) conftest_options = ENV . fetch ( "CONFTEST_OPTIONS" , "" ) cmd_statuses = yaml_files_in_pr ( client ) . map { | file | cmd = "conftest test -p #{policy_dir} #{conftest_options} #{file}" command_status ( cmd ) } exit 1 unless cmd_statuses . all? end
Test all the YAML files in this PR to ensure they comply with our Rego
policies
Test all the YAML files in this PR to ensure they comply with our Rego policies
# Assume rego policies are in the ./policy directory, unless user supplied a # different location # Get any additional command-line options for conftest # We want to test all files, rather than exiting on the first failure, so that # the user can see all problems reported in the log. So, we collect all the # exit statuses of the conftest commands. # Fail the action if conftest failed any YAML files