Skip to content

AmitBenAmi/cfcrmigration

 
 

Repository files navigation

cfcf migration - pipeline identification

This is a sample node.js based script to find all pipelines under a codefresh account impacted by codefresh integreted registry, cfcr deprectation.

More about CFCR registry depreaction - https://codefresh.io/docs/docs/docker-registries/cfcr-deprecation/

script logic

This script identifies the various pipelines in the following order.

  1. Find metadata for all pipelines under an account using the restapi.

  2. Breakdown metada into 2 buckets 2.1 Inline Pipelines Spec metada 2.2 Pipelines with step definition stored as part of last build.

  3. Inspect all the inline steps for the following steps types.

    3.1 build steps using codefresh type:build

    3.2 push steps using codefresh type:push and registry:'cfcr'

    3.3 pull steps using image registry containing 'r.cfcr.io/*'

    collect the pipeline and steps details of those pipelines matching 3.1, 3.2 and 3.3 criteria into an output csv report file.

  4. Inspect those pipelines, not having inline steps definiton but the yaml stored in a last build..

    4.1 Retreive the pipeline definion from the last build and convert into a json format.

    4.2 build steps using codefresh type:build

    4.3 push steps using codefresh type:push and registry:'crcf'

    4.4 pull steps using image registry containing 'r.cfcr.io/*'

    collect the pipeline and steps details of those pipelines fulfilling the 4.2,4.3 and 4.4 into an output csv report file.

How to run the script

  1. using docker

Build docker image locally using the following build command

docker build . -t cfcrpips

create an output folder to generate your report.

E.g

mkdir output 
chmod 777 output

Run a docker container out of the image that you just built, passing in APIKEY and the output folder as mount points.

docker run -e APIKEY="yourapikey" -e outputfolder="/output"  -e skipInline=true -v /tmp/cfcrmig/cfcrmigration/output:/output cfcrpips:latest
  1. Run this script as a node js script using node cli, passing the codefresh account API key as an env value by keeping it in .env file.

To run this script install node.js and then run as follows

./node CFCRpipidentifier.js

Output

Script will generate a run log and a csv file report of the pieplines that need to be changed under /output folder. The output folder can be changed by passing a differetn fodler path through outputfolder enviroment variable.

Output files produced are

E.g

cfcrmigrationpipelines.csv
run_log.log

About

CFCR registry migration Enablement

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 59.9%
  • Shell 38.0%
  • Dockerfile 2.1%