<commit_before><?php
return function($clusterConfig, $nodeConfig, $cloudConfig, $enabledFeatures) {
    // merge config  node <= cluster <= defaults
    $etcdSslConfig = array();

    if(!empty($clusterConfig['etcd-ssl'])) {
        $etcdSslConfig = array_merge($etcdSslConfig, $clusterConfig['etcd-ssl']);
    }

    if(!empty($nodeConfig['etcd-ssl'])) {
        $etcdSslConfig = array_merge($etcdSslConfig, $nodeConfig['etcd-ssl']);
    }

    // construct cloud-config.yml
    if (!array_key_exists('write_files', $cloudConfig)) {
        $cloudConfig['write_files'] = array();
    }

    if (!empty($nodeConfig['etcd']['name'])) {
        $etcdName = $nodeConfig['etcd']['name'];
        
    } elseif (!empty($nodeConfig['hostname'])) {
        $etcdName = $nodeConfig['hostname'];
    }

    $etcdCADir = realpath( __DIR__ . '/../var/etcd-ca' );

    $serviceDefinition = 
        "[Service]\n" .
        "Environment=ETCD_PEER_CA_FILE=/etc/ssl/etcd/certs/ca.crt\n" .
        "Environment=ETCD_PEER_CERT_FILE=/etc/ssl/etcd/certs/peer.crt\n" .
        "Environment=ETCD_PEER_KEY_FILE=/etc/ssl/etcd/private/peer.key\n" .
        "Environment=ETCD_CA_FILE=/etc/ssl/etcd/certs/ca.crt\n" .
        "Environment=ETCD_CERT_FILE=/etc/ssl/etcd/certs/server.crt\n" .
        "Environment=ETCD_KEY_FILE=/etc/ssl/etcd/private/server.key\n";

    $requiredFiles = array(
        $etcdCADir . '/certs/etcd-ca.crt'                             => '/etc/ssl/etcd/certs/ca.crt',
        $etcdCADir . '/certs/' .      $etcdName . "-peer.crt"              => '/etc/ssl/etcd/certs/peer.crt',
        $etcdCADir . '/private/' .    $etcdName . "-peer.key"              => '/etc/ssl/etcd/private/peer.key',
        $etcdCADir . '/certs/' .      $etcdName . "-server.crt"              => '/etc/ssl/etcd/certs/server.crt',
        $etcdCADir . '/private/' .    $etcdName . "-server.key"              => '/etc/ssl/etcd/private/server.key',
        $etcdCADir . '/certs/' .      $etcdName . "-client.crt"              => '/etc/ssl/etcd/certs/client.crt',
        $etcdCADir . '/private/' .    $etcdName . "-client.key"              => '/etc/ssl/etcd/private/client.key'
    );
        

    $cloudConfig['write_files'][] = array(
        'path'          => '/run/systemd/system/etcd.service.d/30-certificates.conf',
        'permissions'   => '0644',
        'content'       => $serviceDefinition
    );

    foreach ($requiredFiles as $sourceFile => $destinationFile) {
        if (!file_exists($sourceFile)) {
            throw new \Exception("Missing file " . $sourceFile);
        }

        $cloudConfig['write_files'][] = array(
            'path'          => $destinationFile,
            'permissions'   => '0644',
            'content'       => @file_get_contents($sourceFile)
        );
    }
<commit_msg>fixed path to ca.crt<commit_after><?php
return function($clusterConfig, $nodeConfig, $cloudConfig, $enabledFeatures) {
    // merge config  node <= cluster <= defaults
    $etcdSslConfig = array();

    if(!empty($clusterConfig['etcd-ssl'])) {
        $etcdSslConfig = array_merge($etcdSslConfig, $clusterConfig['etcd-ssl']);
    }

    if(!empty($nodeConfig['etcd-ssl'])) {
        $etcdSslConfig = array_merge($etcdSslConfig, $nodeConfig['etcd-ssl']);
    }

    // construct cloud-config.yml
    if (!array_key_exists('write_files', $cloudConfig)) {
        $cloudConfig['write_files'] = array();
    }

    if (!empty($nodeConfig['etcd']['name'])) {
        $etcdName = $nodeConfig['etcd']['name'];
        
    } elseif (!empty($nodeConfig['hostname'])) {
        $etcdName = $nodeConfig['hostname'];
    }

    $etcdCADir = realpath( __DIR__ . '/../var/etcd-ca' );

    $serviceDefinition = 
        "[Service]\n" .
        "Environment=ETCD_PEER_CA_FILE=/etc/ssl/etcd/certs/ca.crt\n" .
        "Environment=ETCD_PEER_CERT_FILE=/etc/ssl/etcd/certs/peer.crt\n" .
        "Environment=ETCD_PEER_KEY_FILE=/etc/ssl/etcd/private/peer.key\n" .
        "Environment=ETCD_CA_FILE=/etc/ssl/etcd/certs/ca.crt\n" .
        "Environment=ETCD_CERT_FILE=/etc/ssl/etcd/certs/server.crt\n" .
        "Environment=ETCD_KEY_FILE=/etc/ssl/etcd/private/server.key\n";

    $requiredFiles = array(
        $etcdCADir . '/certs/ca.crt'                             => '/etc/ssl/etcd/certs/ca.crt',
        $etcdCADir . '/certs/' .      $etcdName . "-peer.crt"              => '/etc/ssl/etcd/certs/peer.crt',
        $etcdCADir . '/private/' .    $etcdName . "-peer.key"              => '/etc/ssl/etcd/private/peer.key',
        $etcdCADir . '/certs/' .      $etcdName . "-server.crt"              => '/etc/ssl/etcd/certs/server.crt',
        $etcdCADir . '/private/' .    $etcdName . "-server.key"              => '/etc/ssl/etcd/private/server.key',
        $etcdCADir . '/certs/' .      $etcdName . "-client.crt"              => '/etc/ssl/etcd/certs/client.crt',
        $etcdCADir . '/private/' .    $etcdName . "-client.key"              => '/etc/ssl/etcd/private/client.key'
    );
        

    $cloudConfig['write_files'][] = array(
        'path'          => '/run/systemd/system/etcd.service.d/30-certificates.conf',
        'permissions'   => '0644',
        'content'       => $serviceDefinition
    );

    foreach ($requiredFiles as $sourceFile => $destinationFile) {
        if (!file_exists($sourceFile)) {
            throw new \Exception("Missing file " . $sourceFile);
        }

        $cloudConfig['write_files'][] = array(
            'path'          => $destinationFile,
            'permissions'   => '0644',
            'content'       => @file_get_contents($sourceFile)
        );
    }

{'fraction_non_alphanumeric': 0.18146027201145312, 'fraction_numerical': 0.0035790980672870437, 'mean_word_length': 2.1576271186440676, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, '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': '2842836', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1905, 'n_words': 225}