* 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>
* rebased and updated func struct
* fixing migration to 1.0.0 struct
* fixing on cluster tests
* updaating migration version to 0.34.0
* adding tests for marshalling and migration errors
* adding EOF new line
* updating migrations
* fixing wrong name
* fixing marshalling test
* adding EOF line
* fixing assertion
* feat: deploy autobuild and flag persistence
* cleanup
* help text, comments and test cleanup
* removing usurped commands.txt
* add platform to deploy synopsis help
* 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
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>
* 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
* 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
* 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
* 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
* --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
* 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>
* spelling
* feat: full build options on deploy
* increase e2e lifecycle test timeout to 45m
* remove redundant flag shorthand b
* map flags for parsing
* 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
* 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.
* 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
* 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>
* 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>
* 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>
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>
* 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
* 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>
* 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
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>
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>
* 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
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>
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
```
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
* 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.