Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/commands/func-pull-reguest.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Analyze the git commits on the current branch since it diverged from the main br

4. Format the PR description using the template in `.github/pull-request-template.md` and do the following:
- Add a PR title in a comment above `# Changes` like so: `<!-- PR Title: <pull-request-title> -->`.
- Use correct English capitalization and grammar for the PR title.
- Replace `<pull-request-title>` with the actual title.
- Use correct English capitalization and grammar for the PR title.
- Replace `<pull-request-title>` with the actual title.
- Update the "Changes" section with bullet points using appropriate emoji: :gift: :bug: :broom: :wastebasket:.
- Add a /kind label
- Add "Fixes #" if issue is referenced or "Relates to #" if issue is not supposed to be closed by this PR.
Expand Down
12 changes: 6 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ edge cases into account.

Before committing, test locally following the table below:

| If changed | Target | Description |
|------------|--------|-------------|
| `*.go` files | `make test` | Core unit tests |
| Any files | `make check` | Linting, formatting, spelling |
| `templates/` files | `make test-templates` | All language template tests |
| Significant architectural changes | `make test-full` | e2e tests (cluster required - read `CONTRIBUTING.md`) |
| If changed | Target | Description |
| --------------------------------- | --------------------- | ----------------------------------------------------- |
| `*.go` files | `make test` | Core unit tests |
| Any files | `make check` | Linting, formatting, spelling |
| `templates/` files | `make test-templates` | All language template tests |
| Significant architectural changes | `make test-full` | e2e tests (cluster required - read `CONTRIBUTING.md`) |

### Generated Files

Expand Down
53 changes: 27 additions & 26 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ client.Build(ctx, f)

When exploring the codebase, search for these:

| Term | Where | What it does |
|------|-------|--------------|
| `fn.Client` | `pkg/functions/client.go` | Main client type for all operations |
| `NewClient` | `cmd/client.go` | Creates fully-configured client |
| `ClientFactory` | `cmd/root.go` | Function type for client creation |
| `Builder` | `pkg/functions/client.go` | Interface for function builders |
| `Deployer` | `pkg/functions/client.go` | Interface for function deployers |
| `Function` | `pkg/functions/function.go` | Type representing a function |
| Term | Where | What it does |
| --------------- | --------------------------- | ----------------------------------- |
| `fn.Client` | `pkg/functions/client.go` | Main client type for all operations |
| `NewClient` | `cmd/client.go` | Creates fully-configured client |
| `ClientFactory` | `cmd/root.go` | Function type for client creation |
| `Builder` | `pkg/functions/client.go` | Interface for function builders |
| `Deployer` | `pkg/functions/client.go` | Interface for function deployers |
| `Function` | `pkg/functions/function.go` | Type representing a function |

## Layer Architecture

Expand Down Expand Up @@ -104,6 +104,7 @@ flowchart TB
### Builders

Implement the `Builder` interface (source → OCI image):

- `pkg/buildpacks/`: Cloud Native Buildpacks via Pack
- `pkg/s2i/`: Red Hat Source-to-Image
- `pkg/oci/`: Direct OCI image building on host
Expand Down Expand Up @@ -135,29 +136,29 @@ flowchart LR
end
```

| Stage | Client Method | Description |
|-------|---------------|-------------|
| Create | `Init()` | Create boilerplate project from template |
| Scaffold | `Scaffold()` | Scaffold project as a service|
| Build | `Build()` | Produce OCI image via Builder |
| Deploy | `Deploy()` | Push image, create K8s/Knative Service |
| Run | `Run()` | Local execution for development |
| Invoke | `Invoke()` | Send request to deployed function |
| Stage | Client Method | Description |
| -------- | ------------- | ---------------------------------------- |
| Create | `Init()` | Create boilerplate project from template |
| Scaffold | `Scaffold()` | Scaffold project as a service |
| Build | `Build()` | Produce OCI image via Builder |
| Deploy | `Deploy()` | Push image, create K8s/Knative Service |
| Run | `Run()` | Local execution for development |
| Invoke | `Invoke()` | Send request to deployed function |

## Key Interfaces

Defined in `pkg/functions/client.go`:

| Interface | Purpose |
|-----------|---------|
| `Builder` | Source → OCI image |
| `Pusher` | Image → Registry |
| `Deployer` | Image → Service on K8s |
| `Runner` | Local execution |
| `Remover` | Delete deployed function |
| `Lister` | List deployed functions |
| `Describer` | Describe function instances |
| `PipelinesProvider` | Remote build orchestration |
| Interface | Purpose |
| ------------------- | --------------------------- |
| `Builder` | Source → OCI image |
| `Pusher` | Image → Registry |
| `Deployer` | Image → Service on K8s |
| `Runner` | Local execution |
| `Remover` | Delete deployed function |
| `Lister` | List deployed functions |
| `Describer` | Describe function instances |
| `PipelinesProvider` | Remote build orchestration |

## Subsystems

Expand Down
22 changes: 9 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PR descriptions concise with a high signal-to-noise ratio. If you would like
to contribute to this project please keep this in mind.

An opened PR should include:

- basic explanation why it is needed (what problem does it solve or what feature does it add? is this something you need or a problem you've encountered?)
- explanation of what testing was performed to make sure this change fixes the problem (did you test manually? what tests did you add? what do they cover?)
- must include tests for new code; regression test for bug fixes
Expand All @@ -28,7 +29,8 @@ there is an override directive which points the AI agent to instead read this
that it is not source controlled.

## General information
This document details how to get started contributing to the project. This includes building and testing the core, templates and how to update them, and usage of the optional integration testing tooling.

This document details how to get started contributing to the project. This includes building and testing the core, templates and how to update them, and usage of the optional integration testing tooling.

**Tip**:
Install git hooks that do basic pre-commit checks.
Expand All @@ -42,7 +44,7 @@ Read through our [architecture](ARCHITECTURE.md) file for how we structure this

## Building

To build the core project, run `make` from the repository root. This will result in a `func` binary being generated. Run `make help` for additional targets and `./func help` for usage-centric documentation.
To build the core project, run `make` from the repository root. This will result in a `func` binary being generated. Run `make help` for additional targets and `./func help` for usage-centric documentation.

To remove built artifacts, use `make clean`.

Expand All @@ -60,11 +62,11 @@ uploads coverage when the secret is present.

## Linting

Before submitting code in a Pull Request, please run `make check` and resolve any errors. This creates and runs `bin/golangci-lint`. For settings such as configured linters, see [.golangci.yaml](../.golangci.yaml).
Before submitting code in a Pull Request, please run `make check` and resolve any errors. This creates and runs `bin/golangci-lint`. For settings such as configured linters, see [.golangci.yaml](../.golangci.yaml).

## Templates

When a new Function is created, a few files are placed in the new Function's directory. This includes source code illustrating a minimal Function of the requested type (language runtime and function signature) as well as Function metadata in a `func.yaml` file.
When a new Function is created, a few files are placed in the new Function's directory. This includes source code illustrating a minimal Function of the requested type (language runtime and function signature) as well as Function metadata in a `func.yaml` file.

The source of these templates is `./templates`; a directory subdivided by language and template name.
For example, the Go HTTP template is located in `./templates/go/http`.
Expand All @@ -83,32 +85,28 @@ For a list of available make targets, use `make help`.

## Integration Testing

*Integration tests are run automatically* for all pull requests from within the GitHub Pull Request. This process includes creating and configuring a lightweight cluster.
_Integration tests are run automatically_ for all pull requests from within the GitHub Pull Request. This process includes creating and configuring a lightweight cluster.

If you would like to run integration tests prior to opening a pull request against origin, you can enable Actions in your fork of this repository and create a pull request to your own main branch.

If you would like to run integration tests locally, or would like to use the CLI / Client Library directly against a local cluster, the cluster allocation script can be used locally as well, by following the steps below.


### Prerequisites
### Prerequisites

The cluster allocation script requires [jq](https://stedolan.github.io/jq/), [yq](https://github.com/kislyuk/yq), [kubectl](https://kubernetes.io/docs/tasks/tools/), [kind](https://kind.sigs.k8s.io/docs/user/quick-start/), docker and python.

Please note that the version of `yq` required is installed via `pip3 install yq` or `brew install python-yq`


### Allocate

Allocate a new local cluster by running `hack/cluster.sh`.


### Registry

The allocation script sets up a local container registry and connects it to the cluster. This registry must be set as trusted and its address entered in the local `hosts` file. This is a one-time configuration and on Linux can be accomplished by running `hack/registry.sh`.
The allocation script sets up a local container registry and connects it to the cluster. This registry must be set as trusted and its address entered in the local `hosts` file. This is a one-time configuration and on Linux can be accomplished by running `hack/registry.sh`.

On other systems, add `127.0.0.1 kind-registry` to your local `hosts` file and `"insecure-registries" = ["kind-registry:50000"]` to your docker daemon config (`docker/daemon.json`).


### Using the Cluster

Once the cluster has been allocated, the `func` CLI (or client library) will automatically use it (see the [Kubeconfig Docs](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/) for more)
Expand All @@ -117,8 +115,6 @@ With the Knative deployer, functions are available at `http://[Function Name]-[N

To run integration tests, use `make test-integration`.


### Cleanup

The cluster and registry can be deleted by running `hack/delete.sh`

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ For detailed documentation on all available `func` commands, including usage exa
We use GitHub issues and project to track our roadmap. Please see our roadmap [here](https://github.com/orgs/knative/projects/49).

## Knative Function demos and examples

- [Knative Functions in action: Amsterdam City Data App](https://github.com/zroubalik/knative-functions-ams-data-demo/)

## Contributing

We are always looking for contributions from the Function Developer community. For more information on how to participate, see the [Contribuiting Guide](/CONTRIBUTING.md).
We are always looking for contributions from the Function Developer community. For more information on how to participate, see the [Contribuiting Guide](/CONTRIBUTING.md).
For a list of all help wanted issues in Knative, take a look at [CLOTRIBUTOR](https://clotributor.dev/search?project=knative&page=1).

The `func` Working Group meets @ 10:00 US Eastern every Tuesday, we'd love to have you! For more information, see the invitation on the [Knative Team Calendar](https://calendar.google.com/calendar/u/0/embed?src=knative.team_9q83bg07qs5b9rrslp5jor4l6s@group.calendar.google.com).
22 changes: 11 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

Functions can be written in the following languages using built-in templates:

* Go (Golang)
* Node.js (JavaScript)
* Python
* Quarkus (Java)
* Rust
* SpringBoot (Java)
* TypeScript
- Go (Golang)
- Node.js (JavaScript)
- Python
- Quarkus (Java)
- Rust
- SpringBoot (Java)
- TypeScript

Functions can be deployed on the following platforms:

* Kubernetes
* OpenShift
* Localhost
- Kubernetes
- OpenShift
- Localhost

## Function Installation, Development and Integration

Expand All @@ -30,4 +30,4 @@ Functions can be deployed on the following platforms:

## Contributing

We are always looking for contributions to the project from the Function Developer community. For more information on how to participate, see the [Contributing Guide](../CONTRIBUTING.md)
We are always looking for contributions to the project from the Function Developer community. For more information on how to participate, see the [Contributing Guide](../CONTRIBUTING.md)
24 changes: 22 additions & 2 deletions docs/building-functions/on_cluster_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
This guide describes how you can build a Function on Cluster with Tekton Pipelines. The on cluster build is enabled by fetching Function source code from a remote Git repository. Buildpacks or S2I builder strategy can be used to build the Function image.

## Prerequisite

1. Install Tekton Pipelines on the cluster.

**Note:** If you're using `./hack/cluster.sh` for development/testing, Tekton and PAC are automatically installed.

For production environments, please refer to [Tekton Pipelines documentation](https://github.com/tektoncd/pipeline/blob/main/docs/install.md) or run the following command:

```bash
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v1.6.0/release.yaml
```
Expand Down Expand Up @@ -44,6 +46,7 @@ kubectl create clusterrolebinding $NAMESPACE:knative-serving-namespaced-admin \
```

### Option B: Permissions only needed for the raw Deployer

```bash
export NAMESPACE=<INSERT_YOUR_NAMESPACE>

Expand Down Expand Up @@ -88,6 +91,7 @@ kubectl create rolebinding func-deployer-binding \
```

### Option D: Permissions only needed for the Knative Deployer

```bash
export NAMESPACE=<INSERT_YOUR_NAMESPACE>

Expand All @@ -101,41 +105,53 @@ kubectl create clusterrolebinding $NAMESPACE:knative-serving-namespaced-admin \
```

## Building a Function on Cluster

1. Create a Function and implement the business logic

```bash
kn func create my-function
```

2. Get a reference to the remote Git repository that will host your Function source code (eg. `https://github.com/my-repo/my-function.git`)
3. Initialize a Git repository in your Function project and add a reference to the remote repo

```bash
cd my-function
git init
git branch -M main
git remote add origin git@github.com:my-repo/my-function.git
```

4. Update the Function configuration in `func.yaml` to enable on cluster builds for the Git repository:

```yaml
build:
source:
url: https://github.com/my-repo/my-function.git # required, git repository with the function source code
revision: main # optional, git revision to build (branch, tag, commit)
url: https://github.com/my-repo/my-function.git # required, git repository with the function source code
revision: main # optional, git revision to build (branch, tag, commit)
# dir: myfunction # optional, needed only if the function is not located in the repository root folder
buildpacks: []
builder: ""
buildEnvs: []
```

5. Implement the business logic of your Function, then commit and push changes

```bash
git add .
git commit -a -m "implementing my-function"
git push origin main
```

6. Deploy your Function

```bash
kn func deploy --remote
```

If you are not logged in the container registry referenced in your function configuration,
you will prompted to provide credentials for the remote container registry that hosts the Function image. You should see output similar to the following:

```bash
$ kn func deploy --remote
🕕 Creating Pipeline resources
Expand All @@ -149,7 +165,9 @@ Please provide credentials for image registry used by Pipeline.
7. To update your Function, commit and push new changes, then run `kn func deploy --remote` again.

## Uninstall and clean-up

1. In each namespace where Pipelines and Functions were deployed, uninstall following resources:

```bash
export NAMESPACE=<INSERT_YOUR_NAMESPACE>

Expand All @@ -164,7 +182,9 @@ kubectl delete clusterrolebinding $NAMESPACE:knative-eventing-namespaced-admin
kubectl delete clusterrolebinding $NAMESPACE:knative-serving-namespaced-admin

```

2. Uninstall Tekton Pipelines

```bash
kubectl delete -f https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
```
Loading
Loading