/nuvolaris-cli

Primary LanguageGoApache License 2.0Apache-2.0

Nuvolaris CLI

This repo discuss the Command Line Interface to Nuvolaris.

You can discuss it in the #nuvolaris-cli discord channel and in the forum under the category CLI.

Design

NOTE This design is work in progress and incomplete - feel free to propose improvements but please document the feature and send a PR to this design BEFORE implementing the feature to avoid rejections and time wasted.

Goals

The tool nuv built in the repo nuvolaris-cli it the Command Line interface for the Nuvolaris project.

It embeds the functionalities of the tool wsk for creating actions. As wsk is written in Go, we can directly include the code in nuv

It embeds the functionalities of the tool task for execution actions. As task is written in Go, we can directly include the code in nuv

It also adds some project conventions inspired by the nim tool. But since nim is written in typescript we do not include that code, we will reimplement them. Most notably we want to reimplement the project detection euristic described below and nothing else.

The toll works scanning the current subtree, looking for actions and packages to deploy. It works generating a Taskfile (that can be inspected by the users) and then executing it.

It will be possible to add customizations of the task adding locally some nuvolaris.yml in the various subdirectories. This functionality will be described later.

There will be initially 4 commands:

  • nuv scan scans the folder and generate a Taskfile
  • nuv wsk executes the wsk subcommand
  • nuv task execute the task subcommand
  • nuv install will also be able to execute a kubectl command that deploys the nuvolaris-operator that in turns inizialize openwhisk in any available kubernetes accessible with kubectl and initialize the .wskprops file used by nuv wsk

The expected workflow is that :

  1. nuv install installs an openwhisk cluster using a configured kubectl in the path
  2. nuv scan generates a Taskfile
  3. nuv task executes the Taskfile that embeds many nuv wsk commands
  4. the various nuv wsk create then a full project

An example of a project to deploy can be this

Project Detection

nuv will scan the current directory looking for a folder named packages

If it finds here a file it will create a package for each subfolder.

If it finds files in the file packages it will deploy them as single file actions in the package default. If it finds files in the subfolders of packages it will deploy them as single file actions in packages named as the the subfolder. If it finds folders it will build multi file actions.

Single File Actions

A single file actions is simply a file with an extension.

This extension can be one of the supported ones: .js .py .go .java

This will cause the creation of an action with --kind nodejs:default, --kind python:default, --kind go:default and --kind java:default using the correct runtime.

The correct runtime is described by runtime.json that can be downloaded from the api host configured.

If the extension is in format: .<version>.<extension> it will deploy an action of --kind <language>:<version>

Multi File Actions

initial draft

A multi file action is stored in a subfolder of a subfolder of packages.

This is expected to be a file to build

nuv implements some heuristics to decide the correct type of the file to build.

Currently:

  • if there is a package.json or any js field in the folder then it is .js and it builds with npm install ; npm build
  • if there is a requirements.txt or any .py file then it is a python and it builds creating a virtual env as described in the python runtime documentation
  • if there is pom.xml then it builds using mvn install
  • if there is a go.mod then it builds using go build

then it will zip the folder and send as an action of the current type to the runtime.