Commit Graph

19 Commits

Author SHA1 Message Date
Lance Ball 5adec03c7b
chore: update all references to kn-plugin-func (#1311)
* chore: update all references to kn-plugin-func

I did not change references in CHANGELOG.md but otherwise, I believe
this should cover all configuration settings, image names, package
names, etc.

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: fix instances_test.go

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: still some stray kn-plugin-func

Signed-off-by: Lance Ball <lball@redhat.com>

Signed-off-by: Lance Ball <lball@redhat.com>
2022-10-13 16:31:53 +00:00
Adam Boczek 1b94698f56
fix: the --registry flag is ignored when image: <imagename> exists in func.yaml (#1310)
* fix: add handling in case of differences between registry value and image tag (#1297)

* fix: add additional test cases (#1297)
2022-10-12 14:42:52 +00:00
Luke Kingland c9861ec24e
chore: cmd test cleanup (#1289)
All tests which are directory-sensitive now also:
- reset viper
- use t.Cleanup
- use t.TempDir
- use a clean XDG_CONFIG_HOME
- specify explict name when creating
- moves helpers to root_test
2022-10-03 22:03:28 +00:00
Luke Kingland 15713b2a75
feat!: deploy autobuild and flag persistence (#1079)
* feat: deploy autobuild and flag persistence

* cleanup

* help text, comments and test cleanup

* removing usurped commands.txt

* add platform to deploy synopsis help
2022-09-14 11:45:10 +00:00
Luke Kingland ae75e5e803
fix: image name derivation and flag precidence (#1185)
* fix: image name derivation and flag precidence

* cleanup

* fix image prompt, reorganize and cleanup

* client deploy image test

* be explicit about registry treatment in tests

* ineffassign

* fix: k8s env not required

* misspell

* minor cleanup

* recombine build and deploy configs

* test namesace choosing logic
2022-09-04 19:37:21 +00:00
Lance Ball b8c445579b
fix: check for `--image` flag in build command (#1204)
* fix: check for `--image` flag in build command

If the user provides an `--image` flag on the command line, it should be
used. This commit modifies the image resolving code to check whether or
not the image name was provided on the command line.

Fixes: https://github.com/knative-sandbox/kn-plugin-func/issues/1125

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: review feedback

Signed-off-by: Lance Ball <lball@redhat.com>

Signed-off-by: Lance Ball <lball@redhat.com>
2022-08-31 16:04:17 +00:00
Luke Kingland e6ec11b0e5
builder short name constants etc throughout (#1180)
* chore: shared builder constants etc

* pretty-print the shared unknown builder error

* update builder impls to use shared defs and validators

* error and docs text formatting

* include static default short names

* comment updates and typos

* docs paths

* use the constants for the in-package builder defaults

* use builders.All but with caviat
2022-08-24 19:34:18 +00:00
Lance Ball 80657c90e3
fix: ensure registry in func.yaml is respected (#1168)
* fix: ensure registry in func.yaml is respected

If the user has a value specified in func.yaml for the image registry,
that value should be used by the build command, if not otherwise
specified as a flag or via the environment.

Fixes: https://github.com/knative-sandbox/kn-plugin-func/issues/1159

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: lint

Signed-off-by: Lance Ball <lball@redhat.com>

Signed-off-by: Lance Ball <lball@redhat.com>
2022-08-16 00:05:49 +00:00
David Fridrich e659256005
chore: use lower case *functions* in all CLI outputs (#1135)
* first run, F -> f

* fix

* fix

* misspells

* client*.go files

* add client*.go: misspells

* cmd dir test files

* docker dir

* function* files

* i*.go and job.go

* job.go,mock dir,repos*,s2i dir,schema dir,templates*

* test dir

* testing dir

* root dir *.go second round
2022-07-27 13:34:36 +00:00
David Fridrich 8cb70808f5
feat: always store namespace in func.yaml and warn if current ns & func.yaml ns is different (#1118)
* check namespace; add to func.yaml on first deploy; added tests and mock kubeconfig for testing

* change func args because only f.Namespace is used instead of the whole struct

* func comment

* misspell

* fix tests

* warning in stderr

* use context.Background

* add fake kubeconfig for new test
2022-07-20 16:35:01 +00:00
Gunjan Vyas b1fd9f71b1
feat: persist builder value in func.yaml (#1099)
* Persist builder value in func.yaml

* Added tests

* removed print statement for platform error

* created common function for builder persistence test
2022-07-19 11:42:00 +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
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
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
Zbynek Roubalik 64ba17b4fb
feat: add possibility to disable pushing of image in `deploy` command (#739)
* feat: add possibility to disable pushing of image in `deploy` command

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

* remove commented code

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

* incorporate feedback

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2022-01-07 06:40:26 -08:00
Zbynek Roubalik 2282cf899d
Revert "feat: add possibility to disable pushing of image in `deploy` command (#736)" (#738)
This reverts commit 4e5a5e8307.
2022-01-06 08:03:02 -08:00
Zbynek Roubalik 4e5a5e8307
feat: add possibility to disable pushing of image in `deploy` command (#736)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2022-01-06 07:22:01 -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
Lance Ball 10f2cf44c7
fix: make registry validation work again (#690)
* fix: make registry validation work again

In ccf00152be
the behavior of `NewFunction()` changed slightly, such that it no longer actually
works without a provided and valid path. This was not caught in any of the
tests, because it's the CLI code that was making this call, and the end to end
tests that exercise the build command, use the `--repository` flag, causing
the repository validation code path to be slightly different.

This commit just adds the path so that `func build` without a `--repository` flag will work again.

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: add validation for registry flag and a test

Signed-off-by: Lance Ball <lball@redhat.com>
2021-12-01 18:11:45 -08:00