https://github.com/shawntoffel/faasgo
swaggerless golang api client for the OpenFaaS gateway
https://github.com/shawntoffel/faasgo
api client golang openfaas
Last synced: 4 months ago
JSON representation
swaggerless golang api client for the OpenFaaS gateway
- Host: GitHub
- URL: https://github.com/shawntoffel/faasgo
- Owner: shawntoffel
- License: bsd-3-clause
- Created: 2018-09-30T20:09:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-28T04:32:04.000Z (over 5 years ago)
- Last Synced: 2024-11-13T16:49:18.475Z (over 1 year ago)
- Topics: api, client, golang, openfaas
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# faasgo
[](https://godoc.org/github.com/shawntoffel/faasgo) [](https://goreportcard.com/report/github.com/shawntoffel/faasgo)
swaggerless golang api client for the [OpenFaaS gateway](https://github.com/openfaas/faas)
## Installation
```bash
go get github.com/shawntoffel/faasgo
```
## Authentication
OpenFaaS uses basic authentication.
```
gateway.SetBasicAuth("user", "password")
```
If you do not specify a user/pass with `SetBasicAuth` credentials are read from the following environment variables:
```bash
FAASGO_USER
FAASGO_PASS
```
Alternatively, credentials can be read from a file where the file location is specified by the following environment variables:
```bash
FAASGO_USER_FILE
FAASGO_PASS_FILE
```
The file path may be a docker secret location.
## Basic Usage
```go
gateway := faasgo.New(faasgo.DefaultUrl)
// service, image, and envprocess are required.
function := faasgo.Function{
Service: "nodeinfo",
Image: "functions/nodeinfo:latest",
EnvProcess: "node main.js",
}
// Deploy a function
err := gateway.DeployFunction(function)
if err != nil {
log.Fatal(err)
}
// List deployed functions
functions, err := gateway.ListFunctions()
if err != nil {
log.Fatal(err)
}
// Invoke a function
resp, err := gateway.Invoke("nodeinfo", nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(resp))
```