portainer_host: make init methods private

This commit is contained in:
tylen 2025-03-04 20:38:57 +00:00
parent e0bb16f113
commit 99040eccb2

View File

@ -24,11 +24,11 @@ class PortainerHost(BaseCLi):
home_directory = os.path.expanduser("~")
config_file_path = os.path.join(home_directory, DEFAULT_PORTAINER_JWT_CONFIG_FILE)
try:
self.read_current_config(config_file_path)
self.__read_current_config(config_file_path)
except EmptyConfigException:
self.create_config(config_file_path)
self.__create_config(config_file_path)
def read_current_config(self, file_path):
def __read_current_config(self, file_path):
try:
with open(file_path, 'r') as file:
self.jwt_config = json.load(file)
@ -41,16 +41,16 @@ class PortainerHost(BaseCLi):
if self.host_url not in hostnames:
raise EmptyConfigException()
def create_config(self, file_path):
def __create_config(self, file_path):
config = {
"hostname": self.host_url,
"jwt": self.get_jwt_token(),
"jwt": self.__get_jwt_token(),
}
self.jwt_config.append(config)
with open(file_path, 'w') as file:
json.dump(self.jwt_config, file, indent=4)
def get_jwt_token(self):
def __get_jwt_token(self):
def get_env(env_key):
try:
return os.environ[env_key]