Skip to content

Commit

Permalink
chore: update docuements
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <xpf6677@163.com>
  • Loading branch information
Peefy committed Dec 22, 2023
1 parent d181817 commit b330137
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Crossplane Composition Functions using KCL

[![CI](https://kcl-lang.io/crossplane-kcl/actions/workflows/ci.yml/badge.svg)](https://kcl-lang.io/crossplane-kcl/actions/workflows/ci.yml)
[![Go Report Card](https://goreportcard.com/badge/kcl-lang.io/crossplane-kcl)](https://goreportcard.com/report/kcl-lang.io/crossplane-kcl)
[![GoDoc](https://godoc.org/kcl-lang.io/crossplane-kcl?status.svg)](https://godoc.org/kcl-lang.io/crossplane-kcl)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://kcl-lang.io/crossplane-kcl/blob/main/LICENSE)

## Introduction

Crossplane KCL function allows developers to use [KCL](https://kcl-lang.io/) (a DSL) to write composite logic without the need for repeated packaging of crossplane functions, and we support package management and the [KRM KCL specification](https://github.com/kcl-lang/krm-kcl), which allows for OCI/Git source and the reuse of [KCL's module ecosystem](https://artifacthub.io/packages/search?org=kcl&sort=relevance&page=1).

## Developing

Expand Down Expand Up @@ -31,9 +37,9 @@ A KRM YAML list which means that each document must have an `apiVersion`, `kind`
Here's what you can do in the KCL script:

+ Return an error using `assert {condition}, {error_message}`.
+ Read the `ObservedCompositeResource` from `option("params").oxr`.
+ Read the `ObservedComposedResources` from `option("params").ocds`.
+ Read the `DesiredCompositeResource` from `option("params").dxr`.
+ Read the `ObservedCompositeResource` from `option("oxr").oxr`.
+ Read the `ObservedComposedResources` from `option("ocds").ocds`.
+ Read the `DesiredCompositeResource` from `option("dxr").dxr`.
+ Read the `DesiredComposedResources` from `option("params").dcds`.
+ Read the environment variables. e.g. `option("PATH")` (**Not yet implemented**).

Expand Down
20 changes: 18 additions & 2 deletions examples/resources/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,25 @@ kind: XR
metadata:
name: example-xr
---
apiVersion: example.org/v1
kind: Generated
metadata:
annotations:
crossplane.io/composition-resource-name: ""
generateName: example-xr-
labels:
crossplane.io/composite: example-xr
ownerReferences:
- apiVersion: example.crossplane.io/v1
blockOwnerDeletion: true
controller: true
kind: XR
name: example-xr
uid: ""
---
apiVersion: render.crossplane.io/v1beta1
kind: Result
message: I was run with input "Hello world"!
message: created resource ":Generated"
severity: SEVERITY_NORMAL
step: run-the-template
step: normal
```
2 changes: 1 addition & 1 deletion input/v1beta1/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (in KCLInput) Validate() error {
}
}
default:
return field.Required(field.NewPath("spec.target"), fmt.Sprintf("invalid target %s", in.Spec.Target))
return field.Required(field.NewPath("spec.target"), fmt.Sprintf("invalid target: %s", in.Spec.Target))
}

return nil
Expand Down

0 comments on commit b330137

Please sign in to comment.