diff options
author | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-01-18 12:52:47 -0800 |
---|---|---|
committer | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-01-18 12:52:50 -0800 |
commit | 4bfbc6d3fb1cb11ac2a409764a1380d1741f2af1 (patch) | |
tree | 4d619ba824c344b82922c67b350078cf82d1ec9c | |
parent | 002602dc6b09d4012fbca05740eb4e4dbb9ce6ce (diff) |
Account for strings when reading from db
Strings are not returned unmodified by the
mongo driver and seem to have a size value prepended to them.
Using the built in string reader resolves this issue.
Issue-ID: MULTICLOUD-441
Change-Id: I5c5e35b0749a61b741c9b63cfad55bf2720d91bb
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
-rw-r--r-- | src/k8splugin/db/mongo.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/k8splugin/db/mongo.go b/src/k8splugin/db/mongo.go index 65e721c3..05976b12 100644 --- a/src/k8splugin/db/mongo.go +++ b/src/k8splugin/db/mongo.go @@ -183,7 +183,13 @@ func (m *MongoStore) Read(coll, key, tag string) ([]byte, error) { } //Return the data as a byte array - return tagdata.Lookup(tag).Value, nil + //Convert string data to byte array using the built-in functions + switch tagdata.Lookup(tag).Type { + case bson.TypeString: + return []byte(tagdata.Lookup(tag).StringValue()), nil + default: + return tagdata.Lookup(tag).Value, nil + } } // Helper function that deletes an object by its ID |