Merge pull request #196 from cerc-io/dboreham/fix-project-name

Make cluster/docker-compose project name unique
This commit is contained in:
David Boreham 2023-02-28 08:47:52 -07:00 committed by GitHub
commit 4353418fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -151,10 +151,13 @@ def _make_cluster_context(ctx, include, exclude, cluster):
compose_dir = Path(__file__).absolute().parent.joinpath("data", "compose") compose_dir = Path(__file__).absolute().parent.joinpath("data", "compose")
if cluster is None: if cluster is None:
# Create default unique, stable cluster name from confile file path # Create default unique, stable cluster name from confile file path and stack name if provided
# TODO: change this to the config file path # TODO: change this to the config file path
path = os.path.realpath(sys.argv[0]) path = os.path.realpath(sys.argv[0])
hash = hashlib.md5(path.encode()).hexdigest() unique_cluster_descriptor = f"{path},{ctx.stack},{include},{exclude}"
if ctx.debug:
print(f"pre-hash descriptor: {unique_cluster_descriptor}")
hash = hashlib.md5(unique_cluster_descriptor.encode()).hexdigest()
cluster = f"laconic-{hash}" cluster = f"laconic-{hash}"
if ctx.verbose: if ctx.verbose:
print(f"Using cluster name: {cluster}") print(f"Using cluster name: {cluster}")

1
cli.py
View File

@ -55,5 +55,6 @@ def cli(ctx, stack, quiet, verbose, dry_run, local_stack, debug, continue_on_err
cli.add_command(setup_repositories.command, "setup-repositories") cli.add_command(setup_repositories.command, "setup-repositories")
cli.add_command(build_containers.command, "build-containers") cli.add_command(build_containers.command, "build-containers")
cli.add_command(build_npms.command, "build-npms") cli.add_command(build_npms.command, "build-npms")
cli.add_command(deploy_system.command, "deploy") # deploy is an alias for deploy-system
cli.add_command(deploy_system.command, "deploy-system") cli.add_command(deploy_system.command, "deploy-system")
cli.add_command(version.command, "version") cli.add_command(version.command, "version")