portainer_host: make init methods private
This commit is contained in:
parent
e0bb16f113
commit
99040eccb2
@ -24,11 +24,11 @@ class PortainerHost(BaseCLi):
|
|||||||
home_directory = os.path.expanduser("~")
|
home_directory = os.path.expanduser("~")
|
||||||
config_file_path = os.path.join(home_directory, DEFAULT_PORTAINER_JWT_CONFIG_FILE)
|
config_file_path = os.path.join(home_directory, DEFAULT_PORTAINER_JWT_CONFIG_FILE)
|
||||||
try:
|
try:
|
||||||
self.read_current_config(config_file_path)
|
self.__read_current_config(config_file_path)
|
||||||
except EmptyConfigException:
|
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:
|
try:
|
||||||
with open(file_path, 'r') as file:
|
with open(file_path, 'r') as file:
|
||||||
self.jwt_config = json.load(file)
|
self.jwt_config = json.load(file)
|
||||||
@ -41,16 +41,16 @@ class PortainerHost(BaseCLi):
|
|||||||
if self.host_url not in hostnames:
|
if self.host_url not in hostnames:
|
||||||
raise EmptyConfigException()
|
raise EmptyConfigException()
|
||||||
|
|
||||||
def create_config(self, file_path):
|
def __create_config(self, file_path):
|
||||||
config = {
|
config = {
|
||||||
"hostname": self.host_url,
|
"hostname": self.host_url,
|
||||||
"jwt": self.get_jwt_token(),
|
"jwt": self.__get_jwt_token(),
|
||||||
}
|
}
|
||||||
self.jwt_config.append(config)
|
self.jwt_config.append(config)
|
||||||
with open(file_path, 'w') as file:
|
with open(file_path, 'w') as file:
|
||||||
json.dump(self.jwt_config, file, indent=4)
|
json.dump(self.jwt_config, file, indent=4)
|
||||||
|
|
||||||
def get_jwt_token(self):
|
def __get_jwt_token(self):
|
||||||
def get_env(env_key):
|
def get_env(env_key):
|
||||||
try:
|
try:
|
||||||
return os.environ[env_key]
|
return os.environ[env_key]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user