Skip to content

Flagless spin up application source #1155

@itowlson

Description

@itowlson

Instead of having to write spin up -f ~/myapp/spin.toml or spin up --from-registry ghcr/me/myapp:v1, the user should be allowed to write:

  • spin up ~/myapp/spin.toml - Spin detects it's a file and runs it
  • spin up ~/myapp - Spin detects that it's a directory and, if it contains a file named spin.toml, runs it
  • spin up ghcr.io/me/myapp:v1 - Spin detects that it's not a file and "looks like" a registry URI, tries to pull the artifact using the OCI protocol, and runs it if successful

The strategy will work like this:

  • If no application source if specified:
    • If the current directory contains a file with the default manifest name, use it
    • Otherwise, display help
  • If an application source string is specified, try to access the string as a file system reference.
    • If it exists and is a file, use it
    • If it exists and is a directory:
      • If it contains a file with the default manifest name, use that
      • Otherwise, fail with a "directory doesn't contain a manifest" error
    • If it doesn't exist, or isn't a legal filename, try to parse it as a registry reference [to do: consider heuristic checks first, TBD]
      • If the parse succeeds, try to pull from the reference (respecting cache etc.)
        • If the pull succeeds, run the artifact. (In future, if there are multiple registry protocols with "similar looking" references, this could be elaborated with e.g. check for well-known servers of different types, fail over to the other type, etc.)
        • If pull fails, fail with a registry error
      • If the parse fails, fail with a "don't understand this source" error

The error messages alone will be glorious.

There should also be a flag that the user can set to force a specific interpretation of the source string e.g. --source-type file, source-type oci. The default will be --source-type auto which tells Spin to use the strategy given above.

As we are aiming to move from Bindle to OCI, this will not support bindle IDs. For the time being, the existing bindle-related flags will remain available to support this scenario.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions