GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — func/docs/integrators_guide.md at main · stackbuilders/func

Expand file tree

/

integrators_guide.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
53 lines (44 loc) · 1.38 KB
/

integrators_guide.md

Copy path

File metadata and controls

53 lines (44 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Integrator's Guide

Developers can integrate directly with the function system using the client library upon which the func CLI is based.

Using the Client Library

To create a Client which uses the included buildpacks-based function builder, pushes to a Quay.io registry function container artifacts and deploys to a Knative enabled cluster:

package main

import (
	fn "github.com/knative/func"
	"github.com/knative/func/buildpacks"
	"github.com/knative/func/docker"
	"github.com/knative/func/knative"
	"log"
)

func main() {
	pusher, err := docker.NewPusher()
	if err != nil {
		log.Fatal(err)
	}
	deployer, err := knative.NewDeployer("")
	if err != nil {
		log.Fatal(err)
	}
	// A client which uses embedded function templates,
	// Quay.io/alice for interstitial build artifacts.
	// Docker to build and push, and a Knative client for deployment.
	client := fn.New(
		fn.WithBuilder(buildpacks.NewBuilder()),
		fn.WithPusher(pusher),
		fn.WithDeployer(deployer),
		fn.WithRegistry("quay.io/alice"))

	// Create a Go function which listens for CloudEvents.
	// Publicly routable as https://www.example.com.
	// Local implementation is written to the current working directory.
	funcTest := fn.Function{
		Runtime: "go",
		Name:    "my-function",
		Image:   "quay.io/alice/my-function",
		Root:    "my-function",
	}
	if err := client.Create(funcTest); err != nil {
		log.Fatal(err)
	}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.