Commit Graph

62 Commits

Author SHA1 Message Date
Luke Kingland a91bcc5fcf
feat: s2i builder with preliminary node support (#923)
* fix: stuck build ticker

* feat: s2i builder prototype

* default builders

* use s2i fork with updated docker

* in-code builder defaults

* s2i builder verbosity constructor arg

* typed errors

* typed error tests

* remove unneeded env code

* s2i build e2e test

* e2e tests

* update licenses

* cleanup

* codegen debug

* update licenses

* Revert "Update actions (#921)"

This reverts commit 8312b5c560.

* update licenses

* e2e test updates

* use GetDefaultDockerConfig for s2i config

* docker.NewClient docs
2022-04-05 13:08:44 +00:00
Luke Kingland 9a0335de7d
src: exported client constructor with options (#883)
* 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.
2022-03-30 00:58:46 +00:00
Luke Kingland 25524a1f84
fix: bind verbose flag to root (#884) 2022-03-08 11:02:06 -08:00
Luke Kingland 5a122c31e6
src: promote verbosity to constructor arg (#869)
* 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
2022-03-04 11:19:36 -08:00
Luke Kingland 043a00d12b
src: update root and version structure and help text (#865)
* update root and version structure and help text

* test root command help output

* fix trailing whitespace
2022-03-02 11:58:44 -08:00
Luke Kingland 2bd5254f19
feat: command help text template preprocessing (#875) 2022-03-02 03:56:43 -08:00
Luke Kingland 3f30c91116
fix: use full root name for cmd help prefixes (#873) 2022-03-02 02:18:42 -08:00
Matej Vasek 4fec4afca1
Custom improvements for OpenShift (#825)
* Custom improvements for OpenShift

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* fixup: osh cred loader

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* fixup: style

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* fixup: dns-err detec for fallback in cluster dial

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-02-22 10:17:04 -08:00
Luke Kingland 5b06498200
fix: defaults for prompt from flags then options (#821) 2022-02-09 12:24:42 -08:00
Matej Vasek 568af71712
src: cmd's common fn.Client (#824)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-02-09 08:19:41 -08:00
Matej Vasek abd4eea0c7
Cleanup commands (#807)
* 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>
2022-02-03 10:26:21 -08:00
Luke Kingland e918f74b9e
feat!: invoke (#705)
* 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>
2022-01-21 12:04:05 -08:00
Lance Ball 0d68ff945e
chore: refactor cli flags for path and namespace (#702)
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>
2021-12-06 11:46:27 -08:00
Fabian Lopez 2f241824ff
feat: add flag to push image at the end of a successful build (#681)
* 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
2021-12-03 07:07:37 -08:00
Luke Kingland db9ad07c70
feat: ensure config and repos path exists (#683) 2021-11-29 13:53:08 -08:00
Luke Kingland 4d29384958
chore: prefer slices over plural types (#655)
* chore: prefer slices over plural types

* chore: update formatting to reflect slice types
2021-11-12 03:36:36 -08:00
Matej Vasek e85a4aa7f3
feat: Save password after user input (#560)
* Save password after user input

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Improve wording

Signed-off-by: Matej Vasek <mvasek@redhat.com>
Co-authored-by: Lance Ball <lball@redhat.com>

* Apply suggestions from code review

Signed-off-by: Matej Vasek <mvasek@redhat.com>
Co-authored-by: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com>

* Improve test

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Fix for symlinks

Signed-off-by: Matej Vasek <mvasek@redhat.com>

Co-authored-by: Lance Ball <lball@redhat.com>
Co-authored-by: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com>
2021-10-13 06:29:47 -07:00
Luke Kingland 4fe9fdcab0
feat: create cli (#547)
* 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
2021-09-22 13:00:12 -07:00
Luke Kingland ae638c349c
feat: repository management cli (#514)
* feat: repository management cli

* src: cleanup imports, newlines, spelling and trailing whitespace
2021-09-09 08:09:00 -07:00
Fabian Lopez eb17fb819c
chore: example message changes between standalone and plugin (#507)
* 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>
2021-09-08 06:42:45 -07:00
Zbynek Roubalik 55696811e3
feat!: use key&value for Labels (#472)
* feat!: use key/value for labels

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* fix typo

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-08-11 10:12:00 -07:00
Lance Ball 0dba67751e
feat: add support for labels in func.yaml (#373)
* 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>
2021-08-03 06:10:16 -07:00
Luke Kingland 66c26115b8
test: confirm repositories search path (#431) 2021-07-22 13:39:44 -07:00
Markus Thömmes 892558bf2a
Rename module to knative.dev/kn-plugin-func (#423)
Co-authored-by: Lance Ball <lball@redhat.com>
2021-07-15 11:33:32 -07:00
Luke Kingland 5ded87368b
src: rename bosonFunc fn 2021-06-22 23:08:11 +09:00
Zbynek Roubalik 9d7fd34649
feat: reference Secrets in `envs` and `volumes` sections in config (#369)
* feat: reference Secrets in `envs` and `volumes` sections in config

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-06-02 09:20:28 +02:00
Lance Ball 2b025df199
src!: revert bump to go 1.16 and template changes (#340)
* Revert "src: rename boson import 'fn'"

This reverts commit c0a6f561c0.

* Revert "src: all test dirs set to 0700"

This reverts commit 99f01220c2.

* Revert "src: better error when custom template not found"

This reverts commit 6673395834.

* Revert "src: better errors when custom runtime not found"

This reverts commit a31a6f67a1.

* Revert "build: create separate target for templates.tgz"

This reverts commit 11164bf8d9.

* Revert "src: use consistent separators for fs.FS instances"

This reverts commit 4db07b412f.

* Revert "src: update go event template dependencies"

This reverts commit 3bfc13380f.

* Revert "src: tarfs assumes forward slashes internally"

This reverts commit 6cc0e67b1c.

* Revert "feat: support windows paths in embedded templates FS"

This reverts commit c2b216857b.

* Revert "feat: positive error when runtimme or template unrecognized"

This reverts commit acc56b0900.

* Revert "fix: lint issues"

This reverts commit 895872aee7.

* Revert "ci: go 1.16 compatiblity updates"

This reverts commit 1e3959c045.

* Revert "feat: preserve file modes using in-memory tar FS"

This reverts commit 7dc772ec62.

* Revert "feat: create templates archive on go generate"

This reverts commit 63b7f11471.

* Revert "ci: remove pkger from ci"

This reverts commit 876b0dd0f7.

* Revert "src: remove pkger dependency and tidy"

This reverts commit f006ab1e32.

* Revert "src: remove packaging artifact"

This reverts commit 4d9d0a7b4e.

* Revert "src: remove pkger from make targets"

This reverts commit e44c1ad74c.

* Revert "src: replace pkger with embed.FS"

This reverts commit 38874a4afd.

* Revert "src: update references to deprecated ioutil"

This reverts commit 4025460f73.

* Revert "src: require go 1.16"

This reverts commit 512d4c2580.

* chore: update pkged.go

Signed-off-by: Lance Ball <lball@redhat.com>
2021-05-12 14:37:21 -04:00
Luke Kingland c0a6f561c0
src: rename boson import 'fn' 2021-05-07 14:17:14 +09:00
Lance Ball 857b0fd19d
feat: add/improve spinner for build and deploy (#322)
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>
2021-05-03 14:25:19 -04:00
Lance Ball 89ff286a1f
refactor!: change envVars to env in func.yaml (#316)
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>
2021-04-27 10:46:50 -04:00
Matej Vasek 923c788f4a
src: better ctx propagation (#283)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-03-24 11:05:52 -04:00
Matej Vasek db0945ed3e
fix: `func run` now uses Docker API, not binary
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-03-15 18:24:57 +01:00
Zbynek Roubalik a5cbe3061b
src: rename from faas to func (#253)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-01-21 17:10:39 +01:00
Roland Huß 5dd72d7348
chore: Update help messages and adding examples. (#218)
* 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
2020-11-06 14:11:57 -05:00
Zbynek Roubalik 470ebb9da4
rename function -> func (#217)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-11-06 12:47:30 +01:00
Zbynek Roubalik cd57692c9d
feat!: rename faas to function (#210)
* rename faas to function

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* function.yaml -> func.yaml

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-11-06 10:41:42 +01:00
Matej Vasek 5182487df2
feat: user can set envvars 2020-10-13 14:11:06 +02:00
David Simansky ec5327d520
fix: root cmd init 2020-10-08 18:35:18 +02:00
David Simansky 85a5f475eb
feat(kn): Enable faas to be integrated as plugin to kn (#155)
Provides capabilities for the faas CLI to exist as a plugin in the upstream kn CLI.

Tested with kn 0.17
2020-10-08 10:14:10 -04:00
Lance Ball e425c8f081
src!: change all references of "repository" to "registry" for images (#156)
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>
2020-10-08 10:58:17 +02:00
Zbynek Roubalik d5839ea6c1
feat!: combine deploy and update commands (#152)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-10-07 17:29:09 +02:00
Matej Vasek c2b4a304bd
feat: ability for users to specify custom builders (#147)
* refactor: functionWithOverrides
* feat: custom Buildpacks builder
* fix: namespaces
2020-10-05 10:29:51 -04:00
Zbynek Roubalik 025862689e
feat: decouple function name from function domain (#127)
* decouple function name from function domain

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-09-24 09:52:22 -04:00
Lance Ball fae27dabc9
fix: correct value for config path and robustify (#130)
* 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
2020-09-21 14:35:46 -04:00
Lance Ball 566d8f9255 feat: default to no confirmation prompts for CLI commands
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
2020-09-11 14:36:34 -04:00
Luke K 3fc39aa773
feat: consolidate formatters
- 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
2020-08-31 16:37:07 +09:00
Luke K 00ac880c3b
docs: fix function typos 2020-08-29 01:55:33 +09:00
Luke K 4918cc7eef
feat: cli usability enhancements and API simplification 2020-08-29 01:54:13 +09:00
lkingland 4c3a276c2f
feat: version command respects verbose flag (#61) 2020-08-13 17:05:59 -04:00
Matej Vasek 4677b3452f
chore: add lint to GH actions CI 2020-07-29 17:47:08 +02:00