From 94fbac2235ca75f136c35fa0b09bc719e72ef10b Mon Sep 17 00:00:00 2001 From: Yngvar Kristiansen <562343+yngvark@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:50:46 +0200 Subject: [PATCH] Revert "feat: Display packages in ok pkg install --interactive (#278)" This reverts commit de8af27dc1217332511aae3016ad64ed05028238. --- pkg/pkg/install/interactive/interactive.go | 27 +----- test/{terraform => }/config/app-hello.yml | 0 .../config/common-config.yml | 0 test/{terraform => }/config/networking.yml | 0 ...-app-a_test-dev_receive_dispatch_event.yml | 89 ------------------- .../my-app-a-receive_dispatch_event.yml | 5 -- test/github-actions/config/packages.yml | 20 ----- test/{terraform => }/packages.yml | 6 -- test/terraform/config/common-config.yml | 4 - 9 files changed, 2 insertions(+), 149 deletions(-) rename test/{terraform => }/config/app-hello.yml (100%) rename test/{github-actions => }/config/common-config.yml (100%) rename test/{terraform => }/config/networking.yml (100%) delete mode 100644 test/github-actions/_gp_my-app-a_test-dev_receive_dispatch_event.yml delete mode 100644 test/github-actions/config/my-app-a-receive_dispatch_event.yml delete mode 100644 test/github-actions/config/packages.yml rename test/{terraform => }/packages.yml (67%) delete mode 100644 test/terraform/config/common-config.yml diff --git a/pkg/pkg/install/interactive/interactive.go b/pkg/pkg/install/interactive/interactive.go index 5f2ed77..be6641f 100644 --- a/pkg/pkg/install/interactive/interactive.go +++ b/pkg/pkg/install/interactive/interactive.go @@ -7,12 +7,6 @@ import ( "github.com/oslokommune/ok/pkg/pkg/common" ) -const ( - outputFolderWidth = 45 - templateWidth = 40 - varFilesWidth = 80 -) - func SelectPackagesToInstall(pkgManifestFilename string) ([]string, error) { manifest, err := common.LoadPackageManifest(pkgManifestFilename) if err != nil { @@ -21,11 +15,8 @@ func SelectPackagesToInstall(pkgManifestFilename string) ([]string, error) { options := make([]huh.Option[string], 0) - for _, pkg := range manifest.Packages { - displayText := createDisplayText(pkg) - value := pkg.OutputFolder - - options = append(options, huh.NewOption[string](displayText, value)) + for _, p := range manifest.Packages { + options = append(options, huh.NewOption(p.OutputFolder, p.OutputFolder)) } var packages []string @@ -47,17 +38,3 @@ func SelectPackagesToInstall(pkgManifestFilename string) ([]string, error) { return packages, nil } - -func createDisplayText(pkg common.Package) string { - /* - Format specifiers explained: - %-*.*s formats a string with a specified width and precision. - - The first * sets the minimum width, padding with spaces if shorter. - - The second * sets the maximum length, truncating if longer. - */ - outputFolder := fmt.Sprintf("%-*.*s", outputFolderWidth, outputFolderWidth, pkg.OutputFolder) - template := fmt.Sprintf("%-*.*s", templateWidth, templateWidth, pkg.Template) - varFiles := fmt.Sprintf("%-*.*s", varFilesWidth, varFilesWidth, fmt.Sprint(pkg.VarFiles)) - - return fmt.Sprintf("%s %s %s", outputFolder, template, varFiles) -} diff --git a/test/terraform/config/app-hello.yml b/test/config/app-hello.yml similarity index 100% rename from test/terraform/config/app-hello.yml rename to test/config/app-hello.yml diff --git a/test/github-actions/config/common-config.yml b/test/config/common-config.yml similarity index 100% rename from test/github-actions/config/common-config.yml rename to test/config/common-config.yml diff --git a/test/terraform/config/networking.yml b/test/config/networking.yml similarity index 100% rename from test/terraform/config/networking.yml rename to test/config/networking.yml diff --git a/test/github-actions/_gp_my-app-a_test-dev_receive_dispatch_event.yml b/test/github-actions/_gp_my-app-a_test-dev_receive_dispatch_event.yml deleted file mode 100644 index 0cca905..0000000 --- a/test/github-actions/_gp_my-app-a_test-dev_receive_dispatch_event.yml +++ /dev/null @@ -1,89 +0,0 @@ -# DO NOT EDIT: Changes here will be overwritten by Boilerplate; NEVER EDIT MANUALLY -# This file is part of the Golden Path. You can find the exact version in .boilerplate/_template_.json. -name: my-app-a - test-dev - Receive dispatch event and commit image tag 🛬 -run-name: my-app-a - test-dev - Received Docker image update dispatch event 🛬 - -permissions: {} - -on: - repository_dispatch: - types: [test-dev-my-app-a-image-tag-update] - -concurrency: - group: avoid-git-push-conflicts - cancel-in-progress: false - -jobs: - update-app-image-tag: - name: Update image tag and commit to main (or PR) - runs-on: ubuntu-latest - - defaults: - run: - shell: bash - working-directory: stacks/prod/app-my-app-a - - steps: - - - - name: Import okctl-bot GPG key - id: gpg - uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY_FOR_MACHINE_USER }} - passphrase: ${{ secrets.GPG_PASSPHRASE_FOR_MACHINE_USER }} - git_user_signingkey: true - git_commit_gpgsign: true - git_config_global: true - - - name: Checkout - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - with: - token: ${{ secrets.PAT_ON_MACHINE_USER_FOR_IMAGE_UPDATE }} - persist-credentials: true - sparse-checkout-cone-mode: false - sparse-checkout: | - stacks/prod/app-my-app-a/__gp_config_app_image.auto.tfvars.json - show-progress: 'false' - - - - name: Write receive summary - env: - SENDER_REPOSITORY: ${{ github.event.client_payload.sender_repository }} - SENDER_RUN_ID: ${{ github.event.client_payload.sender_run_id }} - SENDER_BEFORE_SHA: ${{ github.event.client_payload.sender_before_sha }} - SENDER_AFTER_SHA: ${{ github.event.client_payload.sender_after_sha }} - run: | - echo "Workflow dispatch event received from [\`${SENDER_REPOSITORY}\`](https://github.com/${SENDER_REPOSITORY}/actions/runs/${SENDER_RUN_ID}) ([compare changes](https://github.com/${SENDER_REPOSITORY}/compare/${SENDER_BEFORE_SHA}..${SENDER_AFTER_SHA}))." >> "$GITHUB_STEP_SUMMARY" - - - - name: Update image tag - env: - IMAGE_TAG: ${{ github.event.client_payload.image_version }} - IMAGE_DIGEST: ${{ github.event.client_payload.image_digest }} - run: | - jq ".main_container_image_tag = \"$IMAGE_TAG\" | .main_container_image_digest = \"$IMAGE_DIGEST\"" __gp_config_app_image.auto.tfvars.json > t.json - mv t.json __gp_config_app_image.auto.tfvars.json - - - name: Commit and push changes - env: - COMMIT_MESSAGE: "feat: Update app my-app-a image tag in test-dev" - IMAGE_METADATA_FILE: __gp_config_app_image.auto.tfvars.json - MAX_ATTEMPTS: 3 - run: | - git add "$IMAGE_METADATA_FILE" - git commit --gpg-sign -m "$COMMIT_MESSAGE" - - for ((attempt=1; attempt<=$MAX_ATTEMPTS; attempt++)); do - echo "Attempt $attempt of $MAX_ATTEMPTS" - if git push; then - echo "Push successful" - exit 0 - else - echo "Push failed. Retrying..." - git pull --rebase - fi - done - - echo "Max attempts reached. Push failed." >&2 - exit 1 diff --git a/test/github-actions/config/my-app-a-receive_dispatch_event.yml b/test/github-actions/config/my-app-a-receive_dispatch_event.yml deleted file mode 100644 index bf5779a..0000000 --- a/test/github-actions/config/my-app-a-receive_dispatch_event.yml +++ /dev/null @@ -1,5 +0,0 @@ -AppName: "my-app-a" -CreatePr: false -GpgSign: true -WorkingDirectory: "stacks/prod/app-{{ .AppName }}" -ImageMetadataFile: "__gp_config_app_image.auto.tfvars.json" diff --git a/test/github-actions/config/packages.yml b/test/github-actions/config/packages.yml deleted file mode 100644 index 2564d73..0000000 --- a/test/github-actions/config/packages.yml +++ /dev/null @@ -1,20 +0,0 @@ -DefaultPackagePathPrefix: boilerplate/github-actions -Packages: - - OutputFolder: .. - Template: receive-dispatch-event - Ref: receive-dispatch-event-v0.3.3 - VarFiles: - - my-app-a-receive_dispatch_event.yml - - common-config.yml - - OutputFolder: .. - Template: receive-dispatch-event - Ref: receive-dispatch-event-v0.3.3 - VarFiles: - - my-app-b-receive_dispatch_event.yml - - common-config.yml - - OutputFolder: .. - Template: terraform-on-changed-dirs - Ref: terraform-on-changed-dirs-v2.2.0 - VarFiles: - - common-config.yml - - terraform-on-changed-dirs.yml diff --git a/test/terraform/packages.yml b/test/packages.yml similarity index 67% rename from test/terraform/packages.yml rename to test/packages.yml index 9994c4f..312c43b 100644 --- a/test/terraform/packages.yml +++ b/test/packages.yml @@ -11,9 +11,3 @@ Packages: VarFiles: - "config/common-config.yml" - "config/networking.yml" - - Template: "networking" - Ref: "main" - OutputFolder: "out/networking2" - VarFiles: - - "config/common-config.yml" - - "config/networking.yml" diff --git a/test/terraform/config/common-config.yml b/test/terraform/config/common-config.yml deleted file mode 100644 index db041a1..0000000 --- a/test/terraform/config/common-config.yml +++ /dev/null @@ -1,4 +0,0 @@ -AccountId: "123456789012" -Region: "eu-west-1" -Team: "kjoremiljo" -Environment: "test-dev"