Planned support for Starlark load() to support common config between repos?

Somewhat related to “Starlark cannot load external script”, I was pleased to see the inclusion of Starlark into core as part of version 1.10.0, but crestfallen when I discovered that load() is not supported as it is in the drone-convert-starlark plugin (which itself appears to be stale judging by months-long open PRs and last commit in April 2020).

Are there any plans to include such support in the future (perhaps like drone-convert-starlark)?

If not, what is the recommended approach to centralizing common Drone configuration across multiple repos?

Thanks for any guidance,
-Marc

kw: starlark load common configuration

1 Like

There are no immediate plans to replicate this capability in the embedded starlark implementation in drone core, at least, not as it is currently designed and implemented (e.g. loaded from disk). If you rely on this feature you would need to continue using the extension.

We may consider adding a snippets feature, where you can create and manage snippets in the user interface, which can then be included in your yaml or loaded into your starlark script. So the implementation would be a little different, but this would likely still satisfy your use case. This is not something we have formally committed to building, but is something we will consider for our 2021 roadmap.

Thanks for clarifying, @bradrydzewski – we’re looking to manage common config under source control, and being able to apply automation to it. Sounds like our path forward for now should involve the drone-convert-starlark plugin.

For the record, managing anything through a UI that cannot be done via commands or sourced from configuration (i.e.: material under source control) would not be that interesting for us – hopefully this input is helpful for such a feature.

Thanks again,
-Marc

Oh snap! I’m managing multiple repos and need to include .drone.star with repeating the code in every repo. It would be really helpful having the shared code in single lib and just pull it and run with different config.

Can you think of any way, how to achieve this functionality? Some kind of pre-task, which would pull the scripts and concatenate into drone.star?

This is supported in the extension github.com/drone/drone-convert-starlark#external-loadsimports-optional. This extension is considered feature-complete and is therefore no longer being actively developed by our team, however, you can definitely still use it. And of course anyone can fork and augment to meet their needs.

We also have a new feature called templates which can be used to share configurations across repositories. This would require you change your approach, but may provide an alternate solution to your problem. See docs.drone.io/template.

Awesome! Templates are exactly what I needed. Thanks!