Commit Graph

412 Commits

Author SHA1 Message Date
Luke Kingland 4b2bdc9b8a
fix: incorrect deploy namespace warnings (#1257) 2022-09-20 02:34:09 +00:00
Adam Boczek e1e33370d3
fix: add extra request to template cmd to avoid subsequent if repo does not exist (#1206) (#1249) 2022-09-19 12:43:08 +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
Adam Boczek 4d622bc007
feat: group main help message to put important commands to the top (#1152)
* feat: add initial version of command groups and template engine (#215)

* feat: add relevant dependencies and vendor files (#215)

* feat: extend TestUsageFlags for hidden flags and flags with no shorthand (#215)

* feat: refactor root.go to use command groups (#215)

* feat: move the long help of root cmd to the usage templates section (#215)

* feat: updates after rebase (#215)

* feat: update after review (#215)

* feat: rename 'options' into 'flags' to align with the old help (#215)

* feat: remove support for help options, add template for global flags help section (#215)

* feat: update handling of root command help to support proper use of templates and docs generation (#215)

* feat: generate new docs (#215)
2022-09-13 14:13:48 +00:00
Matej Vasek a6c885ef04
feat: UX improvements for docker/podman usage (#1224)
* Better error message I docker/podman not present.
* Auto detect podman machine's socket on mac/win.

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

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-09-09 13:34:29 +00:00
Luke Kingland 4e5e9927b2
fix: only use flag value as default or if altered (#1223) 2022-09-07 20:47:18 +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
Ying Chun Guo d0a181bd24
use correct sample repository name in command usage (#1207) 2022-08-31 11:19:16 +00:00
Matej Vasek 6a0b4a2211
fix: flags more consistent between build/deploy (#1202)
Signed-off-by: Matej Vasek <mvasek@redhat.com>

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-08-30 19:16:18 +00:00
Matej Vasek 56b1db3500
Improve `func config envs` (#1188)
* Added ability to add env non-interactively
* Added ability to list envs as JSON

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

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-08-30 15:41:17 +00:00
Lance Ball 81289dc757
doc: use cobra markdown generator for command docs (#1169)
This commit removes the docs/reference/commands.txt file and instead
uses the Cobra built-in documentation generator to create markdown
documents for every command.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2022-08-25 13:16:19 +00:00
Zbynek Roubalik 1112aaa2fe
feat: S2I strategy for on cluster build (#1191)
* feat: S2I strategy for on cluster build

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>

* use upstream `s2i` task only

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>

* use custom func-s2i task

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
2022-08-25 13:03:19 +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
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
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
Ying Chun Guo 12073a4c8f
remove duplicate cmd.AddCommand(NewLanguagesCmd) at root.go (#1162) 2022-08-11 14:52:03 +00:00
Luke Kingland 2f8d82bec2
feat: templates list command (#1134)
* feat: templates list command

* linter placation
2022-08-10 19:37:58 +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
Zbynek Roubalik 71b0dddc55
chore: add validation for `builder` (#1136)
* chore: add validation for `builder`

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>

* address feedback

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
2022-07-25 16:09:24 +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
Lance Ball 59df756e49
fix: add languages command to cmd root (#1127)
Also add a little more information to the short description.

Signed-off-by: Lance Ball <lball@redhat.com>
2022-07-20 15:59: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 d1f935fde9
feat: languages list command (#1114)
* feat: languages list command

* corrections
2022-07-18 11:20:59 +00:00
Zbynek Roubalik b4b4cc34c3
feat: add OpenShift related Annotations & Labels (#1106)
* feat: add OpenShift related Annotations & Labels

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>

* fix test

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
2022-07-13 18:19:14 +00:00
David Fridrich c57af36f74
feat: func deploy accepts image digest in --image (#1098)
* --image can be given with digest, created parser and edited some help text to reflect this

* fixed small stuff

* tests for deploy with --image

* move parser to file, static test should be kept active

* updated some error mesgs; now prints a warning if flags not set explicitly, if set to a wrong value, return an error; updated tests to fit new error messages

* --image flag message edit

* removed warning; instead print info about disabled push a build unconditionally
2022-07-12 19:24:13 +00:00
Matej Vasek 80505979f9
Improve usability of `func` CLI for IDE plugins (#1091)
* Better input handling for non-tty

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

* Make cred-helper 'not implemented' non fatal error

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-07-01 05:07:42 +00:00
Matej Vasek f066218042
Add --platform flag for build/deploy sub-cmd (#1076)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-06-22 16:40:23 +00:00
Lance Ball 80093d66a4
fix: do not prompt user if --build diabled (#1071)
Fixes: https://github.com/knative-sandbox/kn-plugin-func/issues/693

Signed-off-by: Lance Ball <lball@redhat.com>
2022-06-16 22:39:17 +00:00
Luke Kingland 7a60394be6
feat: add all build flags to deploy (#1065)
* spelling

* feat: full build options on deploy

* increase e2e lifecycle test timeout to 45m

* remove redundant flag shorthand b

* map flags for parsing
2022-06-16 16:02:17 +00:00
Luke Kingland 3000a8857a
feat: on run, build only when filesystem changed (#1031)
* feat: detect built image staleness and utilize on run command

* write directly to sha256 rather than buffer

* client test cleanup

* remove superfluous test println

* ensure runtime dir

* close file opened when testing

* fix typos

* typos and missing test case
2022-06-15 09:56:17 +00:00
Luke Kingland b40911b67c
fix: map invoke format flag (#1041) 2022-06-09 09:12:40 +00:00
Luke Kingland 5e26510f9d
feat: builder images map migration (#1033)
* feat: function builder images migration

* fix typos and comments
2022-06-07 11:15:36 +00:00
Luke Kingland 17dc507c25
feat: pack builder images individually configurable (#1028) 2022-06-03 20:31:52 +00:00
Luke Kingland 096085d751
feat: configurable s2i builder images (#1024)
adds support for the builderImages func.yaml attribute
2022-06-01 06:12:02 +09:00
Matej Vasek 8f405b691a
Improve help for the `build` sub-command (#1023)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-05-26 17:21:00 +02: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
Matej Vasek e9932cdf43
fix: read pwd from non-tty input (#996)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-04-28 12:09:53 +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 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
Matej Vasek 669329f02f
Improve error handling (#916)
* replaced plain `==` by `error.Is()`
* wrapping some more errors using `fmt.Errorf()`

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-03-22 17:18:17 -07:00
Luke Kingland 9dec4c20ee
differentiate repository and repositories (#900) 2022-03-16 14:01:59 -07:00
Zbynek Roubalik c60079d792
🐛 allow adding environment variables without a cluster connection (#893)
* allow adding environment variables without a cluster connection

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>

* add tests

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>

* use k8s clientcmd

Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
2022-03-16 07:20:00 -07:00
Luke Kingland 25524a1f84
fix: bind verbose flag to root (#884) 2022-03-08 11:02:06 -08: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 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
Senthilnathan M efb7996da7
printing helpful shorthand command (#816)
* printing helpful shorthand command

* Addressed review comments

* Resolved rebase conflicts

* Using cmd.Root().Name() for getting the executable name
2022-03-01 11:56:42 -08:00
Fabian Lopez 60dbeacc46
added git related flags for remote builds (#844)
* added git related flags for remote builds

* fix dependency issues

* remove context cancel

* add # split for git url

* account for the use of git args with local build type

* fix error message for build type
2022-02-28 03:56:07 -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
Lance Ball 93fa9804da
chore: accommodate knative's go linter (#831)
Signed-off-by: Lance Ball <lball@redhat.com>
2022-02-15 12:23:00 -08:00
Matej Vasek 4000fc59d1
Fix --verbose mode for the version sub-command (#829)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-02-13 22:02:20 -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
Senthilnathan M 879031a245
Setting the default for language selector (#815) 2022-02-07 01:10:53 -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
Matej Vasek fff00497f8
feat: completion --build flag of deploy sub-cmd (#802)
* feat: completion --build flag of deploy sub-cmd

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

* src: refactor

Moved functionality.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-02-01 06:58:31 -08:00
Zbynek Roubalik d478f555cc
feat: delete pipeline and resources with `func delete` (#763)
* feat: delete pipeline and resources with `func delete`

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

* fix test and prompt

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2022-01-24 12:39:29 -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
Fabian Lopez 7de4dc1667
ensure build flag binds for run command (#758)
Signed-off-by: Fabian Lopez <lfabian@vmware.com>
2022-01-17 01:41:29 -08:00
Matej Vasek 15d617f99d
src: use common functionality for docker cred retrieval (#756)
* Use common functionality for docker cred retrieval

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

* fixup: docker auth secret for tekton pipeline

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

* fixup: style

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-01-13 03:52:12 -08:00
Zbynek Roubalik cb719ff564
feat!: support on cluster build from git repo with Tekton (#743)
* feat: support on cluster build from git repo with Tekton

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

* incorporate feedback

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

* incorporate feedback 2

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

* fixup-licence

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

* fix deploy with --build=disabled

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

* incorporate feedback

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

* incorporate feedback

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

Co-authored-by: Matej Vasek <mvasek@redhat.com>
2022-01-12 11:58:51 -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
Matej Vasek 8d51393181
feat: allow push to cluster internal registries (#718)
* feat: allow push to cluster internal registries

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

* fix: NewRoundTripper consults http.DefaultTransport

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

* src: move credential code to sub-package

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

* src: refactor

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

* src: share RoundTripper

avoid creating expensive RoundTripper twice

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

* test: added test for pusher

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

* src: disable parallel layer upload

it's more reliable

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

* fixup: lint

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

* fixup: lint

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

* fixup: doc, rm commented code

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-12-20 14:28:17 -08:00
Fabian Lopez b190b52754
feat: allow build to be triggered from run when fn.Image is missing (#644)
* allow build to be triggered from run when fn.Image is missing

* add build check when run by the run command

* added unit test for run command

* remove log output

* rename run test

* change build trigger to be managed by a flag and not a prompt

* tlet users know about the --build flag in the error message

* fix code check issue

* add some debug info to the run_test

* Update cmd/run.go

Co-authored-by: Luke Kingland <58986931+lkingland@users.noreply.github.com>

* add build field to runConfig

* fix issue with cmd args for testing

* refactor run tests to use mocks

* update imageless function run error message

* add check for build error test case

* run unit test cleanup

* empty commit

Co-authored-by: Luke Kingland <58986931+lkingland@users.noreply.github.com>
2021-12-13 09:25:22 -08:00
Matej Vasek 6c67be0515
src: revert golobal dialer (#716)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-12-10 08:12:29 -08:00
Matej Vasek a13f897fbb
feat: custom default HTTP transport (#711)
* src: dialer pod auto-exit

The pod should exit (be Completed) when func exits.

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

* feat: use in cluster dialer by default

This sets http.DefaultTransport to our specialized RoundTripper.
The RoundTripper first tries dial in standard way.
If dial operation fails due to hostname resolution error
in cluster dialer will be used.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-12-10 02:31:29 -08:00
Matej Vasek 27e1b0153a
Refactor credential provider (#707)
* src: cleanup

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

* src: cleanup

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

* src: cleanup

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

* src: cleanup

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

* src: cleanup

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

* src: allow to set custom crednetial loader

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-12-09 14:19:28 -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
Luke Kingland 92ac14a6f7
refactor: config path accessors with instantiation cleanup (#686)
* feat: config and repository path creation

Removes need to use a client to trigger creation of paths
Adds back static path accessors
Enables creation of paths when configured repos is outside config
Cleans up instantiation logic, including removal of some setters

* fix spelling mistakes per review
2021-12-06 06:03:28 -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
Luke Kingland db9ad07c70
feat: ensure config and repos path exists (#683) 2021-11-29 13:53:08 -08:00
Shashank Sharma a0bfc3e3ef
making language runtime a required flag (#647)
* making language as required flag

* create tests fixed

* gofmt

* more tests fixed

* more tests added for invalid runtime and template

* changes removed from client library

Co-authored-by: Luke Kingland <58986931+lkingland@users.noreply.github.com>
2021-11-23 18:43:27 -08:00
Luke Kingland c2e1b769cc
src: direct serialization of Function metadata as func.yaml (#641)
* src: directly serialize Function metadata as func.yaml

Functions now save directly to func.yaml using .Write().
Fixes a serialization error where defaults were not respected on load.
Moves runtime and template defaults into function constructor.
Extracts Function validation (was config validation) into separate functions.
Extracts associated test files (validation) into separate unit test files.
Updates schema generator to use Function

* comment spelling and re-enabling tests
2021-11-17 06:18:35 -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
Luke Kingland 1bf17ec976
feat: function creation timestamp (#651) 2021-11-11 08:25:38 -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
Zbynek Roubalik 0ed1e81692
fix: ConfigMap/Secret key validation (#623)
* fix: ConfigMap/Secret key validation

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

* add more tests

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-11-03 10:20:48 -07:00
Zbynek Roubalik ac9de9dfc6
fix: Environment values -> Environment variables (#622)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-11-03 08:24:49 -07:00
Lance Ball e319ea3b62
feat: add support for manifest.yaml at repo/language/template levels (#558)
* feat!: add support for manifest.yaml and runtime.yaml

BREAKING CHANGE
This commit adds the concepts of a manifest.yaml file at the top level
of a template repository, and a runtime.yaml file for each language/runtime
within the repository. Prior to this, repository metadata was primarily
restricted to information that could be gleaned from the file system, such
as the directory name used as the Name.

A manifest.yaml file contains a Name, URL, Version, and a list of supported
runtimes; and if all of the runtimes expose the same health endpoints, these
can be set here.

Within a runtime directory, there may exist a runtime.yaml file which allows
language pack providers to set the health endpoints, overriding the values
set in manifest.yaml, as well as Builders and Buildpacks.

This change removes support for a builders.yaml file in a runtime/template
directory, as this was guaranteed to be redundant with the builders.yaml
file in a sibling template directory. The choice was to move these up a
level to runtime/runtime.yaml.

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

* fixup: bump go version for unit tests

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

* fixup: using go 1.16 now requires 'go mod tidy'
See: https://golang.org/doc/go1.16

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

* fixup: restore support for directory traversal

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

* fixup: whitespace linting

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

* fixup: update func_yaml-schema.json

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

* fixup: spelling errors caught by reviewdog

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

* fixup: use os.ReadDir

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

* squash: restore project creation from remote repos

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

* fixup: remove billyFilesystem

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

* doc: expand on language pack documentation

Adds more detail around how language packs can be provided by third
parties, and the expected structure and metadata required.

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

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

* doc: update language pack documentation

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

* fixup: cleanup deps

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

* fixup: cleanup deps - again

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

* fixup: reviewdog whitespace cleanup

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

* fixup: custom repo template listing

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

* fixup: bump go version for integration tests

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

* fixup: adjust test-templates repo uri for e2e

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

* fix: don't fail when extended templates don't support a given runtime

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

* src: repo and template type hierarchy

As the client API increases in complexity, upgrading to a more correct
type hierarchy for the object managers serves to keep things clean.  In
this update, the Repository and Templates manager now use constructors
with private members, including a backreference to the root Client
object, which provides the mangers with full access to the current
client instance API for implementing their (growing) features.

* src: template manager writes

The templateWriter struct has now been upgraded to integrate with the
newly-added type system which includes a Templates Manager by adding a
.Write method which writes a template at the given location.  This
encapsulation of the write functionality moves us towards having a
cleaner abstraction atop writing any template to disk from any
repository.

In addition, the "Get" prefix was removed from many accessor methods, as
this is standard a Go idiom.

* src: templates write including denormalize

- merges templateWriter into templates manager
- denormalization of builders, health endpoints etc. made part of .Write
- write logic now works on a Template rather than string paths etc

The templates manager can now write out a template given a function directy.
Included internnaly to write is the denormalization logic, which is now closer
to where it is used, which should improve cohesion and decouple the template
implementation detail from the Client. Also moves the write logic closer to the
template itself, with the expectation the same will happen for functions when
Config and Function are merged.

* src: vendor

* src: merge manifests into domain model

In general, the manifests sytsem is merged more tightly into the overall
system while also expalding it to use a path to templates to avoid
having to create a full filesystem shadow-copy in yaml. Preserves
backwards-compatiblity by keeping the base case a yaml-free repo of only
templates.  Creaets a hierarchical inheritance from repository to
runtime to template for builders, endpoints etc.  whcih allows for the
manifest within templates to be a first-class citizen, though its use
will be rather rare.  Some more in-depth explanations of the more
substantive changes are as follows:

- Merges Manifest with Repository

The Manifest structure is essentially a serialized Repository, so they
are now the same object.

- Converts repo URL to a calculated field

The URL is informative and entirely dependent on the current state of
the repo, so it should be calculated to avoid confusion and avoid being
serialized to the manifest.

- Merge FunctionTemplate with Template

The struct being serialized here is a Template, so they are now the same object

- Extracts new "BuildConfig" embedded struct

The Builders and Buildpacks members are shared between Repository,
Runtime and Template, so they are now an embedded stuct in the same
manner as HealthEndpoints.

- yaml 'inline' declaration for embedded structs

The HealthEndpoints and other embedded structs were not actually being
read from their configs because of a nuance of yaml which (in contrast
to json unmarshallers) requires the `,inline` tag on the struct member
to trigger inclusion in decode.

- Replaces Repository's runtimes member with templates

While it is true that on disk templates are subdivided into their
effective runtime, this is for ease of development.  The logical
structure is: repositories have templates.  Templates are applicabe to
runtimes.  Therefore the correct API is to have templates a direct
member of repository but requiring a runtime filter for access.

- Use repository templates path instead of full list

The goal is to support the use of repositories which contain more than
just templates.  The solution is to define an alternate location for
templates (such as ./templates).  Creating an entire exhaustive manifest
where each runtime and each template is defined with a name and path is
a usurpation of the responsibilities of a filesystem, and causes
unintend negative knock-on effects.  Let's try this simple solution
before jumping to the nuclear option of defining a filesystem-in-yaml.

- Use filesystems when loading repository objects

The fact that a file exists on the disk, embedded, or remote should be
of no concern to most of the code.  This is accomplished by using the
filesystem abstraction which is used during template writing.  This will
be further improved in future versions by upgrading to use the fs.FS
interface and tooling.

- Uses manifest.yaml at all levels

Once the hierarchical nature of the manifest was instituted, it seemed
more intuitive to have the same filename at each level.  This also has
the nice benefit of being backwards-compatible with template-level
manifest.  This is not a correctness issue, but a guess that remembering
a single filename which can exist at different levels in a hierarchy is
easier to remember than different filenames, and its location in the
hierearchy sufficient differentiator making the different filenames
_perhaps_ unencssary.  The constants are left as separate for an easy
revert.

- Moves static defaults into code wherever possible

Wherever yaml was being statically compiled in, it was updated such that
canonical values for static defaults were defined on the Go structure,
with the yaml being for overrides.  For example Default Readiness and
Liveness endpoints.

Some notable benefits of letting the filesystem do it's thing:
* Preserves the ability to create a repository of templates without
  hacking yaml
* Reflects changes directly in IDEs which have native support for
  filesystem, not so for a proprietary manifest.yaml
* the builtin repository has no name, so parsing a manifest from within
  it is both prone to error and confusing, as it could lead future
  developers to submit PRs which change its name.

* fix: revert repository.git to a bare server repo

* src: repository default name

The Repository struct now includes a Name and DefaultName. The former is
the current name of the repository, and corresponds to the path on disk.
The latter is the name specified in the manifest.yaml, and is used as
the default name of the repository when no name is provided.

Fixes an issue where there could be name collisions using a uuid for the
initial name until the manifest is read in.

Restructures the embedded repositories such that one exemplifies a base
case repo with no metadata and only templates, the other specifying a
manifest to exemplify for example a complete language pack.

Adds a test such that all three cases are covered: explicit name, no
name but manifest-defined default name, URI-derived name.

* feat: single repo mode

Enables single repository mode suystem-wide, which fully implements the
logic intended by the WithRepository option.

The default repoisitory is now programatically defined, and while by
default is the embedded repo, it can be overriden using the
WithRepository option.  This keeps the logic internal to the
repositories managet, removeing the need for a crossp-cutting concern in
other parts of the system.

* src: manifest inheritance and existence tests

Respects alternate templates location when defined in a manifest.
Respects manifest embedded structs HealthEndpoints and BuildConfig at
each of the three levels, with inheritance:  Repo, Runtime and Template.
Separates test repositories into the two cases of a templates-only repo
(with no manifest) and a complex repo (with manifests) such as for
language packs.
Leaves the BuildConfig struct as inline but sets the HealthEndpoints as
being named, such that the latter has its fields in the yaml under the
key 'healthEndpoints' but the former does not (passthrough).
Adds error checks when attempting to access named repo when in
single-repo mode.

* src: remove function merge

Removes feature of mergine a func.yaml defined in a template in favor of
sticking with the manifest.yaml until such time as this is requested.
Assuming YAGNI.

* src: repo filesystems

- Embeds repositories with an internal filesystem
- Replaces filesystem disk checkouts with in-memory until final write
- Combines template Write of various types into a single write which uses the
  filesystem of the applicable templates's repository
- Template is now a simple noun, with logic localized to the templates manager
- Adds better error message regarding single repo mode conditions

The reason for replacing filesystem-based repository instances with in-memory
(especially remote for WithRepository mode) is for a few reasons:  First, 'Add'
will fail without using the temporary UUID hack if there already exists a
repository of the _repo_ name (due to a filesystem collision).  We have
to read the repo to determine the default name as well, so it's messy to avoid.
Second, using an on-disk version is potentially leaky because it may leave
files on the system in the event of a process interruption; able to be
mitigated, but with a likewise hacky use of a os temp directory.  Third, it
may cause racing conditions when using multiple instances the Client as a lib.
Lastly, it precludes our ability to run without touching the filesystm: a
useful mode when running as a pure library or in security-restricted
environments.

* fix: paths within embedded fs

* src: repositories code cleanup

* Removes the manual 0_18 version suffix
* Reanames "single" (uri for single-mode) to the more descriptive
  "remote" (with associated accessor api)
* Default repo name when no URI provided is set to default
* Various wording improvements in error text and comments

* src: error formatting

* feat: templates from local file paths

Adds back the local os filesystem as a fallthrough to support loading
template repositories from file:// paths on disk, without the
requirement that they also be git repositories.

* fix: clone once

Fixes the shortcut of performing a clone to read the manifest prior to
cloning the repository to disk.  This double-clone was replaced by a
single clone (applying the manifest) followed by a file copy from the
in-memory FS to the on-disk repository location.

* src: test fixes

* respect explict name on repository .Add
* fail if repository already exists
* update expected test filenames to new general (non-go-specific) setup
* adds the default repo name to the NewRepository constructor,
  internalizing the somewhat tricky default logic.
* move repo write logig to repo itself, as it will contain impl-specific
  nuances.
* invalid repo path is an error, but only if defined
* temporarily disable repository URL test

* src: update templates test to reflect new name 'cloudevents'

* src: fix go templates and repackage

* fixup: reviewdog spelling errors

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

* fixup: reviewdog whitespace cleanup

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

* fixup: run ./hack/update-codegen.sh

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

* fixup: restore boson-project templates for e2e

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

* fixup: do not error if default repo location does not exist

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

* fixup: typo

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

* paketo builder and paket community rust buildpack (#599)

* fixup: apply f161d50084

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

* fixup: update documentation to match impl

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

* fixup: add git attributes to ignore linting on binary files

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

* fixup: remove whitespace

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

* fixup: tweak linter rules

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

* fixup: tweak .gitattributes

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

Co-authored-by: Luke Kingland <lkingland2038@gmail.com>
Co-authored-by: Shashankft9 <48708039+Shashankft9@users.noreply.github.com>
2021-10-27 07:09:01 -07:00
salaboy cf9596c83e
feat: validation for registry/namespace to not contain image name (#601)
* initial validation for registry/namespace to not contain image name

* Update function.go

* supporting nested namespace
2021-10-26 11:13:21 -07:00
knative-automation cd45b6c007
Format go code (#589)
Signed-off-by: Knative Automation <automation@knative.team>
2021-10-18 10:08:22 +02:00
Lance Ball 68b0904b17
feat!: rename event templates to 'cloudevents' (#584)
* feat!: rename event templates to 'cloudevents'

This commit renames the templates for cloudevents to be named "cloudevents".

BREAKING CHANGE

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

* fixup: update commands.md doc

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

* fixup: fix make test-templates

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

* fixup: missed an e2e test change

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

* fixup: gitignore and pkged.go

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

* fixup: adjust Makefile recipe for pkged.go

Signed-off-by: Lance Ball <lball@redhat.com>
2021-10-13 14:19:42 -07:00
Fabian Lopez d2ee140cee
Detect and report unreachable image deployment (#579)
* detect and report unreachable image deployment

* change error message for private images

Co-authored-by: Lance Ball <lball@redhat.com>

Co-authored-by: Lance Ball <lball@redhat.com>
2021-10-13 06:43:48 -07: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
Lance Ball eccc0ad368
chore: improve messaging in func build (#562)
Fixes: https://github.com/knative-sandbox/kn-plugin-func/issues/552

Signed-off-by: Lance Ball <lball@redhat.com>
2021-10-07 06:41:36 -07:00
Fabian Lopez 62b21f0536
avoid unintentional image/registry overwrite (#551) 2021-09-24 05:43:23 -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
Matej Vasek 4236ba9287
Better credentials handling (#526)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-09-16 02:57:39 -07:00
Luke Kingland 90c60b693d
fix: removal of repositories (#524) 2021-09-15 06:48:08 -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
Lance Ball 71368c6a1d
chore: update files with goimport (#513)
* chore: update files with goimport

This should get https://github.com/knative-sandbox/kn-plugin-func/pull/509
happy and green.

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

* fixup: remove extraneous print statements

Signed-off-by: Lance Ball <lball@redhat.com>
2021-09-08 06:53:45 -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 77b019213a
chore: fix typo in `build` help message (#503)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-09-02 04:50:06 -07:00
Senthilnathan M 2ae3e46346
Minor fix in the help doc (#500) 2021-08-30 23:57:55 -07:00
Matej Vasek f7c55cb42e
test: add test for listing labels (#494)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-08-26 04:03:31 -07:00
Matej Vasek f2efbe5b42
fix: `config labels` panic (#493)
During refactor flag registration was unintentionally removed.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-08-25 05:32:25 -07:00
Lance Ball a4b15ad992
feat: move go, typescript and nodejs to paketo builders (#485)
This commit removes the Red Hat builders from the built in templates
for Go, TypeScript and Node.js, replacing them with paketo builders.
For Go, the builder is augmented with a simple buildpack that installs
the Go wrapper code and its dependencies. For TypeScript, the paketo
buildpacks oddly don't support an `npm build` step, so these templates
are also dependent on a small Boson buildpack. These buildpacks are
currently at https://github.com/lance/boson-buildpacks but should find
a home either in the boson-project organization, or the knative-sandbox
organization.

This change also slightly modifies how the Node.js and TypeScript
templates are structured, reducing the coupling between the buildpack
and a function project.

This commit includes the code in https://github.com/knative-sandbox/kn-plugin-func/pull/465
and is dependent on it in the use of manifest.yaml.

Provide sane defaults for health endpoints

Note that this will need to be documented as a requirement for
language packs that do not wish to provide explicit endpoints for
these kube health checks. In that case, the language pack should
specify these both as the root path, with a query parameter. For
example, `/?health=readiness` and `/?health=liveness`, or some other
similar construct.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-08-24 08:46:24 -07:00
jrangelramos 4b5d7365ac
doc: fix create command help message description (#486) 2021-08-20 00:35:06 -07:00
jrangelramos 10145aab29
style: create command output formatting for repository option (#487) 2021-08-19 14:13:05 -07:00
Lance Ball 10a07578e9
feat!: change `describe` command to `info` (#474)
The describe command conflicts sematically with kubectl describe.
This commit changes the command name to `info`.

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

Signed-off-by: Lance Ball <lball@redhat.com>
2021-08-15 21:43:54 -07:00
Matej Vasek 84ff281bed
test: `config` sub-command (#457)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-08-12 06:30:35 -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
Matej Vasek 79e2234cbc
fix: hide progress indicator if asking for creds (#458)
* fix: hide progress indicator if asking for creds

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

* fix: NPE in integration test

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-08-05 10:41:52 -07:00
Luke Kingland 9db1a3d902
feat: remote template repositories (#437)
* feat: remote template repositories

* Update cmd/create.go

Co-authored-by: Lance Ball <lball@redhat.com>

* docs: extensible templates

* feat: remote template repositories

* Update docs/guides/language-packs.md

* Update docs/guides/language-packs.md

Co-authored-by: Lance Ball <lball@redhat.com>

* Update docs/guides/language-packs.md

Co-authored-by: Lance Ball <lball@redhat.com>

* Update docs/guides/templates.md

Co-authored-by: Lance Ball <lball@redhat.com>

Co-authored-by: Lance Ball <lball@redhat.com>
2021-08-03 06:28:15 -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 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 4222e34aa6
src: test create command validates name 2021-06-24 21:08:06 +09:00
Luke Kingland 1591fa6759
src: refactor create command to be testable 2021-06-24 21:08:06 +09:00
Luke Kingland 5ded87368b
src: rename bosonFunc fn 2021-06-22 23:08:11 +09:00
Zbynek Roubalik 6f96011d7c
src: `create`- use Select for specifying runtime in interactive mode (#399)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-06-21 17:11:35 -04:00
Matej Vasek 88ea081cc0
fix: use credsStore
use credsStore when searching for credentials

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-06-21 15:51:56 +02:00
Zbynek Roubalik 7a24a103ef
src: refactor prompt to use `AlecAivazis/survey` (#397)
* src: refactor prompt to use `AlecAivazis/survey`

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-06-21 08:38:26 +02:00
Zbynek Roubalik 83a9ca684f
feat: `func config envs` - interactive prompt (#396)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-06-21 08:37:48 +02: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
Zbynek Roubalik 54f60a2552
src: validate Env Var name (#395)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-06-18 09:12:45 +02:00
Zbynek Roubalik 4ba95b69a8
feat: `func config volumes` - interactive prompt (#391)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-06-17 09:21:07 +02:00
Matej Vasek 84f896b329
fix: password read on windows
* fix: password read on windows

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-06-16 04:18:40 +02:00
Luke Kingland 8041a25486
extensible repositories flag (#384)
The flag pointing to extensible template repositories is now called
repositories.  This fits with the expectation that this location
will most likely be filled with git repositories containing templates.
2021-06-14 14:57:05 -04:00
Luke Kingland 2147f97ba2
use 'a' for 'additional packages' parameter --packages 2021-06-10 22:42:53 +09:00
Lance Ball ce29ff6285
refactor!: change --trigger and --templates flags
This commit is a breaking change.

Change the `--trigger` flag to be `--template` and the `--templates` flag
to be `--packages`. This is being done in anticipation of future work focused
on making `func` extensibility friendlier, and in an attempt to finalized some
of the naming conventions we have used to date.

In fact, the `--trigger` flag used to be `--template` but we decided to
change that a few months ago. This commit reverses that decision. The reason
behind this is twofold.

1. Using 'trigger' has proved to be confusing. Even if I create a function
with an HTTP trigger, it will still be invoked when a CloudEvent is sent
to the function process. Or alternatively, it is possible to send a raw
HTTP request to a function with an event trigger. Using 'template' instead
implies that the incoming request does not determine how the function is
invoked - rather it is the structure of the function signature that informs
the invocation.

2. The `trigger` terminology is not inclusive enough for our use cases. For
example, a third party provider of function templates may provide a template
for multiplexing incoming HTTP requests in Go using `gorilla-mux`. It doesn't
really make sense to say that `gorilla-mux` is the trigger. It's just a
defining feature of how the template is structured. I think this:

```sh
func create --runtime go --template gorilla-mux
```

Makes more sense than this:

```sh
func create --runtime go --trigger gorilla-mux
```

In changing this flag to be `--template`, we then need to come up with
another name for our existing `--templates` flag. I chose `--packages`
because what is being specified here is more than just the template. The
user sees only the function template when they run `func create...` but
the filesystem from which this template is pulled also contains metadata
about the template - most importantly right now, `.builders.yaml`. It is
conceivable that we may ultimately want to stuff these directories with
event more metadata in the future.

Something like `--packages` makes sense to me, but I am open to suggestion.

Thinking of these as a package also allows for better extensibility features
down the road. For example, users could reference packages at a URI like so.

```
func create --packages https://mycompany.com/function/templates.tgz
```

This would result in `func` downloading the tarball, extracting it to the
config directory, and using it for additional templates.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-06-09 21:33:21 +09:00
Luke Kingland b30e883e67
refactor!: function signatures implied from trigger
Renames trigger to template, removing it as an unnecessary configuration.
This reiterates that a Function implementation can change function sig
implemented at any time, and it is not part of the configuration.  This
sets the stage for renaming 'templates', and the finalization of the
use cases enabling extensible templates.
2021-06-09 21:18:55 +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
Zbynek Roubalik 4f0641f586
chore: bump Knative deps to 0.22.0 (#368)
* chore: bump Knative deps to 0.22.0

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-06-01 16:29:41 +02:00
Lance Ball 72584ced0d
fix: Revert "chore: bump Knative deps to 0.22.0 (#358)" (#366)
This reverts commit 27f62066ee.
2021-05-27 16:18:33 -04:00
Zbynek Roubalik 27f62066ee
chore: bump Knative deps to 0.22.0 (#358)
* chore: bump Knative deps to 0.22.0

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

* update to Knative 0.22.0

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-05-25 15:05:05 +02:00
Lance Ball 2a0724083b
src: fail fast with conflicting flags (#348)
Signed-off-by: Lance Ball <lball@redhat.com>
2021-05-17 08:41:44 -04:00
Lance Ball 49594d9766
feat: add 'kn func emit' command (#332)
This commit adds an Emitter to be used by the CLI commands
for sending CloudEvents to functions, either locally, on
the cluster, or at a specified endpoint.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-05-13 12:44:11 -04:00
Matej Vasek a74e3dd5e8
src: update CLI help for env flag
Update CLI help for env flag. Now mentioning unsetting of variable.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-05-13 16:19:22 +02:00
Matej Vasek a72a9a858a
src: add tests
Tests for mergeEnvMaps.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-05-13 15:01:33 +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
Jefferson Ramos 94e387c932 fix: added checks on delete command test for lint 2021-05-11 13:05:57 -03:00
Matej Vasek 5a3d385432 add tests for delete cmd
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-05-10 21:22:11 +02:00
Jefferson Ramos 8ab0ba243a fix: func delete with explicity name as argument (#323) with strict validation 2021-05-10 13:38:19 -03:00
Luke Kingland c0a6f561c0
src: rename boson import 'fn' 2021-05-07 14:17:14 +09:00
Matej Vasek 18cb0f4652
src: update knative deps to 0.21.0
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-05-05 17:20:32 +02: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
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 06455f4bac
fix: default for `--builder` flag
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-04-22 15:44:15 +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
Matej Vasek dc2fbee67f
fix: `func deploy` uses Docker API, not binary
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-03-22 15:18:03 +01:00
Luke Kingland 8a91cac6cc
feat: add --build (default: true) flag to func deploy 2021-03-16 15:29:36 +09: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
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
Lance Ball 5a3a0d6bda
fix: fix the help text for the describe function (#243)
That must have been a copy/paste error.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-12-10 12:10:52 +01:00
Kamesh Sampath 557361a374
feat: add spring cloud function runtime and templates (#231)
* feat: add spring cloud function runtime and templates

* docs: review updates

* squash: apply suggestions from code review

Co-authored-by: Lance Ball <lball@redhat.com>
2020-11-25 12:15:48 -05: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
Matej Vasek d5624980d5
fix: `delete` and `deploy sub-commands respects func.yaml conf 2020-11-06 17:19:10 +01: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
Luke K 57e12362af
feat!: remove create cli subcommand (#180) 2020-11-06 17:08:49 +09:00
Zbynek Roubalik ddbb95b075
feat: Better output of build/deploy/delete commands (#206)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-11-05 16:46:21 +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 61cb56aec3
feat: change default runtime to Node.js HTTP (#198)
Fixes: https://github.com/boson-project/faas/issues/191

Signed-off-by: Lance Ball <lball@redhat.com>
2020-11-02 09:27:31 -05:00
Zbynek Roubalik 551331925a
chore: tweak output & verbose messages (#173)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-10-15 19:00:28 +02:00
Zbynek Roubalik 68351bd0ec
src: use Knative Client libraries (#167)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-10-14 10:42:26 +02: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
Zbynek Roubalik 2c7c18dd9b
chore: commands are checking that Function is initialized (#162)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-10-08 15:32:46 +02: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 d82230353d
feat: fish completion 2020-10-06 15:39:07 +02:00
Matej Vasek bf9b048813
fix: stop using manually edited completion 2020-10-05 22:06:49 +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
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 d6e131f915
feat: set builder images in templates and .faas.yaml (#136)
This commit adds a .builder.yaml file to each template directory. In the file
there is at the moment a single key/value pair, "default: <image>", where the
actual builder image name is <image>. Using a mapping allows the future
possibility that a user may specify a builder image by name via a flag on the
command line. For example,

```console
faas build --builder native
```

When a project is initialized, the .builder.yaml file is read, and the default
builder is saved in the project's .faas.yaml file. The .faas.yaml file is then
consulted when building an image with `faas build`. If the builder image is
specified, then the builder will use it. Otherwise, it will fallback to the
defaults. This allows developers to create custom builders, and specify them
in the configuration file.

After extracting the builder image from .builder.yaml in the project directory,
this file is deleted.

This commit also adds Verbose to the init command.
2020-09-24 11:41:34 -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
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 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
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
Matej Vasek 284b77f7ef fix: delete command
There was hard-coded `faas` namespace.
2020-09-10 10:06:20 -04:00
Luke K ce48083a10
fix: remove references to unused binaries appsody, kn, kubectl 2020-09-04 23:08:03 +09:00
Matej Vasek 91172ef0b1
fix: image override (#88) 2020-09-02 08:37:17 -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
Luke K 2fcbe740e9
fix: default k8s namespace to 'faas' per documentation 2020-08-29 01:52:56 +09:00
Matej Vasek fbab8c09d0
feat: the `list` sub-command uses namespace 2020-08-24 14:08:25 +02:00
lkingland 4c3a276c2f
feat: version command respects verbose flag (#61) 2020-08-13 17:05:59 -04:00
Lance Ball 5b4d97a443
feat: add init/build/deploy commands and customizable namespace (#65)
* feat: add init/build/deploy commands and customizable namespace

This commit comprises some fairly large changes in the codebase.
The 'create' command has been extracted into 'init', 'bulid' and
'deploy' commands. The 'create' command remains, but now delegates
most of its work to these other three. This also has resulted in
some rework of the various flags. 

In addition, it is now possible to specify the cluster namespace to
which the function will be deployed.
2020-08-12 10:52:50 -04:00
Matej Vasek 17a00c9057
feat: JSON output for the `list` sub-command 2020-08-11 15:25:33 +02:00
Matej Vasek 4677b3452f
chore: add lint to GH actions CI 2020-07-29 17:47:08 +02:00