question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide each: in software templates

See original GitHub issue

Feature Suggestion

Consider the example of creating virtual machines via a gitops process. If we consider backstage as it currently functions, we can articulate this sort of thing as:

spec:
  parameters:
    # ...
steps:
- name: fetch-repo
   action: fetch:plain
- name: fetch-template
   action: fetch:template   
 - name: publish
   action: publish:github:pull-request   

Now imagine we want to make more than one of these for some static N. We can obviously fill this out multiple times but there should be a better way!

Consider also the case of collecting user input in an array form and wanting to do things for each of them. In the VM request form, I may be hitting “add item” in an array input to add multiple things, or using a multiselect, or any number of possible inputs to add additional VMs I wish to create, and I want to act across these. This currently is not possible via backstage without making custom actions that call out to specific actions for each permutation of this.

It would be fantastic if each of these were solvable, and would allow all manners of automation possibilities using backstage templates.

Possible Implementation

If we just consider what we may like to do in some sort of repeating block, we could tell it to do something N times and if we had access to the index, we could coerce backstage to grab that element where it matters.

- name: Fetch Template
   action: fetch:template
   times: 10
   input:
     url: ./template
     targetPath: '...'
     values:
       version: ${{parameters.version}}
       index: ${{index}}
       object: ${{parameters.objects[$index]}}

We may also want to iterate over them, so something like:

- name: Fetch Template
   action: fetch:template
   each: ${{parameters.objects}}
   input:
     url: ./template
     targetPath: '...'
     values:
       version: ${{parameters.version}}
       index: ${{index}}
       object: ${{object}}

We can probably coerce nunjucks to generate 0…n from an n, so we could get by with just the second I think.

I don’t think ${{object}} or ${{index}} are necessarily good ways to articulate those, but illustrate the idea.

Context

There are a large number of automations that boil down to “ask user for input and do it a bunch of times” and I think backstage is exceptionally positioned to be able to make these go away with largely the same primitives that make software templates so useful for n=1.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
Rugvipcommented, Jan 13, 2022

Throwing in a possible naming choice here that keeps the number of top-level names low and keeps things a bit namespaced

- name: Fetch Template
  action: fetch:template
  each: ${{parameters.versions}} # array or object
  input:
    url: ./template
    targetPath: versions/${{each.key}}
    values:
      info: ${{each.value}}
2reactions
asummerscommented, Jan 20, 2022

I think fundamentally, if I can do an action once, it shouldn’t require me making a custom action to do it more than once. That burden seems too high to impose on users, IMO. A custom action makes composing them much harder and requires you to surface details like required, inputs, outputs in multiple places which feels burdensome on users. It will also result in excessive wrapping of built ins, which just feels wrong, to me. If there was a way to generically compose things, I think I’d be a little more open to that, where instead of needing to create a new one, you could tell it you want to do an action multiple times and it do the legwork for you. But I think needing to write it yourself every single time is a bit heavy handed here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Backstage Software Templates
The Software Templates part of Backstage is a tool that can help you create ... Each template can ask for different input variables,...
Read more >
Technical Documentation in Software Development - AltexSoft
Samples and templates for software documentation ... Each is unique in terms of accompanying documentation.
Read more >
Free Software Development Proposal Template by PandaDoc
Decrease your creation-to-close rate by 48% with this free software development proposal template. Try for free.
Read more >
Best Software Design Document Templates - DevTeam.Space
Find the Best Software Design Document Templates Right Here in our Guide to Help You Build the Best Software Products.
Read more >
Free Review of Systems Template for Software Development
This template acts as a concise workflow, providing teams with insights on ... A review of systems template outlines every phase of software...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found