<commit_before>require 'rschema'
require 'rschema/cidr_schema'

module Baustelle
  module Config
    module Validator
      REGIONS = %w(us-east-1 eu-west-1 eu-central-1)

      extend self

      def call(config_hash)
        RSchema.validation_error(schema, config_hash)
      end

      private

      def schema
        RSchema.schema {
          {
            optional('base_amis') => hash_of(
              String => REGIONS.
                       inject({
                                'user' => String,
                                'system' => enum(%w(ubuntu amazon)),
                                optional('user_data') => String
                              }) { |spec, region|
                spec[optional(region)] = predicate("valid ami id") { |v| v.is_a?(String) && v =~ /^ami-.*$/ }
                spec
              }
            ),
            optional('jenkins') => Hash,
            'vpc' => {
              'cidr' => cidr,
              'subnets' => hash_of(enum(%w(a b c d e)) => cidr),
              optional('peers') => hash_of(
                String => {
                  'vpc_id' => predicate("valid vpc id") { |v| v.is_a?(String) && v =~ /^vpc-.+$/ },
                  'cidr' => cidr
                }
              )
            },
            'stacks' => Hash,
            'backends' => Hash,
            'applications' => Hash,<commit_msg>Jenkins schema check<commit_after>require 'rschema'
require 'rschema/cidr_schema'

module Baustelle
  module Config
    module Validator
      REGIONS = %w(us-east-1 eu-west-1 eu-central-1)

      extend self

      def call(config_hash)
        RSchema.validation_error(schema, config_hash)
      end

      private

      def schema
        RSchema.schema {
          {
            optional('base_amis') => hash_of(
              String => REGIONS.
                       inject({
                                'user' => String,
                                'system' => enum(%w(ubuntu amazon)),
                                optional('user_data') => String
                              }) { |spec, region|
                spec[optional(region)] = predicate("valid ami id") { |v| v.is_a?(String) && v =~ /^ami-.*$/ }
                spec
              }
            ),
            optional('jenkins') => {
              'connection' => {
                'server_url' => String,
                'username' => String,
                'password' => <PASSWORD>
              },
              'options' => {
                optional('credentials_id') => String,
                optional('maven_settings_id') => String
              }
            },
            'vpc' => {
              'cidr' => cidr,
              'subnets' => hash_of(enum(%w(a b c d e)) => cidr),
              optional('peers') => hash_of(
                String => {
                  'vpc_id' => predicate("valid vpc id") { |v| v.is_a?(String) && v =~ /^vpc-.+$/ },
                  'cidr' => cidr
                }
              )
            },
            'stacks' => Hash,
            'backends' => Hash,
            'applications' => Hash,
{'fraction_non_alphanumeric': 0.13599742184982275, 'fraction_numerical': 0.0019336126329358686, 'mean_word_length': 1.1392143349414197, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7299498', 'n_tokens_mistral': 907, 'n_tokens_neox': 863, 'n_words': 170}