Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge latest changes from master #104

Merged
merged 5 commits into from
Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
sudo: required
dist: xenial

branches:
except:
- stable

lang: go

go:
Expand Down
5 changes: 2 additions & 3 deletions script/release-binary
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ gsutil stat "${DST}/${BINARY_NAME}" \
|| echo 'Building a new binary.'

# Build the binary
bazel build --config=release //src/envoy/mixer:envoy_tar
bazel build -c dbg //src/envoy/mixer:envoy_tar
BAZEL_TARGET="bazel-bin/src/envoy/mixer/envoy_tar.tar.gz"
ln "${BAZEL_TARGET}" "${BINARY_NAME}"
cp -f "${BAZEL_TARGET}" "${BINARY_NAME}"
sha256sum "${BINARY_NAME}" > "${SHA256_NAME}"

# Copy it to the bucket.
echo "Copying ${BINARY_NAME} ${SHA256_NAME} to ${DST}/"
gsutil cp "${BINARY_NAME}" "${SHA256_NAME}" "${DST}/"

24 changes: 6 additions & 18 deletions src/envoy/mixer/http_control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ const std::string kAttrNameResponseTime = "response.time";
const std::string kAttrNameOriginIp = "origin.ip";
const std::string kAttrNameOriginHost = "origin.host";

const std::string kEnvNameSourceService = "SOURCE_SERVICE";
const std::string kEnvNameTargetService = "TARGET_SERVICE";

const std::string kAttrNameSourceService = "source.service";
const std::string kAttrNameTargetService = "target.service";

Attributes::Value StringValue(const std::string& str) {
Attributes::Value v;
v.type = Attributes::Value::STRING;
Expand Down Expand Up @@ -134,27 +128,21 @@ void FillRequestInfoAttributes(const AccessLog::RequestInfo& info,

} // namespace

HttpControl::HttpControl(const std::string& mixer_server) {
HttpControl::HttpControl(const std::string& mixer_server,
std::map<std::string, std::string>&& attributes)
: config_attributes_(std::move(attributes)) {
::istio::mixer_client::MixerClientOptions options;
options.mixer_server = mixer_server;
mixer_client_ = ::istio::mixer_client::CreateMixerClient(options);

auto source_service = getenv(kEnvNameSourceService.c_str());
if (source_service) {
source_service_ = source_service;
}
auto target_service = getenv(kEnvNameTargetService.c_str());
if (target_service) {
target_service_ = target_service;
}
}

void HttpControl::FillCheckAttributes(const HeaderMap& header_map,
Attributes* attr) {
FillRequestHeaderAttributes(header_map, attr);

SetStringAttribute(kAttrNameSourceService, source_service_, attr);
SetStringAttribute(kAttrNameTargetService, target_service_, attr);
for (const auto& attribute : config_attributes_) {
SetStringAttribute(attribute.first, attribute.second, attr);
}
}

void HttpControl::Check(HttpRequestDataPtr request_data, HeaderMap& headers,
Expand Down
9 changes: 4 additions & 5 deletions src/envoy/mixer/http_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ typedef std::shared_ptr<HttpRequestData> HttpRequestDataPtr;
class HttpControl final : public Logger::Loggable<Logger::Id::http> {
public:
// The constructor.
HttpControl(const std::string& mixer_server);
HttpControl(const std::string& mixer_server,
std::map<std::string, std::string>&& attributes);

// Make mixer check call.
void Check(HttpRequestDataPtr request_data, HeaderMap& headers,
Expand All @@ -55,10 +56,8 @@ class HttpControl final : public Logger::Loggable<Logger::Id::http> {

// The mixer client
std::unique_ptr<::istio::mixer_client::MixerClient> mixer_client_;
// Source service
std::string source_service_;
// Target service
std::string target_service_;
// The attributes read from the config file.
std::map<std::string, std::string> config_attributes_;
};

} // namespace Mixer
Expand Down
10 changes: 9 additions & 1 deletion src/envoy/mixer/http_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ class Config : public Logger::Loggable<Logger::Id::http> {
__func__);
}

http_control_ = std::make_shared<HttpControl>(mixer_server);
std::map<std::string, std::string> attributes;
if (config.hasObject("attributes")) {
for (const std::string& attr : config.getStringArray("attributes")) {
attributes[attr] = config.getString(attr);
}
}

http_control_ =
std::make_shared<HttpControl>(mixer_server, std::move(attributes));
log().debug("Called Mixer::Config contructor with mixer_server: ",
mixer_server);
}
Expand Down
2 changes: 1 addition & 1 deletion src/envoy/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,6 @@ cc_test(
native.new_git_repository(
name = "envoy_git",
remote = "https://github.com/lyft/envoy.git",
commit = "02c6fc97b4c21d25ab596a25208fbe283e927f6a",
commit = "fa1d9680d809668fef2ec9386769c79486029f04",
build_file_content = BUILD,
)