Skip to content

Commit 157d891

Browse files
committed
crd2pulumi 1.5.4 (new formula)
Signed-off-by: Rui Chen <rui@chenrui.dev>
1 parent 6b596e0 commit 157d891

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.github/autobump.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ crabz
694694
cracklib
695695
crane
696696
crates-tui
697+
crd2pulumi
697698
cri-tools
698699
crispy-doom
699700
croaring

Formula/c/crd2pulumi.rb

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
class Crd2pulumi < Formula
2+
desc "Generate typed CustomResources from a Kubernetes CustomResourceDefinition"
3+
homepage "https://github.com/pulumi/crd2pulumi"
4+
url "https://github.com/pulumi/crd2pulumi/archive/refs/tags/v1.5.4.tar.gz"
5+
sha256 "3dfb4e2e7eb9633c156c78becb866836760ee4c87056d0c47a8288cef85dc14c"
6+
license "Apache-2.0"
7+
head "https://github.com/pulumi/crd2pulumi.git", branch: "master"
8+
9+
depends_on "go" => :build
10+
11+
def install
12+
system "go", "build", *std_go_args(ldflags: "-s -w -X github.com/pulumi/crd2pulumi/cmd.Version=#{version}")
13+
14+
generate_completions_from_executable(bin/"crd2pulumi", "completion")
15+
end
16+
17+
test do
18+
assert_match version.to_s, shell_output("#{bin}/crd2pulumi version")
19+
20+
test_crd = testpath/"crd.yaml"
21+
test_crd.write <<~YAML
22+
apiVersion: apiextensions.k8s.io/v1
23+
kind: CustomResourceDefinition
24+
metadata:
25+
name: widgets.example.com
26+
spec:
27+
group: example.com
28+
names:
29+
kind: Widget
30+
plural: widgets
31+
singular: widget
32+
scope: Namespaced
33+
versions:
34+
- name: v1
35+
served: true
36+
storage: true
37+
schema:
38+
openAPIV3Schema:
39+
type: object
40+
properties:
41+
spec:
42+
type: object
43+
properties:
44+
size:
45+
type: string
46+
color:
47+
type: string
48+
YAML
49+
50+
# Generate TypeScript code from the CRD
51+
system bin/"crd2pulumi", "--nodejsPath", testpath/"typescript", test_crd, "--force"
52+
53+
assert_path_exists testpath/"typescript/example/v1/widget.ts"
54+
assert_match "this file was generated by crd2pulumi", (testpath/"typescript/provider.ts").read
55+
56+
# Generate Python code from the CRD
57+
system bin/"crd2pulumi", "--pythonPath", testpath/"python", "--python", test_crd
58+
assert_path_exists testpath/"python/pulumi_crds/example/v1/Widget.py"
59+
assert_match "this file was generated by crd2pulumi", (testpath/"python/pulumi_crds/provider.py").read
60+
end
61+
end

0 commit comments

Comments
 (0)