Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Module should allow to export some values #333

Open
yyvess opened this issue Feb 1, 2024 · 2 comments
Open

[Proposal] Module should allow to export some values #333

yyvess opened this issue Feb 1, 2024 · 2 comments

Comments

@yyvess
Copy link
Contributor

yyvess commented Feb 1, 2024

A module can declare a list of exported value.

On timoni.cue we should able to declare exported value like

// Define how Timoni should build, validate and
// apply the Kubernetes resources.
timoni: {
	apiVersion: "v1alpha1"

	export: [ {url: "redis://\(instance.config.metadata.name).\(instance.config.metadata.namespace).svc.cluster.local:\(instance.config.port)"}]

Then we should able to re-use these variables on bundle file as =>

bundle: {
    apiVersion: "v1alpha1"
    name:       "podinfo"
    instances: {
        redis: {
            module: {
                url:     "oci://ghcr.io/stefanprodan/modules/redis"
                version: "7.2.3"
            }
            namespace: "podinfo"
            values: maxmemory: 256
        }
        podinfo: {
            module: url:     "oci://ghcr.io/stefanprodan/modules/podinfo"
            module: version: "6.5.4"
            namespace: "podinfo"
            values: caching: {
                enabled:  true
                redisURL: redis.url
            }
        }
    }
}
@jmgilman
Copy link
Contributor

jmgilman commented Feb 5, 2024

This is a nice alternative to the bundle runtime, especially when you don't actually need runtime data in many cases. If my module produces one or more Kubernetes secrets, for example, being able to export their names for other instances to use is helpful.

Given that the CLI is mostly just transpiling a given CUE output into YAML (that happens to produce valid Kubernetes manifests), it's plausible you could add another reserved output (i.e., export as shown above) that is ingested and made available when the bundle is being processed.

I would propose the outputs appear in their own namespace, like: redis.outputs.url. Otherwise, you'll have collisions (i.e., what happens when an output is named namespace).

@salotz
Copy link

salotz commented Mar 25, 2024

+1 for this. Same use case with the secrets/configs.

Although I'll ask if it is possible to just fully introspect/unify on any value within Timoni module?

I think its still useful to have a declared and expected interface like outputs but it would probably be also useful to have read access to everything. I.e. only use the values for unification of the module, but then be able to view the already concretized values from bundles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants