func()

in internal/output/gcppubsub/gcppubsub.go [142:159]


func (o *Output) createTopic() error {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	topic := o.client.Topic(o.opts.GCPPubsubOptions.Topic)
	exists, err := topic.Exists(ctx)
	if err != nil {
		return fmt.Errorf("failed to check if topic exists: %w", err)
	}

	if !exists {
		if _, err := o.client.CreateTopic(ctx, o.opts.GCPPubsubOptions.Topic); err != nil {
			return fmt.Errorf("failed to create the topic: %w", err)
		}
	}

	return nil
}