smith icon indicating copy to clipboard operation
smith copied to clipboard

Add support for referencing bundle from resources

Open nilebox opened this issue 8 years ago • 3 comments

Use case: generate resource names based on the bundle name (see name: {{#metadata.name}}-sleeper1 for example):

apiVersion: smith.atlassian.com/v1
kind: Bundle
metadata:
  name: bundlex
spec:
  resources:
  - name: sleeper1
    spec:
      apiVersion: tpr.atlassian.com/v1
      kind: Sleeper
      metadata:
        name: {{#metadata.name}}-sleeper1
      spec:
        sleepFor: 3
        wakeupMessage: Hello 1 from bundle {{#metadata.name}}!
  - name: sleeper2
    dependsOn:
    - sleeper1
    spec:
      apiVersion: tpr.atlassian.com/v1
      kind: Sleeper
      metadata:
        name: {{#metadata.name}}-sleeper2
      spec:
        sleepFor: 4
        wakeupMessage: "{{sleeper1.status.message}}"
  - name: sleeper3
    dependsOn:
    - sleeper2
    spec:
      apiVersion: tpr.atlassian.com/v1
      kind: Sleeper
      metadata:
        name: sleeper3
      spec: "{{{sleeper2.spec}}}"

Some "global variables" defined within bundle would also work.

nilebox avatar Jun 19 '17 00:06 nilebox

We should probably support "global constants" section inside of the bundle that can be referenced along with other bundle contents.

ash2k avatar Jun 19 '17 10:06 ash2k

@wryun this is what I was talking about

ash2k avatar Feb 21 '18 11:02 ash2k

Ah, right, makes more sense. I'm not convinced it would be an understandability improvement, though, in the case we were discussing (because the 'resource specific' info would be moved out of the resource...). One could maintain separate constants for each resource, I guess, or even invert things: i.e. the spec is always a valid object that can be pushed into the actual types (has the examples in it), and there is a separate 'template' thing full of references that's merged in.

wryun avatar Feb 21 '18 11:02 wryun