q-shift / backstage-playground

2 stars 8 forks source link

Create bash script to generate app-config.local.yaml file from template #6

Open jacobdotcosta opened 8 months ago

jacobdotcosta commented 8 months ago

Create a bash script to generate a app-config.local.yaml file from a template and to ask some questions to the user to provide their:

cmoulliard commented 8 months ago

Here is the template that we should use:

# Backstage override configuration for QShift

organization:
  name: QShift

app:
  title: QShift Backstage App
  baseUrl: ${BACKSTAGE_URL}:3000 (we add the port only for localhost)

backend:
  baseUrl: ${BACKSTAGE_URL}:7007 (we add the port only for localhost)
  listen:
    port: 7007
  csp:
    connect-src: ["'self'", 'http:', 'https:']
    # Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference
    # Default Helmet Content-Security-Policy values can be removed by setting the key to false
  cors:
    origin: http://localhost:3000
    methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
    credentials: true
  # This is for local development only, it is not recommended to use this in production
  # The production database configuration is stored in app-config.production.yaml
  database:
    client: better-sqlite3
    connection: ':memory:'
  auth:
    # Used for enabling authentication, secret is shared by all backend plugins
    # See https://backstage.io/docs/auth/service-to-service-auth for
    # information on the format
    keys:
      - secret: Tg3vL6P2w74xP/fcSpmv0ulZw2Lx1wsr

auth:
  # see https://backstage.io/docs/auth/ to learn about auth providers
  providers: {}

proxy:
### Example for how to add a proxy endpoint for the frontend.
### A typical reason to do this is to handle HTTPS and CORS for internal services.
# endpoints:
#   '/test':
#     target: 'https://example.com'
#     changeOrigin: true

# Reference documentation http://backstage.io/docs/features/techdocs/configuration
# Note: After experimenting with basic setup, use CI/CD to generate docs
# and an external cloud storage when deploying TechDocs for production use-case.
# https://backstage.io/docs/features/techdocs/how-to-guides#how-to-migrate-from-techdocs-basic-to-recommended-deployment-approach
techdocs:
  builder: 'local' # Alternatives - 'external'
  generator:
    runIn: 'docker' # Alternatives - 'local'
  publisher:
    type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.

catalog:
  import:
    entityFilename: catalog-info.yaml
  rules:
    - allow: [ Component, System, API, Resource, Location ]
  locations:
    # Quarkus template, org, entity
    - type: url
      target: ${TEMPLATE_URL} (default could be : https://github.com/ch007m/my-backstage-templates/blob/main/qshift/all.yaml)
      rules:
        - allow: [Template,Location,Component,System,Resource,User,Group]

integrations:
  github:
    - host: github.com
      token: ${GITHUB_PERSONAL_ACCESS_TOKEN}

argocd:
  username: admin
  password: ${ARGOCD_ADMIN_PASSWORD}
  baseUrl: ${ARGOCD_SERVER}
  appLocatorMethods:
    - type: config
      instances:
        - name: argocdQShift
          url: ${ARGOCD_SERVER}

kubernetes:
  serviceLocatorMethod:
    type: 'multiTenant'
  clusterLocatorMethods:
    - type: 'config'
      clusters:
        - url: https://kubernetes.default.svc
          name: ocp-qshift
          authProvider: 'serviceAccount'
          skipTLSVerify: true
          skipMetricsLookup: true
          serviceAccountToken: ${SERVICE_ACCOUNT_TOKEN} (we should provide the command to be issued to got it !!

to generate this app-config.qshift.local at the root of the project (it is ignored by git)

# Backstage override configuration for QShift

organization:
  name: QShift

app:
  title: QShift Backstage App
  baseUrl: http://localhost:3000

backend:
  baseUrl: http://localhost:7007
  listen:
    port: 7007
    # Uncomment the following host directive to bind to specific interfaces
    # host: 127.0.0.1
  csp:
    connect-src: ["'self'", 'http:', 'https:']
    # Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference
    # Default Helmet Content-Security-Policy values can be removed by setting the key to false
  cors:
    origin: http://localhost:3000
    methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
    credentials: true
  # This is for local development only, it is not recommended to use this in production
  # The production database configuration is stored in app-config.production.yaml
  database:
    client: better-sqlite3
    connection: ':memory:'
  auth:
    # Used for enabling authentication, secret is shared by all backend plugins
    # See https://backstage.io/docs/auth/service-to-service-auth for
    # information on the format
    keys:
      - secret: Tg3vL6P2w74xP/fcSpmv0ulZw2Lx1wsr

auth:
  # see https://backstage.io/docs/auth/ to learn about auth providers
  providers: {}

proxy:
### Example for how to add a proxy endpoint for the frontend.
### A typical reason to do this is to handle HTTPS and CORS for internal services.
# endpoints:
#   '/test':
#     target: 'https://example.com'
#     changeOrigin: true

# Reference documentation http://backstage.io/docs/features/techdocs/configuration
# Note: After experimenting with basic setup, use CI/CD to generate docs
# and an external cloud storage when deploying TechDocs for production use-case.
# https://backstage.io/docs/features/techdocs/how-to-guides#how-to-migrate-from-techdocs-basic-to-recommended-deployment-approach
techdocs:
  builder: 'local' # Alternatives - 'external'
  generator:
    runIn: 'docker' # Alternatives - 'local'
  publisher:
    type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.

catalog:
  import:
    entityFilename: catalog-info.yaml
  rules:
    - allow: [ Component, System, API, Resource, Location ]
  locations:
    # Quarkus template, org, entity
    - type: url
      target: https://github.com/ch007m/my-backstage-templates/blob/main/qshift/all.yaml
      rules:
        - allow: [Template,Location,Component,System,Resource,User,Group]
    #- type: file
    #  target: ../../examples/org.yaml

integrations:
  github:
    - host: github.com
      token: ######### TOKEN NOT SHOWED ######

argocd:
  username: admin
  password: ######### TOKEN NOT SHOWED ######
  baseUrl: https://openshift-gitops-server-openshift-gitops.apps.qshift.snowdrop.dev
  appLocatorMethods:
    - type: config
      instances:
        - name: argocdQShift
          url: https://openshift-gitops-server-openshift-gitops.apps.qshift.snowdrop.dev

kubernetes:
  serviceLocatorMethod:
    type: 'multiTenant'
  clusterLocatorMethods:
    - type: 'config'
      clusters:
        - url: https://kubernetes.default.svc
          name: ocp-qshift
          authProvider: 'serviceAccount'
          skipTLSVerify: true
          skipMetricsLookup: true
          serviceAccountToken: eyJhbGciOiU.....XTFG