From ccdb6f5425c6418ad6e6aa12dc32f5d728680b88 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Jan 07 2024 20:43:05 +0000 Subject: get_formulas: remove broken branch logic This seemed like an unfinished implementation, the argument did nothing, always the default branch got cloned. Hence removing all related code from the application and removing all uses of the argument throughout the repository. Signed-off-by: Georg Pfuetzenreuter --- diff --git a/.gitlab-ci.templates/test_highstate.jinja b/.gitlab-ci.templates/test_highstate.jinja index b5f0a28..26a0b9b 100644 --- a/.gitlab-ci.templates/test_highstate.jinja +++ b/.gitlab-ci.templates/test_highstate.jinja @@ -3,7 +3,7 @@ stage: test before_script: - bin/prepare_test_env.sh -g -o Leap,15,5 -s -n - - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production + - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' tags: - docker artifacts: diff --git a/.gitlab-ci.templates/test_nginx.jinja b/.gitlab-ci.templates/test_nginx.jinja index ef51849..86498fc 100644 --- a/.gitlab-ci.templates/test_nginx.jinja +++ b/.gitlab-ci.templates/test_nginx.jinja @@ -3,7 +3,7 @@ stage: test before_script: - bin/prepare_test_env.sh -g -s - - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production -f nginx + - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' -f nginx script: bin/test_nginx.sh tags: - docker diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 05540e2..b5974c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ show_highstate: - .test_artifacts before_script: - bin/prepare_test_env.sh -g -o Leap,15,4 -s - - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production + - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' script: bin/test_show_highstate.sh test_haproxy: @@ -40,7 +40,7 @@ test_haproxy: before_script: - bin/prepare_test_env.sh -g -s -n - bin/replace_secrets.sh - - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production -f haproxy + - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' -f haproxy script: bin/test_haproxy.sh # changes: # - bin/test_haproxy.sh diff --git a/bin/get_formulas.py b/bin/get_formulas.py index 38a5457..d8bed48 100755 --- a/bin/get_formulas.py +++ b/bin/get_formulas.py @@ -38,7 +38,7 @@ def git(cmd, cwd=None): sys.exit(status) -def clone(CLONE_FROM, CLONE_BRANCH, DEST): +def clone(CLONE_FROM, DEST): def clone_repo(): FULL_PATH = f'{DEST}/{formula}-formula' if os.path.isdir(FULL_PATH): @@ -46,8 +46,6 @@ def clone(CLONE_FROM, CLONE_BRANCH, DEST): pygit2.clone_repository(url, FULL_PATH, bare=False) - if CLONE_BRANCH: - pass if CLONE_FROM: for formula in FORMULAS.keys(): url = f'{CLONE_FROM}/{formula}-formula' @@ -160,7 +158,6 @@ parser.add_argument('-d', '--destination', nargs=1, help='Destination absolute p parser.add_argument('-f', '--formulas', action='append', nargs='+', help='Specify specific formulas to operate on, instead of working with all the specified FORMULAS.yaml formulas.') parser.add_argument('-c', '--clone', action='store_true', help='Clone the formulas to the destination specified with "--destination".') parser.add_argument('--clone-from', nargs=1, help='Specify the git provider to clone from together with the namespace.') -parser.add_argument('--clone-branch', nargs=1, help='Specify the branch to clone.') parser.add_argument('-s', '--symlink', action='store_true', help='Creates symlink from the specified destination to /srv/salt.') parser.add_argument('--remove-symlinks', action='store_true', help='Removes all symlinks that were created in /srv/salt.') parser.add_argument('-r', '--add-remote', action='append', nargs='+', help='''Add the specified remotes on the local repositories. It can be passed multiple times. @@ -190,7 +187,7 @@ if args.remove_symlinks: remove_symlinks() # Every option below requires the --destination argument to be set -if args.clone or args.symlink or args.clone_from or args.clone_branch or args.add_remote or isinstance(args.update, list) or args.push or args.checkout: +if args.clone or args.symlink or args.clone_from or args.add_remote or isinstance(args.update, list) or args.push or args.checkout: will_run = True if args.formulas: @@ -211,8 +208,8 @@ if args.clone or args.symlink or args.clone_from or args.clone_branch or args.ad print("ERROR: The following given formulas are not in FORMULAS.yaml: %s\n" % ', '.join(unknown_formulas), file=sys.stderr) sys.exit(1) - if (args.clone_from or args.clone_branch) and not args.clone: - print('ERROR: Please specify -c / --clone when using --clone-from or --clone-branch', file=sys.stderr) + if args.clone_from and not args.clone: + print('ERROR: Please specify -c / --clone when using --clone-from', file=sys.stderr) sys.exit(1) if not args.destination or not os.path.isabs(args.destination[0]): @@ -227,12 +224,9 @@ if args.clone or args.symlink or args.clone_from or args.clone_branch or args.ad if args.clone: clone_from = None - clone_branch = None if args.clone_from: clone_from = args.clone_from[0] - if args.clone_branch: - clone_branch = args.clone_branch[0] - clone(clone_from, clone_branch, args.destination[0]) + clone(clone_from, args.destination[0]) if args.symlink: create_symlinks(args.destination[0]) diff --git a/bin/run_tests_locally.sh b/bin/run_tests_locally.sh index d4246a0..d3cf21e 100755 --- a/bin/run_tests_locally.sh +++ b/bin/run_tests_locally.sh @@ -139,7 +139,7 @@ $SSH sh <<-EOS || echo 'Test suite returned with errors.' sudo sed -i 's/download-prg.infra.opensuse.org/download.opensuse.org/' /etc/zypp/repos.d/* pprint 'Preparing formulas' - bin/get_formulas.py -c -d /srv/salt-formulas -s --clone-from https://gitlab.infra.opensuse.org/saltstack-formulas --clone-branch production || pfail + bin/get_formulas.py -c -d /srv/salt-formulas -s --clone-from https://gitlab.infra.opensuse.org/saltstack-formulas || pfail pprint Testing: validate bin/test_validate.sh || pfail diff --git a/t/lib/Dockerfile.systemd b/t/lib/Dockerfile.systemd index e7314e7..ea3e259 100644 --- a/t/lib/Dockerfile.systemd +++ b/t/lib/Dockerfile.systemd @@ -21,7 +21,7 @@ RUN mkdir -p /srv/salt/ && \ ADD bin /test/bin ADD pillar /test/pillar WORKDIR /test -RUN bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production || bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production +RUN bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' || bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' RUN ( echo $'file_roots:\n\ base:\n\ - /srv/salt\n\