* playing around with csv parsing action * switch to workflow dispatch * working script * add a check to not run on forks * adding check comment * no idea who should own, adding myself for now * adding the cleanup script too
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
import { parse } from 'csv-parse/sync';
|
|
import fs from 'fs';
|
|
|
|
/***
|
|
* Feauture Flag Structure example
|
|
* Name: 'disableEnvelopeEncryption',
|
|
Stage: 'GA',
|
|
Owner: '@grafana/grafana-as-code',
|
|
Created: '2022-05-24',
|
|
requiresDevMode: 'false',
|
|
RequiresLicense: 'false',
|
|
RequiresRestart: 'false',
|
|
FrontendOnly: 'false'
|
|
*
|
|
*/
|
|
|
|
|
|
export default function cleanupFeatureFlags() {
|
|
const today = new Date();
|
|
const sixMonthAgo = today.setMonth(today.getMonth() - 6);
|
|
const inputFileContents = fs.readFileSync(process.env.FEATURE_TOGGLES_CSV_FILE_PATH);
|
|
const parsedFeatureFlags = parse(inputFileContents, {
|
|
columns: true,
|
|
skip_empty_lines: true,
|
|
cast: true,
|
|
cast_date: true,
|
|
});
|
|
|
|
// Here we can have the custom logic of how to handle what type of feature flag - e.g. GA can be treated differently than experimental and so on.
|
|
for (const flag of parsedFeatureFlags) {
|
|
if (flag.Created < sixMonthAgo) {
|
|
console.log(`The flag ${flag.Name} was created more than 6 months ago. It should be checked.`);
|
|
console.log(flag);
|
|
}
|
|
}
|
|
|
|
|
|
}
|