AWSProfileConfigLoaderBase.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. * SPDX-License-Identifier: Apache-2.0.
  4. */
  5. #include <aws/core/config/AWSProfileConfigLoaderBase.h>
  6. #include <aws/core/utils/logging/LogMacros.h>
  7. #include <fstream>
  8. namespace Aws
  9. {
  10. namespace Config
  11. {
  12. using namespace Aws::Utils;
  13. using namespace Aws::Auth;
  14. static const char* const CONFIG_LOADER_BASE_TAG = "Aws::Config::AWSProfileConfigLoaderBase";
  15. bool AWSProfileConfigLoader::Load()
  16. {
  17. if(LoadInternal())
  18. {
  19. AWS_LOGSTREAM_INFO(CONFIG_LOADER_BASE_TAG, "Successfully reloaded configuration.");
  20. m_lastLoadTime = DateTime::Now();
  21. AWS_LOGSTREAM_TRACE(CONFIG_LOADER_BASE_TAG, "reloaded config at "
  22. << m_lastLoadTime.ToGmtString(DateFormat::ISO_8601));
  23. return true;
  24. }
  25. AWS_LOGSTREAM_INFO(CONFIG_LOADER_BASE_TAG, "Failed to reload configuration.");
  26. return false;
  27. }
  28. bool AWSProfileConfigLoader::PersistProfiles(const Aws::Map<Aws::String, Profile>& profiles)
  29. {
  30. if(PersistInternal(profiles))
  31. {
  32. AWS_LOGSTREAM_INFO(CONFIG_LOADER_BASE_TAG, "Successfully persisted configuration.");
  33. m_profiles = profiles;
  34. m_lastLoadTime = DateTime::Now();
  35. AWS_LOGSTREAM_TRACE(CONFIG_LOADER_BASE_TAG, "persisted config at "
  36. << m_lastLoadTime.ToGmtString(DateFormat::ISO_8601));
  37. return true;
  38. }
  39. AWS_LOGSTREAM_WARN(CONFIG_LOADER_BASE_TAG, "Failed to persist configuration.");
  40. return false;
  41. }
  42. } // Config namespace
  43. } // Aws namespace