diff --git a/script/generate-vault-secret b/script/generate-vault-secret index 28278ce..2c4340e 100755 --- a/script/generate-vault-secret +++ b/script/generate-vault-secret @@ -26,7 +26,7 @@ class Vault: def create_vault_secret (self,secret: VaultSecret) -> None: resp=requests.post( - url= f'{self.URL}/v1/secrets/data/{secret.path}', + url= f'{self.URL}v1/secrets/data/{secret.path}', headers={ 'X-Vault-Token': self.token }, @@ -34,16 +34,32 @@ class Vault: "options": {"cas": 0} }) ) - print(resp.content) + print(resp.url) + if resp.status_code == 200: + print(f"Create {secret.path} done") + else: + print(resp.status_code) + print(resp.content) def main() -> None: - secretList=[] - secretList.append(VaultSecret("nomad/ldap",{"admin":""})) + + listSecret={ + "nomad/ldap":{ + "admin":"" + }, + "nomad/gitea":{ + "internal_token":"", + "jwt_secret":"", + "secret_key":"" + } + } + token=os.getenv('VAULT_TOKEN',"") vault_addr=os.getenv('VAULT_ADDR',"") vault=Vault(vault_addr,token) - for secret in secretList: + for k,v in listSecret.items(): + secret=VaultSecret(k,v) vault.create_vault_secret(secret) if __name__ == '__main__':