Commit Graph

34 Commits

Author SHA1 Message Date
Luke Kingland e6fa020f78
fix: test and namespace isolation (#2187)
* fix: namespace logic cleanup and test isolation

- Pulls logic for defaulting to active namespace (K8S) moved UP to CLI during
  flag default calculation.
- Pushes logic of deciding between f.Namespace vs f.Deploy.Namespace down into
  implementations.
- Updates some tests which needed to have their environment cleared.
- Refactors Pipelines tests to use client API.
- Removes namespaces as a state variable all structures, instead passing as
  an argument.
- Moves FromTempDirectory to testing package for use outside cmd.

* fix spelling errors

* fix: pipelines remover always returned (empty) error

* update tekton namespace handling

* fix: remove deprecated GitLab config: max_concurrency
2024-05-17 08:25:46 +00:00
Luke Kingland e0c4d7bf91
cleanup unused args (#2240) 2024-03-25 08:02:00 +00:00
Luke Kingland 9632748f19
src: errors cleanup (#1783) 2023-06-06 20:15:26 +00:00
Luke Kingland c96d29faa3
src: invoke response cleanup (#1777) 2023-06-05 09:48:41 +00:00
Lance Ball f070ea8c00
chore: improve error messages for most commands (#1745)
This commit adds a new error type `UninitializedError` to minimize
redundancy across commands, and applies it in all of the commands which
need an initialized function to operate.

Fixes: https://github.com/knative/func/issues/1744

Signed-off-by: Lance Ball <lball@redhat.com>
2023-05-17 15:52:12 +00:00
Matej Vasek 62105aa857
chore: improve error message when no func on path (#1739)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2023-05-15 18:44:09 +00:00
Luke Kingland 3ac1ef9229
docs: standardize env flag help suffix (#1689)
* remove 'Env:' prefix from command help text environment variables

* regen docs
2023-04-25 13:56:45 +00:00
Luke Kingland aa582dad21
cli help text updates and flags cleanup (#1564)
* cli help text and flags cleanup

- verbose flag uses global setting throughout
- confirm flag added using shared visitor throughout
- path flag added using shared visitor throughout
- removes --version flag on root as redundant with subcommand
- splits main help's 'Main Commands' into 'Primary Commands' and 'Development
  Commands' groups
- Moves RunE definition into flag struct literals

* remove commented code
2023-03-01 09:35:54 +00:00
Zbynek Roubalik 5a4803bf95
chore: refactor repository layout (#1554)
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
2023-02-15 08:46:52 +00:00
Adam Boczek 2f021f118b
chore: refactor commands help to use templates (#1485)
* chore: extend help template engine and docs generator to get root use

* chore: refactor deploy cmd

* chore: refactor build cmd

* chore: refactor all relevant commands and remove defaultTemplatedHelp func

* chore: update docs

* chore: remove unused functions

* chore: add template func for rendering sub-templates

* chore: fix for typos
2023-01-16 20:40:53 +00:00
Luke Kingland f6a3e55927
feat: effective path (#1353)
* effective path

* function context for build builder

* code review suggestions

- fix misspelled 'precedence' throughout
- remove superfluous command execution from test
- remove debug statements
- add FUNC_PATH precedence check with short-flag in effectivePath test

* rebase and update to NewTestClient
2022-11-11 11:21:17 +00:00
Luke Kingland 11616840b9
path default cwd (#1411)
The system fully supports an empty (zero value) path as indicating
operations should take place on the current working directory by default.
2022-11-07 12:07:21 +00:00
Luke Kingland 034e2de849
chore: global config file paths (#1344)
* feat: config members and paths

- Adds Builder, Namespace, Registry and Verbose as globally
  configurable.
- Fixes problems where file paths were being created or required when
  not necessary.
- Relocates environment variable usage to main's use of config
- Adds FUNC_CONFIG_PATH
- Only creates paths on disk when necessary
- Makes non-existent config paths nonfatal

* postpone adding some members
2022-10-21 10:38:13 +00:00
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
David Simansky e0bbcc2d08
chore: Refactor use of deprecated io/ioutil package (#1285) 2022-09-27 13:28:15 +00:00
Luke Kingland 4c8f730099
feat: readonly global config (#1260)
* improved deploy test output

* remove unused config struct

* feat: read-only global config

Co-authored-by: Lance Ball <lball@redhat.com>
2022-09-23 17:49:13 +00:00
Luke Kingland 63af791e9f
fix: always use function's namespace when invoking remote (#1258)
* fix: always use function's namespace when invoking remote

* test

* Apply suggestions from code review

Co-authored-by: Matej Vasek <matejvasek@gmail.com>
2022-09-23 12:42:13 +00:00
Zbynek Roubalik 50243c740a
feat: `invoke` - allow insecure connections over SSL (#1255)
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
2022-09-20 12:25:10 +00:00
Luke Kingland fecbc4ef8b
chore: use dot as path default rather than absolute path (#1184)
* use '.' in flags to indicate default function path

* regen commands.txt with '.' as default path

* centralize dot expansion

* minor cleanup

* update all references to path flag

* exits should be panics
2022-08-24 11:02:18 +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
Lance Ball df022f5c93
docs: replace commands.md with generated text file (#1089)
* docs: replace commands.md with generated text file

This commit removes commands.md document which tends to get out of date
pretty easily and replaces it with a generated commands.txt file. The
help text generation is fairly naive, but should be sufficient for the
time being.

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

* fixup: tweak title formatting

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

* fixup: run build-docs.sh again after recent change

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

* fixup: add docs generation to make build target

Also removes the random UUID as the default for `invoke` since it's a
little misleading. That value will not be the one that's used, since
it's random. And because it's random, it changes the docs every time.

Signed-off-by: Lance Ball <lball@redhat.com>
2022-07-25 16:10:24 +00:00
Luke Kingland d1f935fde9
feat: languages list command (#1114)
* feat: languages list command

* corrections
2022-07-18 11:20:59 +00:00
Luke Kingland b40911b67c
fix: map invoke format flag (#1041) 2022-06-09 09:12:40 +00:00
Luke Kingland 867d4c26d6
feat: improved invoke verbosity (#1007)
* feat: improved invoke verbosity

* e2e test updates

* regen filesystem

* e2e tests: add to query what is expected as an echo
2022-05-11 19:16:35 +00:00
Luke Kingland c3c1456ede
feat: invoke verbose metadata (#944)
* invoke verbose prints metadata

* review updattes
2022-04-06 14:19:47 +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
Lance Ball 6d7ab83aed
Make `func invoke` print any response it receives. (#881)
* Make `func invoke` print any response it receives.

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

* fixup: improve test

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

* fixup: check Write() return value

Signed-off-by: Lance Ball <lball@redhat.com>
2022-03-06 14:25:35 -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
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 a2abfca3d3
src: error-less ctors (#818)
* src: no error ctors

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

* src: no error ctors

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-02-08 12:20:16 -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