You can't directly call Cloud Functions from a Cron job, as it's an App Engine service, but you can call an App Engine handler from your Cron job, and make that handler call your Cloud Function, using whichever information you want to use from Pub/Sub.
There is an example here, which is basically what I said. You can substitute it to use Node.js in App Engine instead of Python:
const express = require('express');
const app = express();
app.get('/', (req, res) => {
const request = require('request');
request('YOUR_FUNCTION_URL', { json: false }, (err, res, body) => {
if (err) {
return console.log(err);
}
res
.status(200)
.send('Trigger called')
.end();
});
});
// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
EDIT:
Cloud Scheduler is a new service (as of right now in beta) which can create cron jobs that target either App Engine, Pub/Sub or URL's. In your case, you can set up one job hitting the URL of your function, as mentioned in here. It's much simpler.