Commit Graph

52 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 8ea1846c34
feat: add missing command aliases (#1775) 2023-06-05 09:39:42 +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
Luke Kingland 958429c2f3
feat: deploy command global config with function context (#1434)
* feat: deploy command global config function context

* fix static check errors

* fix test

* fix remote persists test

* env opaque box test

* use keyed fields (govet)

* mock deployer expansion

* ClearEnvs now in shared testing pkg

* effectivePath now uses plfags

* list directly uses config for default namespace

* Improved Namespace calculation and Caching

- Built() now a client package function
- Namespace evaluation delegeate to implementations
  This enables the func.yaml to avert dirtiness checks on rebuilds
  (caching)
- Build and Deploy update build stamp on completion
  Enables dirtiness checks to be unaffects, leading to better caching.
- CLI Namespace checks no longer require k8s env evaluation for default
- Fixed missing condition check in TestDeploy_Namespace
- Fixes some minor linter and spelling errors
- Global config does not directly set namespace - it is corrected to be
  deferred evaluation used by implementations.
- Skips writing func.yaml on f.Write if there were no modifications,
  which leads to better caching (no timestamp update means Built ==
  true)
- HasImage removed in favor of a corrected fn.Built

* linting, misspellings and docs rebuild

* warn user if git settings exist on a non-remote build

* lint error fix

* test flag unsetting persists

* allow unknown flags in preparsing of flags

* pre-submit cleanup

* update cmd to use client.Init
2023-02-06 08:43:35 +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 f9dc8b659f
chore: list command namespace (#1370)
* chore: list command namespace

- Adds namespace test to list command
- Moves namespace flag into list command for
  - Better help text
  - Easier testing
- Sets static default namespace for flag to "default"

* regen docs

* list test default from kubeconfig
2022-10-31 19:59:13 +00:00
Luke Kingland 0fa9359750
feat: namespace globally configurable (#1352)
* namespace global config

* integrate namespace config into commands

* comment updates

* combine config write tests

* updates per code review

* regen docs
2022-10-31 18:07:12 +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
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 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 2bd5254f19
feat: command help text template preprocessing (#875) 2022-03-02 03:56:43 -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
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
Kenjiro Nakayama 5553998b9c
Do not print header when func list does not find any functions (#632)
`func list` prints the header when it gets `No functions found`.
This patch stops displaying the header.

ASIS
```
$ func list
No functions found
NAME  NAMESPACE  RUNTIME  URL  READY
```

The header `NAME  NAMESPACE  RUNTIME  URL  READY` should not be print.

TOBE (by this patch)
```
$ func list
No functions found
```
2021-11-05 09:00:12 -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 afcde2d551
src: testable commands (#415)
* feat: client progress listener 'stopping' state

* src: testable commands

Restructures commands to accept a fn.Client constructor on command
instantiation.  This allows the concrete implementations, or entire
client to be mocked for testing.
Also some minor refacotring as necessary to shoehorn into the pattern.

* fix: increase default timeout to 120s for service creation

* chore: bump kind, knative and kubectl versions
2021-07-09 11:15:23 -04:00
Luke Kingland 5ded87368b
src: rename bosonFunc fn 2021-06-22 23:08:11 +09:00
Jim Crossley 947fcaa968
feat: add a URL output type for `func describe` (#389)
* Added a URL output type for 'func describe'

Fixes #387

Co-authored-by: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com>
2021-06-18 09:50:36 +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
Zbynek Roubalik 541e8586f7
feat: function name matches KService name (#317)
* feat: function name matches KService name

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

* fix typo

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-04-26 10:13:32 +02: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
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
Zbynek Roubalik 8d1f5b833d
fix: correcting broken merge (#252)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-12-14 09:54:07 -05:00
Lance Ball 61ea8d4fc6
fix: print "No functions found in [ns] namespace" for kn func list (#240)
When there are no functions deployed, the `kn func list` command now says so.

Fixes: https://github.com/boson-project/faas/issues/228

Signed-off-by: Lance Ball <lball@redhat.com>
2020-12-11 09:34:53 -05:00
Lance Ball 6470d9e574
fix: change --format flag to --output for list and describe commands (#248)
Fixes: https://github.com/boson-project/func/issues/223

Signed-off-by: Lance Ball <lball@redhat.com>
2020-12-11 15:32:30 +01:00
Lance Ball 8e72fd2eba
feat: add --all-namespaces flag to `func list` (#242)
* feat: add --all-namespaces flag to `func list`

Fixes: https://github.com/boson-project/faas/issues/224

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

* fixup: linting

Signed-off-by: Lance Ball <lball@redhat.com>
2020-12-10 12:12:11 +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
Zbynek Roubalik 29ca07768c
feat: list command - improved output (#205)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-11-04 13:15:06 +01:00
Lance Ball a698f39d1d
chore: rename .faas.yaml to faas.yaml (#143)
Fixes: https://github.com/boson-project/faas/issues/142

Signed-off-by: Lance Ball <lball@redhat.com>
2020-09-29 10:27:04 -04:00
Lance Ball 05efee8c83
src: add Long command descriptions for each of the CLI commands (#133)
Uses the Cobra "Long" configuration for each command to provide more
descriptive text.

Example:

```console
faas help create                                                                                                      1.3m  Mon 21 Sep 2020 09:55:40 PM EDT
Create a new Function, including initialization of local files and deployment

Creates a new Function project at 'path'. If 'path' does not exist, it is
created. The function name is the name of the leaf directory at path. After
creating the project, a container image is created and is deployed. This
command wraps 'init', 'build' and 'deploy' all up into one command.

The runtime, trigger, image name, image repository, and namespace may all be
specified as flags on the command line, and will subsequently be the default
values when an image is built or a Function is deployed. If the image name and
image repository are both unspecified, the user will be prompted for a
repository name, and the image name can be inferred from that plus the function
name. The function name, namespace, image name and repository name are all
persisted in the project configuration file .faas.yaml.

Usage:
  faas create <path> [options] [flags]

Flags:
  -c, --confirm             Prompt to confirm all configuration options - $FAAS_CONFIRM
  -h, --help                help for create
  -i, --image string        Optional full image name, in form [registry]/[namespace]/[name]:[tag] for example quay.io/myrepo/project.name:latest (overrides --repository) - $FAAS_IMAGE
  -n, --namespace string    Override namespace into which the Function is deployed (on supported platforms).  Default is to use currently active underlying platform setting - $FAAS_NAMESPACE
  -r, --repository string   Repository for built images, ex 'docker.io/myuser' or just 'myuser'.  Optional if --image provided. - $FAAS_REPOSITORY
  -l, --runtime string      Function runtime language/framework. - $FAAS_RUNTIME (default "go")
      --templates string    Extensible templates path. - $FAAS_TEMPLATES (default "/home/lanceball/.config/faas/templates")
  -t, --trigger string      Function trigger (ex: 'http','events') - $FAAS_TRIGGER (default "http")

Global Flags:
      --config string   config file path (default "~/.faas/config")
  -v, --verbose         print verbose logs
```
2020-09-24 10:23:55 -04:00
Lance Ball 3868ef3441 chore: remove [options] from usage string
The cobra package, magically appends "[flags]" to the usage string
if a command has flags. By adding "[options]" to the usage string,
we end up with help text that looks like this.

```
  faas init <name> [options] [flags]
```

This commit fixes that.
2020-09-19 17:23:08 -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 d33fb2d694
feat: test suite
- updated tests to new api throughout
- expanded tests where appropriate
- lint issues
- minor code review comments addressed
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
Matej Vasek fbab8c09d0
feat: the `list` sub-command uses namespace 2020-08-24 14:08:25 +02:00
Matej Vasek 17a00c9057
feat: JSON output for the `list` sub-command 2020-08-11 15:25:33 +02:00
Luke K 711094b02e
rename Service Function to simply Function 2020-07-02 14:52:27 +00:00
Luke K 88d806b52b
allow path to be provided to commands 2020-05-11 04:01:49 +00:00
Luke K 724b64b51a
FaasNamespace to DefaultNamespace 2020-05-11 00:17:39 +00:00
Luke K 1a3fbe294d
flatten package structure 2020-05-10 23:55:04 +00:00
Matej Vasek 380cc2f3ef feat: 'describe' sub-command for faas cli 2020-05-05 01:13:48 +02:00
Matej Vasek 09cb2d5425 Rename packages
Needed since the project has been moved.
2020-04-27 16:45:46 +02:00