Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.
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: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ YAML_CPP_LIBDIR=$(YAML_CPP_DIR)

SED=/usr/bin/env sed
CMAKE=cmake
CXXFLAGS=-std=c++11 -g -I$(CPP_NETLIB_DIR) -I$(YAML_CPP_DIR)/include
CXXFLAGS=-std=c++11 -g -DENABLE_KUBERNETES_METADATA -I$(CPP_NETLIB_DIR) -I$(YAML_CPP_DIR)/include
LDFLAGS=-L$(CPP_NETLIB_LIBDIR) -L$(YAML_CPP_LIBDIR)
LDLIBS=-lcppnetlib-uri -lcppnetlib-client-connections -lboost_system \
-lboost_thread -lpthread -lyajl -lssl -lcrypto -lyaml-cpp
Expand Down Expand Up @@ -53,7 +53,7 @@ install: metadatad

export DISTRO
PKG_NAME=stackdriver-metadata
PKG_VERSION=0.0.11
PKG_VERSION=0.0.12
PKG_RELEASE=1
PKG_MAINTAINER=Stackdriver Engineering <engineering@stackdriver.com>

Expand Down
15 changes: 0 additions & 15 deletions src/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,6 @@ const std::string& Environment::KubernetesClusterName() const {
return kubernetes_cluster_name_;
}

const std::string& Environment::KubernetesApiToken() const {
std::lock_guard<std::mutex> lock(mutex_);
if (kubernetes_api_token_.empty()) {
std::string filename = "/var/run/secrets/kubernetes.io/serviceaccount/token";
std::ifstream input(filename);
if (!input.good()) {
LOG(ERROR) << "Missing Kubernetes API token " << filename;
return kubernetes_api_token_;
}
LOG(INFO) << "Reading token from " << filename;
std::getline(input, kubernetes_api_token_);
}
return kubernetes_api_token_;
}

const std::string& Environment::CredentialsClientEmail() const {
std::lock_guard<std::mutex> lock(mutex_);
ReadApplicationDefaultCredentials();
Expand Down
2 changes: 0 additions & 2 deletions src/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Environment {
const std::string& InstanceId() const;
const std::string& InstanceZone() const;
const std::string& KubernetesClusterName() const;
const std::string& KubernetesApiToken() const;
const std::string& CredentialsClientEmail() const;
const std::string& CredentialsPrivateKey() const;

Expand All @@ -49,7 +48,6 @@ class Environment {
mutable std::string zone_;
mutable std::string instance_id_;
mutable std::string kubernetes_cluster_name_;
mutable std::string kubernetes_api_token_;
mutable std::string client_email_;
mutable std::string private_key_;
mutable bool application_default_credentials_read_;
Expand Down
20 changes: 14 additions & 6 deletions src/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ class Null : public Value {

Type type() const override { return NullType; }

std::unique_ptr<Value> Clone() const override;

protected:
void Serialize(internal::JSONSerializer*) const override;
std::unique_ptr<Value> Clone() const override;
};

class Boolean : public Value {
Expand All @@ -157,11 +158,12 @@ class Boolean : public Value {

Type type() const override { return BooleanType; }

std::unique_ptr<Value> Clone() const override;

bool value() const { return value_; }

protected:
void Serialize(internal::JSONSerializer*) const override;
std::unique_ptr<Value> Clone() const override;

private:
bool value_;
Expand All @@ -174,11 +176,12 @@ class Number : public Value {

Type type() const override { return NumberType; }

std::unique_ptr<Value> Clone() const override;

double value() const { return value_; }

protected:
void Serialize(internal::JSONSerializer*) const override;
std::unique_ptr<Value> Clone() const override;

private:
double value_;
Expand All @@ -191,11 +194,12 @@ class String : public Value {

Type type() const override { return StringType; }

std::unique_ptr<Value> Clone() const override;

const std::string& value() const { return value_; }

protected:
void Serialize(internal::JSONSerializer*) const override;
std::unique_ptr<Value> Clone() const override;

private:
std::string value_;
Expand All @@ -220,9 +224,10 @@ class Array : public Value, public std::vector<std::unique_ptr<Value>> {

Type type() const override { return ArrayType; }

std::unique_ptr<Value> Clone() const override;

protected:
void Serialize(internal::JSONSerializer*) const override;
std::unique_ptr<Value> Clone() const override;
};

class Object : public Value, public std::map<std::string, std::unique_ptr<Value>> {
Expand All @@ -234,6 +239,8 @@ class Object : public Value, public std::map<std::string, std::unique_ptr<Value>

Type type() const override { return ObjectType; }

std::unique_ptr<Value> Clone() const override;

private:
// Field accessor common functionality.
template<class T>
Expand Down Expand Up @@ -276,6 +283,8 @@ class Object : public Value, public std::map<std::string, std::unique_ptr<Value>
};

public:
bool Has(const std::string& field) const { return find(field) != end(); }

// Field accessors.
template<class T>
typename FieldGetter<T>::return_type Get(const std::string& field) const
Expand All @@ -285,7 +294,6 @@ class Object : public Value, public std::map<std::string, std::unique_ptr<Value>

protected:
void Serialize(internal::JSONSerializer*) const override;
std::unique_ptr<Value> Clone() const override;
};

// Factory functions.
Expand Down
Loading