* update root and version structure and help text
* fix: limit openshift int test with tag
* refactor: commands to use simplifed, unified constructor
* fix ineffectual assignment lint error
* cleanup
* add repository to run command
* callout for forthcoming s2i builder impl
* lint errors
* re-add the deferred client factory
* remove setNamespaceFlag now that it is persistent
* avoid side-effect of global-mutating deploy tests
* reduce line-by-line difference for PR ease
* simplificaiton of tests and comment lines for further PR ease purposes
* reduce inconsequential differences for ease of PR
* tests to RootCommandConfig
* review comment updates
* fix lint errors
* replace stdlib Setenv in tests
Using t.Setenv will require an update to go1.17, which is out of scope
for this PR.
* pass ClientFactory throughout
* explicitly empty test command args
See https://github.com/spf13/cobra/pull/155
Errors can still be encountered when, for example, using precomiled
tests. Explicitly setting constructed command args to the empty slice
ensures we avoid hitting any futher edge cases.
* update root and version structure and help text
* fix: limit openshift int test with tag
* src: verbosity to constructor param
* fix misspelling
* fix merge error
* src: refactor commands
Commands are constructed from root,
not by using init() blocks.
Signed-off-by: Matej Vasek <mvasek@redhat.com>
* fixup the prefix issue
Signed-off-by: Matej Vasek <mvasek@redhat.com>
* fixup style
Signed-off-by: Matej Vasek <mvasek@redhat.com>
* fixup nolint:misspell
Signed-off-by: Matej Vasek <mvasek@redhat.com>
* feat!: rename 'emit' to 'invoke' and default to local
This commit renames 'func emit' command to 'func invoke' and makes the
default behavior to send an event to localhost. The special '--sink'
value 'local' is changed to 'cluster' to indicate that the function
should be invoked on the cluster instead of locally. All other behavior
has remained the same.
BREAKING CHANGE
Signed-off-by: Lance Ball <lball@redhat.com>
* fixup: update commands.md doc
Signed-off-by: Lance Ball <lball@redhat.com>
* squash: change Emitter interface to Invoker
Changes Emit() to Send() in the (now named) Invoker interface, and changes
Emit() to Invoke() in the client.
BREAKING CHANGE
Signed-off-by: Lance Ball <lball@redhat.com>
* squash: use a common Invoker interface for HTTP and events
Signed-off-by: Lance Ball <lball@redhat.com>
* checkpoint
Signed-off-by: Lance Ball <lball@redhat.com>
* fixup: change Emitter to EventInvoker
Signed-off-by: Lance Ball <lball@redhat.com>
* Invoke v2 Draft
* feat: client invoke function
* static invoke defaults and methods
* remove assimilated invoker package
* includes an ignored .func directory on create
* Instances manager with local and remote defaults
Funciton Info is now Instance, representing a Function in a given
environment.
Describing a Function instance is now Instances().Get(f, environment)
Moves Runner to be async with a Stop method to enable returning runtime pid
and port for persisting.
Instances now have a place for primary Route in addition to all routes slice
Running Functions write PID and Port to .func
* cascading targets: local vs remote vs ad-hoc endpoint
* runner start signals and cancel cleanup
* return run on context done or err on channel
* async runner
Refactors the image runner to start the container asynchronously,
reporting back the port on which it started. Errors are communicated
back via a provided channel and stop is signaled using context
cancelation.
* pid neither required nor available
* add withTransport option
Incorporates addition of custom transport of the emitter into the
renamed version invoker. Flag and help text cleanup. Re-additionof the
Info accessor.
* schema now includes invocation data
* loop build msg
* run jobs
Externally exposed port is now chosen based on availability, with 8080
preferred and falling back to an os-chosen open port.
The Client Run method is now async, returning the port assigned to the
running Function, a stop/cleanup function and a runtime errors channel.
The Runner is internally divided into the runner and its started Jobs.
* job metadata
Extracts job metadata tracking to a Job object in the core,
Handles multiple instances of the same Function by creating a single
file for each instances in .func/instances/<port>
* remove superfluous error types and flag bindings
* feat: enable invoke target remote
* feat: preferentially invoke local, remote if running
* feat: read --file for invoke
* feat: invoke confirm prompts
* fixup cli tests
- Updates to handle asynchronous Runner
- Standardize on the naming convention for selective running
* docker runner tests and lint errors
* test refactor
* feat: invoke format override
* comments, spelling and other cleanup
* invoke command doc
* feat: invoke format interactive option
* rename runjob.go to job.go
* e2e test flag update
* test naming homoginization
* silence build activity messages when verbose
* test debugging
* code review updates
- return Job from Client.Run rather than constituent members
- Treat .gitignore as contentious, punting on feature to mutate if
extant.
- docs wording changes
- add invocation format to pertinent manifest.yaml files
* help text spelling etc.
Co-authored-by: Lance Ball <lball@redhat.com>
These flags are used by multiple commands, and explicitly setting them for
each command risks errors that may not be easily detected (see the deleted
flag text for `namespace` in deploy.go). The downside to this is that wording
is not sligtly tweaked for the command - see again some of the removed text
for `namespace` that was slightly different for each command, but usefully so.
I'm not 100% convinced this change is needed, since it does reduce the flexibility
of the user facing text. But if it had existed before we wouldn't have had
incorrect text for `deploy`.
Fixes: https://github.com/knative-sandbox/kn-plugin-func/issues/221
Signed-off-by: Lance Ball <lball@redhat.com>
* add flag to push image at the end of a successful build
* ensure that push flag is binded to viper
* add unit test to build command
* change build test name
* add registry to build test
* fix e2e test problem
* fix compile error
* add push fail test case
* avoid pusher instanciation in absence of push flag
* feat: create cli prompts
* feat: display effective runtimes in prompt
replaces the static list of supported runtimes with a dynamic list of
currently installed+available runtimes; called the effective runtimes.
Used for both prompting and validation.
* feat: dynamic create help and error text
Output from create help text and the create commands now show valid
options for both language runtimes and templates.
* feat: runtime tab completion for runtmes and templates
* feat: support FUNC_PARENT_COMMAND in help
* feat: confirmation of successful create
* fix: include name in initial creation
* src: remove unnecessary comments on create name
* fix: associate prompt questions with struct members in create
* e2e: update tests for language flag
* fix: support nonexistent repositories path
Listing installed repositories considers a missing path equivalent to a
lack of installed repositories. This will change to an error when the
logic to determin default config directory, and automatically create
initial structure, is moved into the client library.
* fix: only CLI-validate when no repo override
* example message changes between standalone and plugin
Signed-off-by: Fabian Lopez <lfabian@vmware.com>
* make template name a parameter in replaceNameInTemplate
Signed-off-by: Fabian Lopez <lfabian@vmware.com>
* use ExecuteTemplate error
Signed-off-by: Fabian Lopez <lfabian@vmware.com>
* feat: add support for labels in func.yaml and `func config`
This change adds support for setting labels on deployed functions. It uses
the interactive CLI prompt introduced by Zbynek to add, remove and list
labels applied on a deployed function.
Signed-off-by: Lance Ball <lball@redhat.com>
* fixup: fix string output for Pair type
Signed-off-by: Lance Ball <lball@redhat.com>
* fixup: review feedback
Signed-off-by: Lance Ball <lball@redhat.com>
This commit modifies the progress meter so that, by default there is no
step counter. It also modifies the responsibility for calling `Done()`,
making it the job of the command rather than the client. This is because
the client does not know how many commands will be executed and therefore
cannot know when the progress bar is done.
This commit also adds String() to the progress bar, and moves logging
responsibility out of the deployer itself and fully into the client.
Deployer#Deploy() now returns a DeploymentResult.
Fixes: https://github.com/boson-project/func/issues/296
Signed-off-by: Lance Ball <lball@redhat.com>
There are some places where I've changed variable and function names
where it wasn't strictly necessary. If you don't mind the bit of churn
that results, changing these makes `rg -i envvars` a nice way to check
for anything that could be overlooked.
Signed-off-by: Lance Ball <lball@redhat.com>
* chore: Update help messages and adding examples.
This commit introduces fixes for the top-level help message as described in #187.
It does not address:
* #216 - Use `kn function` in help message when run as a plugin to kn
* #215 - Group main help message to put important commands to the top
* #214 - Make examples in usage message parameterizable
When dealing with images, instead of referring to an image repository,
let's instead use the more correct term "registry", even though we're
actually using "registry/namespace" in most case.
Signed-off-by: Lance Ball <lball@redhat.com>
* fix: correct value for config path and robustify
The hardcoded, initial value for the configuration path was set to
`.faas/config`. But `configPath()` immediately sets this to the correct
value of ~/.config. Both the create and init commands use `configPath()`
to search for additional templates, if they exist, and were each doing
`filepath.Join(configPath(), "faas", "templates")`. This commit also
changes `configPath()` so that it is `~/.config/faas` and does so in a
cross platform friendly way. If the `$HOME` directory cannot be
determined, the config is assumed to be at `./.config/faas`.
* squash: remove config variable entirely
The CLI commands all printed confirmation prompts for the various flags
they exposed. This commit modifies that logic, so that there is no longer
a `-y` flag, but instead a `--confirm` or `-c` flag for each command, and
prompts are only displayed if using this flag. In most cases, the derived
values are printed even if not prompted for.
In call cases where the user is prompted, I have removed the "Verbose"
prompt, as that seems less like a configuration option that needs to be
confirmed, and more like just a CLI option for the current run which we
can just accept as-is.
The text for the prompts has also been reduced to one or two words.
Also added are some checks around image naming and repositories, short
circuiting failures that could occur if these are not specified or are
unknown. For example, if a user does `faas init` and then `faas deploy`
we don't yet know what the image name should be - one hasn't been built.
Fixes: https://github.com/boson-project/faas/issues/91
Fixes: https://github.com/boson-project/faas/issues/90
Fixes: https://github.com/boson-project/faas/issues/89
- Replaces globally-scoped formatter function with methods
- Defines enumerated Format types
- Renames the 'output' flag 'format' due to confusion with command file descriptors
- FunctionDescription now Function
- Global verbose flag replaced with config struct based value throughout