mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-29 09:40:49 +00:00
Support standalone mode for framework functions
This commit is contained in:
12
kyaml/fn/framework/example2/Dockerfile
Normal file
12
kyaml/fn/framework/example2/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
FROM golang:1.13-stretch
|
||||
ENV CGO_ENABLED=0
|
||||
WORKDIR /go/src/
|
||||
COPY . .
|
||||
RUN go build -v -o /usr/local/bin/function ./
|
||||
|
||||
FROM alpine:latest
|
||||
COPY --from=0 /usr/local/bin/function /usr/local/bin/function
|
||||
CMD ["function"]
|
||||
7
kyaml/fn/framework/example2/config.yaml
Normal file
7
kyaml/fn/framework/example2/config.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
apiVersion: example.com/v1alpha1
|
||||
kind: Example
|
||||
key: key
|
||||
value: value
|
||||
35
kyaml/fn/framework/example2/main.go
Normal file
35
kyaml/fn/framework/example2/main.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"sigs.k8s.io/kustomize/kyaml/fn/framework"
|
||||
)
|
||||
|
||||
func main() {
|
||||
type api struct {
|
||||
Key string `json:"key" yaml:"key"`
|
||||
Value string `json:"value" yaml:"value"`
|
||||
}
|
||||
cmd := framework.TemplateCommand{
|
||||
API: &api{},
|
||||
Template: template.Must(template.New("example").Parse(`
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: foo
|
||||
namespace: default
|
||||
annotations:
|
||||
{{ .Key }}: {{ .Value }}
|
||||
`)),
|
||||
}.GetCommand()
|
||||
if err := cmd.Execute(); err != nil {
|
||||
fmt.Fprintln(cmd.OutOrStderr(), err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user