MCPcopy Create free account
hub / github.com/apache/trafficserver / parse_config

Method parse_config

plugins/origin_server_auth/origin_server_auth.cc:604–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602};
603
604bool
605S3Config::parse_config(const std::string &config_fname)
606{
607 if (0 == config_fname.size()) {
608 TSError("[%s] called without a config file, this is broken", PLUGIN_NAME);
609 return false;
610 } else {
611 std::ifstream file;
612 file.open(config_fname, std::ios_base::in);
613
614 if (!file.is_open()) {
615 TSError("[%s] unable to open %s", PLUGIN_NAME, config_fname.c_str());
616 return false;
617 }
618
619 for (std::string buf; std::getline(file, buf);) {
620 swoc::TextView line{buf};
621
622 // Skip leading/trailing white spaces
623 swoc::TextView key_val = line.trim_if(&isspace);
624
625 // Skip empty or comment lines
626 if (key_val.empty() || ('#' == key_val[0])) {
627 continue;
628 }
629
630 // Identify the keys (and values if appropriate)
631 std::string key_str{key_val.take_prefix_at('=').trim_if(&isspace)};
632 std::string val_str{key_val.trim_if(&isspace)};
633
634 if (key_str == "secret_key") {
635 set_secret(val_str.c_str());
636 } else if (key_str == "access_key") {
637 set_keyid(val_str.c_str());
638 } else if (key_str == "session_token") {
639 set_token(val_str.c_str());
640 } else if (key_str == "version") {
641 set_version(val_str.c_str());
642 } else if (key_str == "virtual_host") {
643 set_virt_host();
644 } else if (key_str == "v4-include-headers") {
645 set_include_headers(val_str.c_str());
646 } else if (key_str == "v4-exclude-headers") {
647 set_exclude_headers(val_str.c_str());
648 } else if (key_str == "v4-region-map") {
649 set_region_map(val_str.c_str());
650 } else if (key_str == "expiration") {
651 set_expiration(val_str.c_str());
652 } else {
653 TSWarning("[%s] unknown config key: %s %s", PLUGIN_NAME, key_str.c_str(), config_fname.c_str());
654 }
655 }
656 }
657
658 return true;
659}
660
661void

Callers 1

getMethod · 0.45

Calls 8

TSWarningFunction · 0.85
take_prefix_atMethod · 0.80
TSErrorFunction · 0.50
sizeMethod · 0.45
openMethod · 0.45
is_openMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected