본문 바로가기
WIKI 기술 지식 베이스

나만의 템플릿 추가하기

원문 보기 위키 갱신

템플릿은 소프트웨어 카탈로그에 Template 종류 아래에 저장됩니다.

출처: 문서

본문

템플릿은 소프트웨어 카탈로그에 Template 종류 아래에 저장됩니다. 템플릿을 정의하는 데 필요한 최소한은 template.yaml 파일이지만, 템플릿화할 수 있는 파일도 몇 개 있는 것이 좋습니다.

간단한 template.yaml 정의는 다음과 비슷할 수 있습니다.

apiVersion: scaffolder.backstage.io/v1beta3kind: Template# some metadata about the template itselfmetadata:  name: v1beta3-demo  title: Test Action template  description: scaffolder v1beta3 template demospec:  owner: backstage/techdocs-core  type: service  # these are the steps which are rendered in the frontend with the form input  parameters:    - title: Fill in some steps      required:        - name      properties:        name:          title: Name          type: string          description: Unique name of the component          ui:autofocus: true          ui:options:            rows: 5    - title: Choose a location      required:        - repoUrl      properties:        repoUrl:          title: Repository Location          type: string          ui:field: RepoUrlPicker          ui:options:            allowedHosts:              - github.com  # here's the steps that are executed in series in the scaffolder backend  steps:    - id: fetchBase      name: Fetch Base      action: fetch:template      input:        url: ./template        values:          name: ${{ parameters.name }}    - id: fetchDocs      name: Fetch Docs      action: fetch:plain      input:        targetPath: ./community        url: https://github.com/backstage/community/tree/main/backstage-community-sessions    - id: publish      name: Publish      action: publish:github      input:        description: This is ${{ parameters.name }}        repoUrl: ${{ parameters.repoUrl }}        defaultBranch: 'main'    - id: register      name: Register      action: catalog:register      input:        repoContentsUrl: ${{ steps['publish'].output.repoContentsUrl }}        catalogInfoPath: '/catalog-info.yaml'

Template Entity는 필수 필드에 대한 더 많은 정보를 담고 있습니다.

template.yaml이 준비되면, 스캐폴더가 사용할 수 있도록 소프트웨어 카탈로그에 추가할 수 있습니다.

참고

템플릿을 추가하거나 수정하면 로케이션 엔티티를 새로고침해야 합니다. 그렇지 않으면 Backstage가 템플릿을 사용 가능한 템플릿에 표시하지 않거나, 계속 이전 템플릿을 보여줄 것입니다. 로케이션 인스턴스를 새로고침하려면 Catalog 웹 페이지로 가서, Components 대신 Locations를 선택하고 올바른 로케이션 엔티티를 선택하세요. 거기서 "Scheduled entity refresh" 액션을 나타내는 새로고침 아이콘을 클릭할 수 있습니다. 그러면 템플릿이 갱신된 것을 볼 수 있을 것입니다.

정적 로케이션 구성을 통해 템플릿 파일을 카탈로그에 추가할 수 있습니다. 예를 들어:

catalog:  locations:    - type: url      target: https://github.com/backstage/software-templates/blob/main/scaffolder-templates/react-ssr-template/template.yaml      rules:        - allow: [Template]    - type: file      target: template.yaml # Backstage will expect the file to be in packages/backend/template.yaml

또는 catalog-import 플러그인을 사용해 템플릿을 추가할 수 있으며, 다르게 구성하지 않았다면 그것은 /catalog-import에서 실행되어야 합니다.

자신만의 템플릿을 작성하는 방법에 대한 정보는 여기 문서를 확인해 보세요.

수동 수집 없이 템플릿을 발견할 방법을 찾고 있다면, 여러 옵션이 있습니다. 한 가지 접근 방식은 GitHub Discovery 같은 Discovery 제공자를 활용하는 것입니다.

대안으로 외부 통합을 설정할 수도 있습니다. 이것은 External Integration에서 언급한 것처럼, 필요에 맞는 템플릿을 호스팅할 수 있는 외부 소스나 플랫폼에 시스템을 연결하는 것을 포함합니다.

더 알아보기 (Learn more)