porter icon indicating copy to clipboard operation
porter copied to clipboard

Porter install missing `--no-lint` flag

Open VinozzZ opened this issue 3 years ago • 3 comments

Describe the bug

When I was testing out a bundle that contains bash script directly in porter.yaml, I ran into a lint error like below. However, when I try to run porter install --no-lint, I got unknown flag: --no-lint error. It looks like only porter build supports --no-lint flag.

Building bundle ===>
result:  warning(exec-100) - Best Practice: Avoid Embedded Bash
install: 1st step in the exec mixin (Install Hello World)
See https://porter.sh/best-practices/exec-mixin/#use-scripts for more information
---
error(exec-101) - bash -c argument missing wrapping quotes
install: 1st step in the exec mixin (Install Hello World)
The bash -c flag argument must be wrapped in quotes, for example
exec:
  description: Say Hello
  command: bash
  flags:
    c: '"echo Hello World"'

See https://porter.sh/best-practices/exec-mixin/#quoting-escaping-bash-and-yaml for more information
---

Lint errors were detected. Rerun with --no-lint ignore the errors.
Lint errors were detected. Rerun with --no-lint ignore the errors.

To Reproduce

Steps to reproduce the behavior:

  1. Run porter install with below porter.yaml
schemaVersion: 1.0.0-alpha.1
name: examples/porter-hello
version: 0.2.0
description: "An example Porter configuration"
registry: ghcr.io/vinozzz

parameters:
  - name: name
    type: string
    default: porter
    value: test

outputs:
  - name: name
    path: /cnab/app/foo/name.txt

mixins:
  - exec

install:
  - exec:
      description: "Install Hello World"
      command: bash
      flags:
        c: 'echo "{{ bundle.parameters.name }}"'


upgrade:
  - exec:
      description: "World 2.0"

uninstall:
  - exec:
      description: "Uninstall Hello World"
  1. Run porter install --no-lint as the error message suggested
  2. See error unknown flag: --no-lint

Expected behavior

The porter install --no-lint should run successfully if the bundle only contains lint error

Version

porter v1.0.0-alpha.22-5-gf6ab3d1d (f6ab3d1d)

VinozzZ avatar Jun 20 '22 17:06 VinozzZ

Yeah, we intentionally don't expose all build flags to the install/upgrade/invoke/uninstall commands. If someone has a wonky build setup, they shouldn't rely on autobuild. Same for publish.

carolynvs avatar Jun 20 '22 18:06 carolynvs

Yeah, we intentionally don't expose all build flags to the install/upgrade/invoke/uninstall commands. If someone has a wonky build setup, they shouldn't rely on autobuild. Same for publish.

Ohhh, right, cool. Maybe then it would be great for the error message to suggest that. I think right now it's a bit misleading that the error suggests users to run with "--no-lint" when the command doesn't support such flag

VinozzZ avatar Jun 20 '22 19:06 VinozzZ

Yeah if we want to do that, the ensureLocalBundleIsUpToDate function would be a good place to check for well-known errors like that and then alter the message to tell people to run build with the appropriate flags.

carolynvs avatar Jun 20 '22 19:06 carolynvs