Skip to content

Allow to pass custom spec -> definition for API entity #74

@HolmesInc

Description

@HolmesInc

Describe Request:

I would like to pass custom definitions (like Kafka topics) to a catalog-info API entity definition but because of hardcoded validator rule it's impossible to do that and pass validation.
Could you please add the possibility to pass definition options?

Examples:

apiVersion: backstage.io/v1alpha1
kind: API
metadata:
  namespace: my-namespace
  name: api-name
  annotations:
    gitlab.com/project-id: '12345678'
spec:
  type: api-type
  owner: group:owner-group
  lifecycle: experimental
  definition:
    $topic: topic.area.name.1

Validation of this catalog info will fail because of hardcoded tule here:

function modifyPlaceholders(obj) {
  for (const k in obj) {
    if (typeof obj[k] === 'object') {
      try {
        if (obj[k].$text || obj[k].$openapi || obj[k].$asyncapi) {
          obj[k] = 'DUMMY TEXT';
          return;
        }
      } catch (e) {
        throw new Error(
          `Placeholder with name '${k}' is empty. Please remove it or populate it.`,
        );
      }
      modifyPlaceholders(obj[k]);
    }
  }
}

But with the following update, it'll pass:

function modifyPlaceholders(obj, condition) {
  for (const k in obj) {
    if (typeof obj[k] === 'object') {
      try {
        for (const c of condition) {
          if (obj[k][c]) {
            obj[k] = 'DUMMY TEXT';
            return;
          }
        }
      } catch (e) {
        throw new Error(
          `Placeholder with name '${k}' is empty. Please remove it or populate it.`,
        );
      }
      modifyPlaceholders(obj[k], condition);
    }
  }
}

Where const condition = ['$text', '$openapi', '$asyncapi', '$topic']

Supporting Documentation Links:

https://github.com/RoadieHQ/roadie-backstage-plugins/blob/0b7f60228b6de7c7d0baa5033aff6b105d258d5b/utils/roadie-backstage-entity-validator/src/validator.js#L39C1-L55C2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions