Skip to content

Commit 7093fe0

Browse files
thomas11iwahbe
andauthored
Introduce AssetOrArchive to support the SDK's Asset type which can be both (#242)
Resolves #237. This PR addresses an issue with the design of the [assets and archives support](https://www.pulumi.com/docs/concepts/assets-archives/) in Pulumi core. Quoting #237: > When defining a property of type resource.Asset, the generated schema will contain a $ref of pulumi.json#/Asset. However, in the SDKs, an "asset" is represented by pulumi.AssetOrArchive because an archive is currently always a valid asset. > Therefore, when deserializing the PropertyValue for the provider to use, it's valid for the user to have specified one of the Archive types which then isn't deserializable into the resource.Asset field within the provider. To work around this, we define a new type `types.AssetOrArchive` here in pulumi-go-provider. In the schema, it's represented as a standard `pulumi.json#/Asset` for interoperability. An incoming core `Asset` is translated into a `types.AssetOrArchive`, in `Decode`, with either Asset or Archive populated. Vice versa, `Encode` pulls the asset/archive out of AssetOrArchive. ## Notes - The decode and encode implementations are bespoke and there might be opportunities to move it to a new, more generic extension point. --------- Co-authored-by: Ian Wahbe <[email protected]>
1 parent 2bf8636 commit 7093fe0

File tree

11 files changed

+825
-7
lines changed

11 files changed

+825
-7
lines changed

examples/assets/consumer/Pulumi.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: consume-assets
2+
runtime: yaml
3+
4+
plugins:
5+
providers:
6+
- name: assets
7+
path: ..
8+
9+
resources:
10+
assetsResource:
11+
type: assets:HasAssets
12+
properties:
13+
a1:
14+
fn::fileAsset: ./file.txt
15+
a2:
16+
fn::fileArchive: ./file.txt.zip

examples/assets/consumer/file.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo

examples/assets/consumer/file.txt.zip

170 Bytes
Binary file not shown.

examples/assets/go.mod

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
module github.com/pulumi/pulumi-go-provider/examples/assets
2+
3+
replace github.com/pulumi/pulumi-go-provider => ../..
4+
5+
go 1.22.4
6+
7+
require github.com/pulumi/pulumi-go-provider v0.0.0-00010101000000-000000000000
8+
9+
require (
10+
dario.cat/mergo v1.0.0 // indirect
11+
github.com/Microsoft/go-winio v0.6.1 // indirect
12+
github.com/ProtonMail/go-crypto v1.0.0 // indirect
13+
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
14+
github.com/agext/levenshtein v1.2.3 // indirect
15+
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
16+
github.com/atotto/clipboard v0.1.4 // indirect
17+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
18+
github.com/blang/semver v3.5.1+incompatible // indirect
19+
github.com/charmbracelet/bubbles v0.16.1 // indirect
20+
github.com/charmbracelet/bubbletea v0.24.2 // indirect
21+
github.com/charmbracelet/lipgloss v0.7.1 // indirect
22+
github.com/cheggaaa/pb v1.0.29 // indirect
23+
github.com/cloudflare/circl v1.3.7 // indirect
24+
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
25+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
26+
github.com/djherbis/times v1.5.0 // indirect
27+
github.com/edsrzf/mmap-go v1.1.0 // indirect
28+
github.com/emirpasic/gods v1.18.1 // indirect
29+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
30+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
31+
github.com/go-git/go-git/v5 v5.12.0 // indirect
32+
github.com/gogo/protobuf v1.3.2 // indirect
33+
github.com/golang/glog v1.2.0 // indirect
34+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
35+
github.com/google/uuid v1.6.0 // indirect
36+
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
37+
github.com/hashicorp/errwrap v1.1.0 // indirect
38+
github.com/hashicorp/go-multierror v1.1.1 // indirect
39+
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
40+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
41+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
42+
github.com/kevinburke/ssh_config v1.2.0 // indirect
43+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
44+
github.com/mattn/go-isatty v0.0.19 // indirect
45+
github.com/mattn/go-localereader v0.0.1 // indirect
46+
github.com/mattn/go-runewidth v0.0.15 // indirect
47+
github.com/mitchellh/go-ps v1.0.0 // indirect
48+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
49+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
50+
github.com/muesli/cancelreader v0.2.2 // indirect
51+
github.com/muesli/reflow v0.3.0 // indirect
52+
github.com/muesli/termenv v0.15.2 // indirect
53+
github.com/natefinch/atomic v1.0.1 // indirect
54+
github.com/opentracing/basictracer-go v1.1.0 // indirect
55+
github.com/opentracing/opentracing-go v1.2.0 // indirect
56+
github.com/pgavlin/fx v0.1.6 // indirect
57+
github.com/pgavlin/goldmark v1.1.33-0.20200616210433-b5eb04559386 // indirect
58+
github.com/pjbgf/sha1cd v0.3.0 // indirect
59+
github.com/pkg/errors v0.9.1 // indirect
60+
github.com/pkg/term v1.1.0 // indirect
61+
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
62+
github.com/pulumi/esc v0.6.2 // indirect
63+
github.com/pulumi/pulumi/pkg/v3 v3.117.0 // indirect
64+
github.com/pulumi/pulumi/sdk/v3 v3.117.0 // indirect
65+
github.com/rivo/uniseg v0.4.4 // indirect
66+
github.com/rogpeppe/go-internal v1.11.0 // indirect
67+
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
68+
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
69+
github.com/segmentio/asm v1.1.3 // indirect
70+
github.com/segmentio/encoding v0.3.5 // indirect
71+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
72+
github.com/skeema/knownhosts v1.2.2 // indirect
73+
github.com/spf13/cobra v1.8.0 // indirect
74+
github.com/spf13/pflag v1.0.5 // indirect
75+
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
76+
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect
77+
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
78+
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
79+
github.com/xanzy/ssh-agent v0.3.3 // indirect
80+
github.com/zclconf/go-cty v1.13.2 // indirect
81+
go.uber.org/atomic v1.10.0 // indirect
82+
golang.org/x/crypto v0.23.0 // indirect
83+
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
84+
golang.org/x/mod v0.14.0 // indirect
85+
golang.org/x/net v0.25.0 // indirect
86+
golang.org/x/sync v0.6.0 // indirect
87+
golang.org/x/sys v0.20.0 // indirect
88+
golang.org/x/term v0.20.0 // indirect
89+
golang.org/x/text v0.15.0 // indirect
90+
golang.org/x/tools v0.17.0 // indirect
91+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
92+
google.golang.org/grpc v1.63.2 // indirect
93+
google.golang.org/protobuf v1.33.0 // indirect
94+
gopkg.in/warnings.v0 v0.1.2 // indirect
95+
gopkg.in/yaml.v3 v3.0.1 // indirect
96+
lukechampine.com/frand v1.4.2 // indirect
97+
)

0 commit comments

Comments
 (0)