<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jean-Louis FEREY</title>
    <description>The latest articles on DEV Community by Jean-Louis FEREY (@jeanlouisferey).</description>
    <link>https://dev.to/jeanlouisferey</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F646751%2F4d98e79d-0ee4-4a8b-a605-3d1fb60e1b98.jpeg</url>
      <title>DEV Community: Jean-Louis FEREY</title>
      <link>https://dev.to/jeanlouisferey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeanlouisferey"/>
    <language>en</language>
    <item>
      <title>Tips and tricks for Backstage Software Templates</title>
      <dc:creator>Jean-Louis FEREY</dc:creator>
      <pubDate>Wed, 09 Aug 2023 16:09:31 +0000</pubDate>
      <link>https://dev.to/jeanlouisferey/tips-and-tricks-for-backstage-software-templates-488p</link>
      <guid>https://dev.to/jeanlouisferey/tips-and-tricks-for-backstage-software-templates-488p</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;I'm a big fan of &lt;a href="https://backstage.io/" rel="noopener noreferrer"&gt;Backstage&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you don't know what Backstage is, have a look on this short video:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/85TQEpNCaU0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Software templates
&lt;/h2&gt;

&lt;p&gt;There is a lot of interesting features in Backstage, but one of my favorite is the &lt;a href="https://backstage.io/docs/features/software-templates/" rel="noopener noreferrer"&gt;Software Templates&lt;/a&gt;. This feature is already well explained by Ricardo Castro on &lt;a href="https://dev.to/mccricardo/backstage-software-templates-2jf6"&gt;dev.to&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I like this feature because it permit what I call "standardization by ease", in opposition to standardization by constraint when somewhere in your organization, a "code police", impose a law without telling how to implement it in your code.&lt;/p&gt;

&lt;p&gt;With Software Templates, you can provide to your developers some state-of-the-art project (in term of coding, ci/cd, security, documentation) which will be automatically pushed in a repo of your scm system (Github, Gitlab  Bitbucket, ...). And they will follow the best practices because it helps them.&lt;/p&gt;

&lt;p&gt;Software Templates can also be used to onboard an existing component in Backstage by creating a pull request (on Github) or a merge request (on Gitlab) which propose to the project to add in the repo the catalog-info.yaml file used by Backstage to index the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn from the community
&lt;/h2&gt;

&lt;p&gt;The best way to start with Software Templates is to learn from others.&lt;/p&gt;

&lt;p&gt;The first place to learn is, of course, the &lt;a href="https://backstage.io/docs/features/software-templates/" rel="noopener noreferrer"&gt;Backstage documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But, in my opinion, it's easier to see how others are building their templates. For that you should have a look on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/backstage/software-templates/tree/main/scaffolder-templates" rel="noopener noreferrer"&gt;Backstage's Github&lt;/a&gt;, simple but very good to begin,&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/janus-idp/software-templates/tree/main/scaffolder-templates" rel="noopener noreferrer"&gt;Janus's Github&lt;/a&gt; which shows, among many other interesting things, a way to share some piece of templates,&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/RoadieHQ/software-templates/tree/main/scaffolder-templates" rel="noopener noreferrer"&gt;Roadie's Github&lt;/a&gt; where you can find some &lt;a href="https://roadie.io/docs/scaffolder/debug-template/" rel="noopener noreferrer"&gt;tips &lt;/a&gt; to debug your templates&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use Backstage tools
&lt;/h2&gt;

&lt;p&gt;When you begin on Software Templates, as for any other languages, you make mistakes and it's a little bit boring to modify your code, to push it in your Software Templates repository, then to try it in Backstage, to see it does not work.&lt;/p&gt;

&lt;p&gt;Fortunately, Backstage will help you with that. There is a special place in Backstage for trying and tuning your templates. You can try it on &lt;a href="https://YourBackstageInstance/create/edit" rel="noopener noreferrer"&gt;https://YourBackstageInstance/create/edit&lt;/a&gt;. For instance, on the &lt;a href="https://showcase.janus-idp.io/create/edit" rel="noopener noreferrer"&gt;janus showcase portal&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6570qesbdkuriu88rrr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6570qesbdkuriu88rrr.jpg" alt="Backstage create edit page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Edit template form
&lt;/h3&gt;

&lt;p&gt;When you click on Edit template form, you access to a place where you will be able to write your template, and to see immediately if it works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpw8r3r7g27wnx7l6d834.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpw8r3r7g27wnx7l6d834.png" alt="Backstage create edit template form"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Custom field explorer
&lt;/h3&gt;

&lt;p&gt;Paraphrasing the documentation of Backstage, collecting input from the user is a very large part of the scaffolding process and Software Templates as a whole. These input are made in software templates by using custom fields, for instance the &lt;a href="https://backstage.io/docs/features/software-templates/writing-templates#the-repository-picker" rel="noopener noreferrer"&gt;Repository Picker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes, it's not easy to understand all the possibilities of these objects.&lt;/p&gt;

&lt;p&gt;Here again, you can explore them with the custom field explorer, for instance the OwnerEntityPicker:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8v6wlesxxz56wp9ckvof.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8v6wlesxxz56wp9ckvof.jpg" alt="Backstage create edit custom field"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, we add group in allowedKinds to limit the choice on groups, and we can see immediately the result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffm251nbtegwngegpwn5f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffm251nbtegwngegpwn5f.jpg" alt="Backstage create edit custom field result"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Built-in actions
&lt;/h3&gt;

&lt;p&gt;There are three parts in a software template:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;em&gt;&lt;a href="https://github.com/backstage/software-templates/blob/main/scaffolder-templates/clean-architecture-app/template.yaml#L17" rel="noopener noreferrer"&gt;parameters&lt;/a&gt;&lt;/em&gt; where you get inputs from your customer&lt;/li&gt;
&lt;li&gt;the &lt;em&gt;&lt;a href="https://github.com/backstage/software-templates/blob/main/scaffolder-templates/clean-architecture-app/template.yaml#L93" rel="noopener noreferrer"&gt;steps&lt;/a&gt;&lt;/em&gt; where you do some things with information collected in the first part&lt;/li&gt;
&lt;li&gt;the &lt;em&gt;&lt;a href="https://github.com/backstage/software-templates/blob/main/scaffolder-templates/clean-architecture-app/template.yaml#L127" rel="noopener noreferrer"&gt;output&lt;/a&gt;&lt;/em&gt; where you give some information to your customer about the tasks done by the template.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To do things in &lt;em&gt;steps&lt;/em&gt;, you use &lt;a href="https://backstage.io/docs/features/software-templates/builtin-actions" rel="noopener noreferrer"&gt;builtin actions&lt;/a&gt;, and all these actions are not listed in the documentation. But there are listed directly in the application on &lt;a href="https://YourBackstageInstance/create/actions" rel="noopener noreferrer"&gt;https://YourBackstageInstance/create/actions&lt;/a&gt;. For instance, on the &lt;a href="https://showcase.janus-idp.io/create/actions" rel="noopener noreferrer"&gt;janus showcase portal&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftezs6ime0pvpo3qlkzth.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftezs6ime0pvpo3qlkzth.jpg" alt="Backstage builtin actions page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's very useful when you want to know all capabilities of an action, for instance publish:gitlab&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8n9tix94zmbbqwyyauwf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8n9tix94zmbbqwyyauwf.png" alt="Backstage builtin actions publish gitlab"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some actions have even some examples:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4dsgahzm9jqo5l2xxu72.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4dsgahzm9jqo5l2xxu72.jpg" alt="Backstage builtin actions debug examples"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;To faster you Backstage Software Templates learning curve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;learn from the community&lt;/li&gt;
&lt;li&gt;use Backstage embedded tools&lt;/li&gt;
&lt;li&gt;ask for help on &lt;a href="https://discord.com/channels/687207715902193673/923143744176418836" rel="noopener noreferrer"&gt;Backstage's discord&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>backstage</category>
      <category>idp</category>
      <category>devsecops</category>
    </item>
  </channel>
</rss>
