Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::LocalFileSecretStorage Class Reference
Inheritance diagram for duckdb::LocalFileSecretStorage:
Collaboration diagram for duckdb::LocalFileSecretStorage:

Public Member Functions

 LocalFileSecretStorage (SecretManager &manager, DatabaseInstance &db, const string &name_p, const string &secret_path)
Public Member Functions inherited from duckdb::CatalogSetSecretStorage
 CatalogSetSecretStorage (DatabaseInstance &db_instance, const string &name_p, const int64_t offset)
string & GetName () override
 SecretStorage API.
unique_ptr< SecretEntry > StoreSecret (unique_ptr< const BaseSecret > secret, OnCreateConflict on_conflict, optional_ptr< CatalogTransaction > transaction=nullptr) override
 Store a secret.
vector< SecretEntry > AllSecrets (optional_ptr< CatalogTransaction > transaction=nullptr) override
 Get all secrets.
void DropSecretByName (const string &name, OnEntryNotFound on_entry_not_found, optional_ptr< CatalogTransaction > transaction=nullptr) override
 Drop secret by name.
SecretMatch LookupSecret (const string &path, const string &type, optional_ptr< CatalogTransaction > transaction=nullptr) override
 Get best match.
unique_ptr< SecretEntry > GetSecretByName (const string &name, optional_ptr< CatalogTransaction > transaction=nullptr) override
 Get a secret by name.
Public Member Functions inherited from duckdb::SecretStorage
 SecretStorage (const string &name, const int64_t tie_break_offset)
virtual bool IncludeInLookups ()
 Returns include_in_lookups, used to create secret storage.
virtual bool Persistent () const

Protected Member Functions

void WriteSecret (const BaseSecret &secret, OnCreateConflict on_conflict) override
 Implements the writes to disk.
void RemoveSecret (const string &secret, OnEntryNotFound on_entry_not_found) override
 Implements the deletes from disk.
Protected Member Functions inherited from duckdb::CatalogSetSecretStorage
CatalogTransaction GetTransactionOrDefault (optional_ptr< CatalogTransaction > transaction)
 Returns the CatalogTransaction in transaction if not set, return the System transaction.

Protected Attributes

case_insensitive_set_t persistent_secrets
 Set of persistent secrets that are lazily loaded.
string secret_path
 Path that is searched for secrets;.
Protected Attributes inherited from duckdb::CatalogSetSecretStorage
unique_ptr< CatalogSet > secrets
 CatalogSet containing the secrets.
DatabaseInstance & db
 DB instance for accessing the system catalog transaction.
Protected Attributes inherited from duckdb::SecretStorage
string storage_name
 Name of the storage backend (e.g. temporary, file, etc).
const int64_t tie_break_offset
 Offset associated to this storage for tie-breaking secrets between storages.
bool persistent
 Whether entries in this storage will survive duckdb reboots.

Additional Inherited Members

Static Public Attributes inherited from duckdb::SecretStorage
static const int64_t TEMPORARY_STORAGE_OFFSET = 10
 Default storage backend offsets.
static const int64_t LOCAL_FILE_STORAGE_OFFSET = 20
Static Protected Member Functions inherited from duckdb::SecretStorage
static SecretMatch SelectBestMatch (SecretEntry &secret_entry, const string &path, int64_t offset, SecretMatch &current_best)

Constructor & Destructor Documentation

◆ LocalFileSecretStorage()

duckdb::LocalFileSecretStorage::LocalFileSecretStorage ( SecretManager & manager,
DatabaseInstance & db,
const string & name_p,
const string & secret_path )
301020 : CatalogSetSecretStorage(db_p, name_p, LOCAL_FILE_STORAGE_OFFSET),
301021 secret_path(FileSystem::ExpandPath(secret_path_p, nullptr)) {
301022 persistent = true;
301023
301024 // Check existence of persistent secret dir
301025 LocalFileSystem fs;
301026 if (fs.DirectoryExists(secret_path)) {
301027 fs.ListFiles(secret_path, [&](const string &fname, bool is_dir) {
301028 string full_path = fs.JoinPath(secret_path, fname);
301029
301030 if (StringUtil::EndsWith(full_path, ".duckdb_secret")) {
301031 string secret_name = fname.substr(0, fname.size() - 14); // size of file ext
301032 persistent_secrets.insert(secret_name);
301033 }
301034 });
301035 }
301036
301037 auto &catalog = Catalog::GetSystemCatalog(db);
301038 secrets = make_uniq<CatalogSet>(Catalog::GetSystemCatalog(db),
301039 make_uniq<DefaultSecretGenerator>(catalog, manager, persistent_secrets));
301040}
DatabaseInstance & db
DB instance for accessing the system catalog transaction.
Definition duckdb.cpp:177757
unique_ptr< CatalogSet > secrets
CatalogSet containing the secrets.
Definition duckdb.cpp:177755
static DUCKDB_API Catalog & GetSystemCatalog(ClientContext &context)
Get the SystemCatalog from the ClientContext.
Definition duckdb.cpp:7173
static DUCKDB_API string ExpandPath(const string &path, optional_ptr< FileOpener > opener)
Expands a given path, including e.g. expanding the home directory of the user.
Definition duckdb.cpp:73909
string secret_path
Path that is searched for secrets;.
Definition duckdb.cpp:177785
case_insensitive_set_t persistent_secrets
Set of persistent secrets that are lazily loaded.
Definition duckdb.cpp:177783
bool persistent
Whether entries in this storage will survive duckdb reboots.
Definition duckdb.cpp:177712
static DUCKDB_API bool EndsWith(const string &str, const string &suffix)
Returns true if the target string ends with the given suffix.
Definition duckdb.cpp:109384

Member Function Documentation

◆ WriteSecret()

void duckdb::LocalFileSecretStorage::WriteSecret ( const BaseSecret & secret,
OnCreateConflict on_conflict )
overrideprotectedvirtual

Implements the writes to disk.

Reimplemented from duckdb::CatalogSetSecretStorage.

301073 {
301074 LocalFileSystem fs;
301075
301076 // We may need to create the secret dir here if the directory was not present during LocalFileSecretStorage
301077 // construction
301078 if (!fs.DirectoryExists(secret_path)) {
301079 // TODO: recursive directory creation should probably live in filesystem
301080 auto sep = fs.PathSeparator(secret_path);
301081 auto splits = StringUtil::Split(secret_path, sep);
301082 D_ASSERT(!splits.empty());
301083 string extension_directory_prefix;
301085 extension_directory_prefix = sep; // this is swallowed by Split otherwise
301086 }
301087 try {
301088 for (auto &split : splits) {
301089 extension_directory_prefix = extension_directory_prefix + split + sep;
301090 if (!fs.DirectoryExists(extension_directory_prefix)) {
301091 fs.CreateDirectory(extension_directory_prefix);
301092 }
301093 }
301094 } catch (std::exception &ex) {
301095 ErrorData error(ex);
301096 if (error.Type() == ExceptionType::IO) {
301097 throw IOException("Failed to initialize persistent storage directory. (original error: '%s')",
301098 error.RawMessage());
301099 }
301100 throw;
301101 }
301102 }
301103
301104 string file_path = fs.JoinPath(secret_path, secret.GetName() + ".duckdb_secret");
301105 string temp_path = file_path + ".tmp-" + UUID::ToString(UUID::GenerateRandomUUID());
301106
301107 // If persistent file already exists remove
301108 fs.TryRemoveFile(file_path);
301109 // If temporary file already exists remove
301110 fs.TryRemoveFile(temp_path);
301111
301112 WriteSecretFileToDisk(fs, temp_path, secret);
301113
301114 fs.MoveFile(temp_path, file_path);
301115}
static void ToString(hugeint_t input, char *buf)
Convert a hugeint object to a uuid style string.
Definition duckdb.cpp:130940
static DUCKDB_API vector< string > Split(const string &str, char delimiter)
Split the input string based on newline char.
Definition duckdb.cpp:109734
static DUCKDB_API bool StartsWith(string str, string prefix)
Returns true if the target string starts with the given prefix.
Definition duckdb.cpp:109377
static hugeint_t GenerateRandomUUID(RandomEngine &engine)
Generate a random UUID v4 value.
Definition duckdb.cpp:131021
void split(const Mat &src, Mat *mvbegin)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveSecret()

void duckdb::LocalFileSecretStorage::RemoveSecret ( const string & secret,
OnEntryNotFound on_entry_not_found )
overrideprotectedvirtual

Implements the deletes from disk.

Reimplemented from duckdb::CatalogSetSecretStorage.

301117 {
301118 LocalFileSystem fs;
301119 string file = fs.JoinPath(secret_path, secret + ".duckdb_secret");
301120 persistent_secrets.erase(secret);
301121 try {
301122 fs.RemoveFile(file);
301123 } catch (std::exception &ex) {
301124 ErrorData error(ex);
301125 if (error.Type() == ExceptionType::IO) {
301126 throw IOException("Failed to remove secret file '%s', the file may have been removed by another duckdb "
301127 "instance. (original error: '%s')",
301128 file, error.RawMessage());
301129 }
301130 throw;
301131 }
301132}
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: