<commit_before>#
# Cookbook Name:: cookbook-openshift3
# Resources:: openshift_deploy_router
#
# Copyright (c) 2015 The Authors, All Rights Reserved.

use_inline_resources
provides :openshift_deploy_router if defined? provides

def whyrun_supported?
  true
end

action :create do
  converge_by 'Deploy Router' do
    execute 'Annotate Hosted Router Project' do
      command "#{node['cookbook-openshift3']['openshift_common_client_binary']} annotate --overwrite namespace/${namespace_router} openshift.io/node-selector=${selector_router}"
      environment(
        'selector_router' => node['cookbook-openshift3']['openshift_hosted_router_selector'],
        'namespace_router' => node['cookbook-openshift3']['openshift_hosted_router_namespace']
      )
      not_if "#{node['cookbook-openshift3']['openshift_common_client_binary']} get namespace/${namespace_router} --template '{{ .metadata.annotations }}' | fgrep -q openshift.io/node-selector:${selector_router}"
      only_if "#{node['cookbook-openshift3']['openshift_common_client_binary']} get namespace/${namespace_router} --no-headers"
    end

    execute 'Create Hosted Router Certificate' do
      command "#{node['cookbook-openshift3']['openshift_common_client_binary']} create secret generic router-certs --from-file tls.crt=${certfile} --from-file tls.key=${keyfile} -n ${namespace_router}"
      environment(
        'certfile' => node['cookbook-openshift3']['openshift_hosted_router_certfile'],
        'keyfile' => node['cookbook-openshift3']['openshift_hosted_router_keyfile'],
        'namespace_router' => node['cookbook-openshift3']['openshift_hosted_router_namespace']
      )
      cwd node['cookbook-openshift3']['openshift_master_config_dir']
      only_if { ::File.file?(node['cookbook-openshift3']['openshift_hosted_router_certfile']) && ::File.file?(node['cookbook-openshift3']['openshift_hosted_router_keyfile']) }
      not_if "#{node['cookbook-openshift3']['openshift_common_client_binary']} get secret router-certs -n $namespace_router --no-headers"
    end

    deploy_options = %w(--selector=${selector_router} -n ${namespace_router}) + Array(new_resource.deployer_options)
    execute 'Deploy Hosted Router' do
      command "#{node['cookbook-openshift3']['openshift_common_client_binary']} adm router #{deploy_options.join(' ')} --config=#{node['cookbook-openshift3']['openshift_master_config_dir']}/admin.kubeconfig || true"
      environment(<commit_msg>Fix issue<commit_after>#
# Cookbook Name:: cookbook-openshift3
# Resources:: openshift_deploy_router
#
# Copyright (c) 2015 The Authors, All Rights Reserved.

use_inline_resources
provides :openshift_deploy_router if defined? provides

def whyrun_supported?
  true
end

action :create do
  converge_by "Deploy Router on #{node['fqdn']}" do
    execute 'Annotate Hosted Router Project' do
      command "#{node['cookbook-openshift3']['openshift_common_client_binary']} annotate --overwrite namespace/${namespace_router} openshift.io/node-selector=${selector_router}"
      environment(
        'selector_router' => node['cookbook-openshift3']['openshift_hosted_router_selector'],
        'namespace_router' => node['cookbook-openshift3']['openshift_hosted_router_namespace']
      )
      not_if "#{node['cookbook-openshift3']['openshift_common_client_binary']} get namespace/${namespace_router} --template '{{ .metadata.annotations }}' | fgrep -q openshift.io/node-selector:${selector_router}"
      only_if "#{node['cookbook-openshift3']['openshift_common_client_binary']} get namespace/${namespace_router} --no-headers"
    end

    execute 'Create Hosted Router Certificate' do
      command "#{node['cookbook-openshift3']['openshift_common_client_binary']} create secret generic router-certs --from-file tls.crt=${certfile} --from-file tls.key=${keyfile} -n ${namespace_router}"
      environment(
        'certfile' => node['cookbook-openshift3']['openshift_hosted_router_certfile'],
        'keyfile' => node['cookbook-openshift3']['openshift_hosted_router_keyfile'],
        'namespace_router' => node['cookbook-openshift3']['openshift_hosted_router_namespace']
      )
      cwd node['cookbook-openshift3']['openshift_master_config_dir']
      only_if { ::File.file?(node['cookbook-openshift3']['openshift_hosted_router_certfile']) && ::File.file?(node['cookbook-openshift3']['openshift_hosted_router_keyfile']) }
      not_if "#{node['cookbook-openshift3']['openshift_common_client_binary']} get secret router-certs -n $namespace_router --no-headers"
    end

    deploy_options = %w(--selector=${selector_router} -n ${namespace_router}) + Array(new_resource.deployer_options)
    execute 'Deploy Hosted Router' do
      command "#{node['cookbook-openshift3']['openshift_common_client_binary']} adm router #{deploy_options.join(' ')} --config=#{node['cookbook-openshift3']['openshift_master_config_dir']}/admin.kubeconfig || true"
      environment(
{'fraction_non_alphanumeric': 0.14180779432768822, 'fraction_numerical': 0.008161599673536014, 'mean_word_length': 5.904225352112676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1064660', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1488, 'n_words': 242}