You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2020/07/27 17:19:28 UTC
[mesos] 02/02: Remove credential text format support.
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 3f9544390c89736b9cb5e177498cd67ff021bd93
Author: Dong Zhu <dz...@d2iq.com>
AuthorDate: Mon Jul 27 13:14:45 2020 -0400
Remove credential text format support.
Since text format for credential is no longer supported, remove it.
Review: https://reviews.apache.org/r/72600/
---
CHANGELOG | 7 ++++++
src/credentials/credentials.hpp | 53 +++++++++++------------------------------
2 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 6e94a3f..ce7f697 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+Release Notes - Mesos - Version 1.11.0 (WIP)
+-------------------------------------------
+
+Additional API Changes:
+
+ * **Breaking change** Deprecated authentication credential text format support.
+
Release Notes - Mesos - Version 1.10.1 (WIP)
-------------------------------------------
* This is a bug fix release.
diff --git a/src/credentials/credentials.hpp b/src/credentials/credentials.hpp
index 6e9f4aa..c2cef69 100644
--- a/src/credentials/credentials.hpp
+++ b/src/credentials/credentials.hpp
@@ -54,30 +54,17 @@ inline Result<Credentials> read(const Path& path)
<< " credentials file is NOT accessible by others";
}
- // TODO(nfnt): Remove text format support at the end of the deprecation cycle
- // which started with version 1.0.
Try<JSON::Object> json = JSON::parse<JSON::Object>(read.get());
- if (!json.isError()) {
- Try<Credentials> credentials = ::protobuf::parse<Credentials>(json.get());
- if (!credentials.isError()) {
- return credentials.get();
- }
+ if (json.isError()) {
+ return Error("Invalid json format: " + json.error());
}
- Credentials credentials;
- foreach (const std::string& line, strings::tokenize(read.get(), "\n")) {
- const std::vector<std::string>& pairs = strings::tokenize(line, " ");
- if (pairs.size() != 2) {
- return Error("Invalid credential format at line " +
- stringify(credentials.credentials().size() + 1));
- }
-
- // Add the credential.
- Credential* credential = credentials.add_credentials();
- credential->set_principal(pairs[0]);
- credential->set_secret(pairs[1]);
+ Try<Credentials> credentials = ::protobuf::parse<Credentials>(json.get());
+ if (credentials.isError()) {
+ return Error("Failed to parse credentials: "
+ + credentials.error());
}
- return credentials;
+ return credentials.get();
}
@@ -104,28 +91,16 @@ inline Result<Credential> readCredential(const Path& path)
}
Try<JSON::Object> json = JSON::parse<JSON::Object>(read.get());
- if (!json.isError()) {
- Try<Credential> credential = ::protobuf::parse<Credential>(json.get());
- if (!credential.isError()) {
- return credential.get();
- }
+ if (json.isError()) {
+ return Error("Invalid json format: " + json.error());
}
- // TODO(nfnt): Remove text format support at the end of the deprecation cycle
- // which started with version 1.0.
- Credential credential;
- const std::vector<std::string>& line = strings::tokenize(read.get(), "\n");
- if (line.size() != 1) {
- return Error("Expecting only one credential");
+ Try<Credential> credential = ::protobuf::parse<Credential>(json.get());
+ if (credential.isError()) {
+ return Error("Failed to parse credential: "
+ + credential.error());
}
- const std::vector<std::string>& pairs = strings::tokenize(line[0], " ");
- if (pairs.size() != 2) {
- return Error("Invalid credential format");
- }
- // Add the credential.
- credential.set_principal(pairs[0]);
- credential.set_secret(pairs[1]);
- return credential;
+ return credential.get();
}
} // namespace credentials {