https://pulumi.com logo
#typescript
Title
# typescript
r

rhythmic-finland-36256

10/08/2019, 1:59 PM
If you want to group stuff into one single TS file to have it logically separated but this is not worth being a component / doesn’t have any reusability (e.g. some kubernetes deployment, service, ingress for one specific application) but still you want to have some shared config (provider and namespace), what is a good pattern for that? Exposing / importing functions that get the provider and namespace passed down and calling them? Already enough to have a
ComponentResource
for that?
w

white-balloon-205

10/08/2019, 3:58 PM
Yeah - I think in general there are roughly three steps: 1. Break up into multiple file and just import 2. Move things into functions with arguments for simple abstraction and re-use 3. Turn into components for cleaner inheritance of parent options (providers, aliases, transformations, etc) and for nicer visualization
c

clever-sunset-76585

10/08/2019, 4:29 PM
From my experience, I find myself going with #3 usually. 🙂
r

rhythmic-finland-36256

10/09/2019, 7:39 AM
After noticing that I’ll need several inputs (k8sProvider, namespace name, identifiers, urls …) and require some specific order I now went with a ComponentResource which worked pretty straightforward. My approach was passing the (kubernetes) provider in the
args
and constructing some
ComponentResourceOptions
with the said provider in the
provider
field and
parent:this
down to the components for clarity. So I’m also pretty happy with approach #3. Thanks 👍
At first, some simple functions that are imported and executed once looked like the way to go. But when it comes to shared config, passing several basic things (e.g. the provider, the namespace name) in every function and additionally leaking the information in which order things must be run to the caller soon got cumbersome. So for anybody running over this question: I’d go with a ComponentResource as soon as there is some first item I would otherwise have to provide in every function call.