Commit Graph

59 Commits

Author SHA1 Message Date
David Simansky e0bbcc2d08
chore: Refactor use of deprecated io/ioutil package (#1285) 2022-09-27 13:28:15 +00:00
salaboy fe0368a793
[feat] refactoring func.yaml struct to match cmd lifecycle (#1254)
* 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
2022-09-22 20:22:12 +00:00
Matej Vasek 2988f0c06b
fix: nil deref when custom builder image (#1273)
Signed-off-by: Matej Vasek <mvasek@redhat.com>

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-09-22 13:00:12 +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
Gab Satchi 7e96146840
Adds labels and annotations from func.yaml to pipeline resources (#1205)
* adds labels from func.yaml to pipeline resources

* Unify function labels across resources (kService and tekton pipelines)

* Adds function annotations to pipeline resources

* Remove refactored function
2022-09-09 12:48:25 +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
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
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
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
Lance Ball 416ada6715
feat!: change 'version' to 'specVersion' (#1086)
* feat!: change 'version' to 'specVersion'

Changes `func create` to write the last migration value to func.yaml
when a new function is created, and modifies the name in the func.yaml
file to be 'specVersion' instead of 'version' to help reduce confusion.

Adds a migration, and a LastMigration() utility function.

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

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

* fixup: remove DefaultVersion

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

* fixup: review feedback

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

* fixup: review feedback

Signed-off-by: Lance Ball <lball@redhat.com>
2022-07-01 09:22:45 +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 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 096085d751
feat: configurable s2i builder images (#1024)
adds support for the builderImages func.yaml attribute
2022-06-01 06:12:02 +09:00
Luke Kingland 14248311b1
feat: s2i builder env var interpolation (#991)
* feat: s2i builder env var interpolation

* nil env values disinclude from interpolate map
2022-04-25 19:18:54 +00:00
Matej Vasek e502d554c8
Refactor: clean Repository and Runtimes structs (#973)
* Refactor: clean Repository and Runtimes structs

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

* Refactor: rename struct member

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-04-18 23:14:28 +00:00
Zbynek Roubalik 1f54bdcb1c
src: fix `func.yaml` schema (#805)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2022-02-01 18:05:32 -08:00
Luke Kingland e918f74b9e
feat!: invoke (#705)
* feat!: rename 'emit' to 'invoke' and default to local

This commit renames 'func emit' command to 'func invoke' and makes the
default behavior to send an event to localhost. The special '--sink'
value 'local' is changed to 'cluster' to indicate that the function
should be invoked on the cluster instead of locally. All other behavior
has remained the same.

BREAKING CHANGE

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

* fixup: update commands.md doc

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

* squash: change Emitter interface to Invoker

Changes Emit() to Send() in the (now named) Invoker interface, and changes
Emit() to Invoke() in the client.

BREAKING CHANGE

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

* squash: use a common Invoker interface for HTTP and events

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

* checkpoint

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

* fixup: change Emitter to EventInvoker

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

* Invoke v2 Draft

* feat: client invoke function

* static invoke defaults and methods

* remove assimilated invoker package

* includes an ignored .func directory on create

* Instances manager with local and remote defaults

Funciton Info is now Instance, representing a Function in a given
environment.

Describing a Function instance is now Instances().Get(f, environment)

Moves Runner to be async with a Stop method to enable returning runtime pid
and port for persisting.

Instances now have a place for primary Route in addition to all routes slice

Running Functions write PID and Port to .func

* cascading targets: local vs remote vs ad-hoc endpoint

* runner start signals and cancel cleanup

* return run on context done or err on channel

* async runner

Refactors the image runner to start the container asynchronously,
reporting back the port on which it started.  Errors are communicated
back via a provided channel and stop is signaled using context
cancelation.

* pid neither required nor available

* add withTransport option

Incorporates addition of custom transport of the emitter into the
renamed version invoker. Flag and help text cleanup.  Re-additionof the
Info accessor.

* schema now includes invocation data

* loop build msg

* run jobs

Externally exposed port is now chosen based on availability, with 8080
preferred and falling back to an os-chosen open port.
The Client Run method is now async, returning the port assigned to the
running Function, a stop/cleanup function and a runtime errors channel.
The Runner is internally divided into the runner and its started Jobs.

* job metadata

Extracts job metadata tracking to a Job object in the core,
Handles multiple instances of the same Function by creating a single
file for each instances in .func/instances/<port>

* remove superfluous error types and flag bindings

* feat: enable invoke target remote

* feat: preferentially invoke local, remote if running

* feat: read --file for invoke

* feat: invoke confirm prompts

* fixup cli tests

- Updates to handle asynchronous Runner
- Standardize on the naming convention for selective running

* docker runner tests and lint errors

* test refactor

* feat: invoke format override

* comments, spelling and other cleanup

* invoke command doc

* feat: invoke format interactive option

* rename runjob.go to job.go

* e2e test flag update

* test naming homoginization

* silence build activity messages when verbose

* test debugging

* code review updates

- return Job from Client.Run rather than constituent members
- Treat .gitignore as contentious, punting on feature to mutate if
  extant.
- docs wording changes
- add invocation format to pertinent manifest.yaml files

* help text spelling etc.

Co-authored-by: Lance Ball <lball@redhat.com>
2022-01-21 12:04:05 -08:00
Zbynek Roubalik 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
Luke Kingland ccf00152be
feat: function version migrations (#664)
* feat: function version migrations

* unmarshall functin now part of initialization

* regenerate schema

* spelling errors
2021-11-24 04:50: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
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
Preetham 114a5faee3
feat: allow developers to provide Build Envs to buildpacks in `func.yaml` (#571)
* Enhance func.yaml to provide build envs to buildpacks

* Add schema file deleted by make clean

* Add function ValidateBuildEnvs to config.go

* Addressed review comments

* Revert makefile changes to pkged.go

* Fixed buildpack env update lost in rebase

* Add support for local env in buildEnvs
2021-10-16 00:54:23 -07:00
Zbynek Roubalik 8aba038073
fix: `build` should honor registry specified in `-r` (#510)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-09-08 17:23:58 -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
Lance Ball 48f40c35e3
feat: allow language packs to set function metadata (#465)
This commit introduces the concept of a `manifest.yaml` file which
can be added to each template directory to specify things such as health
endpoints, builders and buildpacks for the function.

It problematic that, because we don't yet have the concept
of a global configuration file, the only place to store this metadata is
in a project's `func.yaml` file. There is no reason a function dev
should be exposed to things like health endpoints. This information is
determined by the language pack and integrated by the builder. The only
reason we need it is that it's necessary to determine these endpoints when
deploying. Otherwise, we would have to insist that all language packs
provide endpoints at `/health/readiness` and `/health/liveness`.

This commit also adds support for a `buildpacks` property in `manifest.yaml`
which will be used to set the buildpacks when a function is being built.

Signed-off-by: Lance Ball <lball@redhat.com>
2021-08-22 09:00:34 -07:00
Luke Kingland 844e99bfd5
src: template tests use public api (#473)
* src: client tests now use public api

* Update templates_test.go

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

* Update templates_test.go

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

* Update templates_test.go

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

* Update templates_test.go

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

* Update templates_test.go

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

* Update templates_test.go

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

* Update templates_test.go

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

Co-authored-by: Lance Ball <lball@redhat.com>
2021-08-16 09:14:54 -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
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
Zbynek Roubalik a937c490b7
feat: allow setting autoscaling options to deployed KService (#374)
* feat: allow setting autoscaling options to deployed KService

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

* incorporate feedback

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

* move `target` & `utilization` to `scale` section

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

* don't include concurrency.limit

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2021-06-15 09:26:36 +02: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
Lance Ball 2b025df199
src!: revert bump to go 1.16 and template changes (#340)
* Revert "src: rename boson import 'fn'"

This reverts commit c0a6f561c0.

* Revert "src: all test dirs set to 0700"

This reverts commit 99f01220c2.

* Revert "src: better error when custom template not found"

This reverts commit 6673395834.

* Revert "src: better errors when custom runtime not found"

This reverts commit a31a6f67a1.

* Revert "build: create separate target for templates.tgz"

This reverts commit 11164bf8d9.

* Revert "src: use consistent separators for fs.FS instances"

This reverts commit 4db07b412f.

* Revert "src: update go event template dependencies"

This reverts commit 3bfc13380f.

* Revert "src: tarfs assumes forward slashes internally"

This reverts commit 6cc0e67b1c.

* Revert "feat: support windows paths in embedded templates FS"

This reverts commit c2b216857b.

* Revert "feat: positive error when runtimme or template unrecognized"

This reverts commit acc56b0900.

* Revert "fix: lint issues"

This reverts commit 895872aee7.

* Revert "ci: go 1.16 compatiblity updates"

This reverts commit 1e3959c045.

* Revert "feat: preserve file modes using in-memory tar FS"

This reverts commit 7dc772ec62.

* Revert "feat: create templates archive on go generate"

This reverts commit 63b7f11471.

* Revert "ci: remove pkger from ci"

This reverts commit 876b0dd0f7.

* Revert "src: remove pkger dependency and tidy"

This reverts commit f006ab1e32.

* Revert "src: remove packaging artifact"

This reverts commit 4d9d0a7b4e.

* Revert "src: remove pkger from make targets"

This reverts commit e44c1ad74c.

* Revert "src: replace pkger with embed.FS"

This reverts commit 38874a4afd.

* Revert "src: update references to deprecated ioutil"

This reverts commit 4025460f73.

* Revert "src: require go 1.16"

This reverts commit 512d4c2580.

* chore: update pkged.go

Signed-off-by: Lance Ball <lball@redhat.com>
2021-05-12 14:37:21 -04:00
Luke Kingland 4025460f73
src: update references to deprecated ioutil 2021-05-07 14:00:46 +09:00
Lance Ball 5feb0e20f3
feat: add support for annotations in func.yaml (#314)
This commit adds limited support for annotations in the func.yaml
config file. The feature is limited, because it's only additive. A
user can add an annotation `foo: bar` in the config and deploy the
function, successfully setting that annotation on the Service.
However, if they subsequently remove `foo: bar` from the config
file, it will _not_ be removed from the deployment. This is because
it's not possible to know, from the set of annotations that currently
exist on the deployment, which ones were set by us and which were not.
So, removing any annotations that are not in func.yaml is unsafe.

It may be possible to store in a hidden file somewhere all of the
user-supplied annotations, allowing us to diff func.yaml with that file,
but I'm not sure I want to go down that path. It might just be best to
document this limitation.

We may also want to document that annotations added through func.yaml
should be user supplied settings/values, and not annotations that are
managed by knative (e.g. the autoscaling annotations).

Fixes: https://github.com/boson-project/func/issues/307

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-28 13:59:03 -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
Luke Kingland 8a91cac6cc
feat: add --build (default: true) flag to func deploy 2021-03-16 15:29:36 +09: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
Matej Vasek 6a621a5186
fix: image parsing 2020-10-20 19:54:33 +02:00
Zbynek Roubalik 00e5d187c2
src: use image digest (#175)
Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-10-19 11:43:50 +02:00
Matej Vasek 5182487df2
feat: user can set envvars 2020-10-13 14:11:06 +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 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 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
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
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