export function optionsToTriggerAnnotations()

in src/v2/options.ts [232:287]


export function optionsToTriggerAnnotations(
  opts: GlobalOptions | EventHandlerOptions
): TriggerAnnotation {
  const annotation: TriggerAnnotation = {};
  copyIfPresent(
    annotation,
    opts,
    'concurrency',
    'minInstances',
    'maxInstances',
    'ingressSettings',
    'labels',
    'vpcConnector',
    'vpcConnectorEgressSettings'
  );
  convertIfPresent(
    annotation,
    opts,
    'availableMemoryMb',
    'memory',
    (mem: MemoryOption) => {
      return MemoryOptionToMB[mem];
    }
  );
  convertIfPresent(annotation, opts, 'regions', 'region', (region) => {
    if (typeof region === 'string') {
      return [region];
    }
    return region;
  });
  convertIfPresent(
    annotation,
    opts,
    'serviceAccountEmail',
    'serviceAccount',
    serviceAccountFromShorthand
  );
  convertIfPresent(
    annotation,
    opts,
    'timeout',
    'timeoutSeconds',
    durationFromSeconds
  );
  convertIfPresent(
    annotation,
    (opts as any) as EventHandlerOptions,
    'failurePolicy',
    'retry',
    (retry: boolean) => {
      return retry ? { retry: true } : null;
    }
  );

  return annotation;
}