Skip to content

Commit

Permalink
Reference community templates in the main README
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Nov 11, 2017
1 parent 38c83ec commit 50be10b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ The CLI can be used to build and deploy functions to [OpenFaaS](https://github.c

Demo: [ASCII cinema](https://asciinema.org/a/141284)

#### TL;DR
### TL;DR - Introductory tutorial

[Blog: Coffee with the FaaS-CLI](https://blog.alexellis.io/quickstart-openfaas-cli/)

### Install the CLI
### Get started: Install the CLI

The easiest way to install the faas-cli is through a curl script or `brew`:

Expand Down Expand Up @@ -43,15 +43,19 @@ The main commands supported by the CLI are:
* `faas-cli remove` - removes the functions from a local or remote OpenFaaS gateway
* `faas-cli invoke` - invokes the functions and reads from STDIN for the body of the request
* `faas-cli login` - stores basic auth credentials for OpenFaaS gateway (supports multiple gateways)
* `faas-cli logout` - removes basic auth credentials fora given gateway
* `faas-cli logout` - removes basic auth credentials for a given gateway

Advanced commands:

* `faas-cli template pull` - pull in templates from a remote GitHub repository

Help for all of the commands supported by the CLI can be found by running:

* `faas-cli help` or `faas-cli [command] --help`

You can chose between using a [programming language template](https://github.com/openfaas/faas-cli/tree/master/template) where you only need to provide a handler file, or a Docker that you can build yourself.

**Templates**
#### Templates

Command: `faas-cli new FUNCTION_NAME --lang python/node/go/ruby/Dockerfile/etc`

Expand All @@ -69,7 +73,20 @@ You can customise the Dockerfile or code for any of the templates. Just create a

See also: `faas-cli new --help`

**Docker image**
**Third-party community templates**

Templates created and maintained by a third-party can be added to your local system using the `faas-cli template pull` command.

Curated language templates:

| Language | Author | URL |
|---|---|---|
| PHP | @itscaro | https://github.com/itscaro/openfaas-template-php/ |
| PHP5 | @itscaro | https://github.com/itscaro/openfaas-template-php/ |

Read more on [community templates here](guide/TEMPLATE.md).

#### Docker image as a function

Specify `lang: Dockerfile` if you want the faas-cli to execute a build or `skip_build: true` for pre-built images.

Expand Down Expand Up @@ -124,7 +141,7 @@ Now you can use the following command to deploy your function(s):
$ faas-cli deploy -f ./samples.yml
```
### Managing secrets
#### Managing secrets
You can deploy secrets and configuration via environmental variables in-line or via external files.
Expand Down Expand Up @@ -165,7 +182,7 @@ functions:
no_proxy: http://gateway/
```

### Constraints
#### Constraints

Constraints work with Docker Swarm and are useful for pinning functions to certain hosts.

Expand All @@ -183,7 +200,7 @@ Or only Windows:
- "node.platform.os == windows"
```

### Labels
#### Labels

Labels can be applied through a map which may be consumed by the back-end scheduler such as Docker Swarm or Kubernetes.

Expand All @@ -195,7 +212,7 @@ For example:
canary: true
```

### YAML reference
#### YAML reference

The possible entries for functions are documented below:

Expand All @@ -217,7 +234,7 @@ functions:

Use environmental variables for setting tokens and configuration.

**Accessing the function with `curl`**
#### Access functions with `curl`

You can initiate a HTTP POST via `curl`:

Expand All @@ -237,10 +254,10 @@ $ uname -a | curl http://localhost:8080/function/nodejs-echo--data-binary @-
> For further instructions on the manual CLI flags (without using a YAML file) read [manual_cli.md](https://github.com/openfaas/faas-cli/blob/master/MANUAL_CLI.md)
## FaaS-CLI Developers / Contributors
### FaaS-CLI Developers / Contributors
See [contributing guide](https://github.com/openfaas/faas-cli/blob/master/CONTRIBUTING.md).
### License
#### License
This project is part of the OpenFaaS project licensed under the MIT License.
5 changes: 5 additions & 0 deletions commands/fetch_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,24 @@ func fetchMasterZip(templateURL string) (string, error) {
log.Println(err.Error())
return "", err
}

log.Printf("HTTP GET %s\n", templateURL)
res, err := client.Do(req)
if err != nil {
log.Println(err.Error())
return "", err
}

if res.StatusCode != http.StatusOK {
err := fmt.Errorf(fmt.Sprintf("%s is not valid, status code %d", templateURL, res.StatusCode))
log.Println(err.Error())
return "", err
}

if res.Body != nil {
defer res.Body.Close()
}

bytesOut, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Println(err.Error())
Expand All @@ -214,6 +218,7 @@ func fetchMasterZip(templateURL string) (string, error) {
return "", err
}
}

fmt.Println("")
return archive, err
}
Expand Down

0 comments on commit 50be10b

Please sign in to comment.