This change enables users to have declarative specifications for Fission resources. Users can specify their "app" in a set of spec files, and use a new fission CLI command to "apply" these specs to a running cluster. The new "spec" CLI also includes archiving of local source files, and a file watcher that re-builds archives and uploads them on file changes, and a package build watcher that waits for package builds on the CLI. A "--spec" option is also added to "function create", and will be added to other resources in future changes. This option causes a YAML to be outputted to the specs directory instead of the resource being created on the cluster. The CLI "fission spec --help" outputs usage information.
59 lines
1.0 KiB
Bash
Executable File
59 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#test:disabled
|
|
|
|
set -euo pipefail
|
|
|
|
fn=spec-$(date +%N)
|
|
env=python-$fn
|
|
|
|
# init
|
|
fission spec init
|
|
|
|
# verify init
|
|
[ -d specs ]
|
|
[ -f specs/README ]
|
|
[ -f specs/fission-deployment-config.yaml ]
|
|
|
|
# TODO replace with `fission env create --spec`
|
|
cat > specs/env.yaml <<EOF
|
|
apiVersion: fission.io/v1
|
|
kind: Environment
|
|
metadata:
|
|
name: $env
|
|
namespace: default
|
|
spec:
|
|
version: 1
|
|
runtime:
|
|
image: fission/python-env:0.4.0
|
|
EOF
|
|
|
|
# create env
|
|
fission spec apply
|
|
trap "fission env delete --name $env" EXIT
|
|
|
|
# verify env created
|
|
fission env list | grep python
|
|
|
|
# generate function spec
|
|
fission fn create --spec --name $fn --env $env --code $(dirname $0)/hello.py
|
|
|
|
# verify that function spec exists and has ArchiveUploadSpec, Package and Function
|
|
[ -f specs/function-$fn.yaml ]
|
|
grep ArchiveUploadSpec specs/*.yaml
|
|
grep Package specs/*.yaml
|
|
grep Function specs/*.yaml
|
|
|
|
# create function
|
|
fission spec apply
|
|
trap "fission fn delete --name $fn" EXIT
|
|
|
|
# verify function
|
|
fission fn list | grep $fn
|
|
|
|
sleep 3
|
|
|
|
fission fn test --name $fn | grep -i hello
|
|
|
|
|