Merge pull request 'vars,facts: update_check -> needs_upload' (#2383) from DavHau/clan-core:DavHau-dave into main
This commit is contained in:
@@ -25,8 +25,8 @@ class SecretStoreBase(ABC):
|
||||
def exists(self, service: str, name: str) -> bool:
|
||||
pass
|
||||
|
||||
def update_check(self) -> bool:
|
||||
return False
|
||||
def needs_upload(self) -> bool:
|
||||
return True
|
||||
|
||||
@abstractmethod
|
||||
def upload(self, output_dir: Path) -> None:
|
||||
|
||||
@@ -92,7 +92,7 @@ class SecretStore(SecretStoreBase):
|
||||
return b"\n".join(hashes)
|
||||
|
||||
@override
|
||||
def update_check(self) -> bool:
|
||||
def needs_upload(self) -> bool:
|
||||
local_hash = self.generate_hash()
|
||||
remote_hash = self.machine.target_host.run(
|
||||
# TODO get the path to the secrets from the machine
|
||||
@@ -103,9 +103,9 @@ class SecretStore(SecretStoreBase):
|
||||
|
||||
if not remote_hash:
|
||||
print("remote hash is empty")
|
||||
return False
|
||||
return True
|
||||
|
||||
return local_hash.decode() == remote_hash
|
||||
return local_hash.decode() != remote_hash
|
||||
|
||||
def upload(self, output_dir: Path) -> None:
|
||||
os.umask(0o077)
|
||||
|
||||
@@ -16,8 +16,8 @@ def upload_secrets(machine: Machine) -> None:
|
||||
secret_facts_module = importlib.import_module(machine.secret_facts_module)
|
||||
secret_facts_store = secret_facts_module.SecretStore(machine=machine)
|
||||
|
||||
if secret_facts_store.update_check():
|
||||
log.info("Secrets already up to date")
|
||||
if not secret_facts_store.needs_upload():
|
||||
log.info("Secrets already uploaded")
|
||||
return
|
||||
with TemporaryDirectory(prefix="facts-upload-") as tempdir:
|
||||
secret_facts_store.upload(Path(tempdir))
|
||||
|
||||
@@ -9,8 +9,8 @@ class SecretStoreBase(StoreBase):
|
||||
def is_secret_store(self) -> bool:
|
||||
return True
|
||||
|
||||
def update_check(self) -> bool:
|
||||
return False
|
||||
def needs_upload(self) -> bool:
|
||||
return True
|
||||
|
||||
@abstractmethod
|
||||
def upload(self, output_dir: Path) -> None:
|
||||
|
||||
@@ -124,7 +124,7 @@ class SecretStore(SecretStoreBase):
|
||||
return b"\n".join(hashes)
|
||||
|
||||
@override
|
||||
def update_check(self) -> bool:
|
||||
def needs_upload(self) -> bool:
|
||||
local_hash = self.generate_hash()
|
||||
remote_hash = self.machine.target_host.run(
|
||||
# TODO get the path to the secrets from the machine
|
||||
@@ -135,9 +135,9 @@ class SecretStore(SecretStoreBase):
|
||||
|
||||
if not remote_hash:
|
||||
print("remote hash is empty")
|
||||
return False
|
||||
return True
|
||||
|
||||
return local_hash.decode() == remote_hash
|
||||
return local_hash.decode() != remote_hash
|
||||
|
||||
def upload(self, output_dir: Path) -> None:
|
||||
for secret_var in self.get_all():
|
||||
|
||||
@@ -16,8 +16,8 @@ def upload_secrets(machine: Machine) -> None:
|
||||
secret_store_module = importlib.import_module(machine.secret_facts_module)
|
||||
secret_store = secret_store_module.SecretStore(machine=machine)
|
||||
|
||||
if secret_store.update_check():
|
||||
log.info("Secrets already up to date")
|
||||
if not secret_store.needs_upload():
|
||||
log.info("Secrets already uploaded")
|
||||
return
|
||||
with TemporaryDirectory(prefix="vars-upload-") as tempdir:
|
||||
secret_store.upload(Path(tempdir))
|
||||
|
||||
Reference in New Issue
Block a user