-
Notifications
You must be signed in to change notification settings - Fork 555
feat: Container Image Exporter Plugin #4556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
691960c
image exporter plugin added
kamal-devtron aaf7025
image exporter plugin
kamal-devtron 0ca5f2b
Changes in description
kamal-devtron 206a896
Change in name of plugin
kamal-devtron 7222d3f
Change in name of plugin
kamal-devtron 3ceb132
Change in plugin name
kamal-devtron 8e092e7
Change in plugin name and remove md file
kamal-devtron 8e1ab9d
Change in plugin name and remove md file
kamal-devtron b90b6d8
Change in description
kamal-devtron 4fb45a3
Change in description
kamal-devtron ac5de45
Added conditions for platform
kamal-devtron d286125
refactoring
kamal-devtron 1fa4deb
added plugin image
kamal-devtron 2abb7a9
added plugin image
kamal-devtron 7a840ad
added plugin image
kamal-devtron c2b0c6e
added new plugin image
kamal-devtron 604d210
removed unused image
kamal-devtron f70d9b6
remame of sql file
kamal-devtron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| DELETE FROM plugin_step_variable WHERE plugin_step_id =(SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false); | ||
| DELETE from plugin_pipeline_script where id = (SELECT script_id from plugin_step WHERE plugin_id=(SELECT id FROM plugin_metadata WHERE name='Container Image Exporter v1.0.0')); | ||
| DELETE FROM plugin_step WHERE plugin_id=(SELECT id FROM plugin_metadata WHERE name='Container Image Exporter v1.0.0'); | ||
| DELETE FROM plugin_stage_mapping WHERE plugin_id =(SELECT id FROM plugin_metadata WHERE name='Container Image Exporter v1.0.0'); | ||
| DELETE FROM plugin_metadata WHERE name ='Container Image Exporter v1.0.0'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| -- Plugin metadata | ||
| INSERT INTO "plugin_metadata" ("id", "name", "description","type","icon","deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_metadata'), 'Container Image Exporter v1.0.0','Create Tarball of your Docker images','PRESET','https://raw.githubusercontent.com/devtron-labs/devtron/main/assets/vClutser.png','f', 'now()', 1, 'now()', 1); | ||
|
|
||
| -- Plugin Stage Mapping | ||
|
|
||
| INSERT INTO "plugin_stage_mapping" ("plugin_id","stage_type","created_on", "created_by", "updated_on", "updated_by") | ||
| VALUES ((SELECT id FROM plugin_metadata WHERE name='Container Image Exporter v1.0.0'),0,'now()', 1, 'now()', 1); | ||
|
|
||
| -- Plugin Script | ||
|
|
||
| INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_on", "created_by", "updated_on", "updated_by") | ||
| VALUES ( | ||
| nextval('id_seq_plugin_pipeline_script'), | ||
| E'#!/bin/bash | ||
| set -eo pipefail | ||
|
|
||
| DOCKER_IMAGE=$image | ||
| echo $platform | ||
| current_timestamp=$(date +%s) | ||
| if [[ -z $FilePrefix ]] | ||
| then | ||
| file=$ContainerImage.tar | ||
| file=$(echo $file | tr \'/\' \'_\') | ||
| else | ||
| file=$FilePrefix-$ContainerImage.tar | ||
| file=$(echo $file | tr \'/\' \'_\') | ||
| fi | ||
| echo $file | ||
| future_timestamp=$((current_timestamp + $Expiry * 60)) | ||
| future_date=$(date -u -d@"$future_timestamp" +"%Y-%m-%dT%H:%M:%SZ") | ||
| aws_secs=$(($Expiry * 60)) | ||
| docker pull --platform linux/$Platform $ContainerImage | ||
| docker save $ContainerImage > $file | ||
| ls | ||
| if [ $CloudProvider == "azure" ] | ||
| then | ||
| docker run --rm -v $(pwd):/data mcr.microsoft.com/azure-cli /bin/bash -c " az storage blob upload --account-name $AzureAccountName --account-key $AzureAccountKey --container-name $BucketName --name $file --file data/$file" | ||
| echo "docker run --rm mcr.microsoft.com/azure-cli /bin/bash -c " az storage blob generate-sas --account-name $AzureAccountName --account-key $AzureAccountKey --container-name $BucketName --name $file --permissions r --expiry $future_date"" | ||
| sas_token=$(docker run --rm mcr.microsoft.com/azure-cli /bin/bash -c " az storage blob generate-sas --account-name $AzureAccountName --account-key $AzureAccountKey --container-name $BucketName --name $file --permissions r --expiry $future_date") | ||
| token=$sas_token | ||
| echo $token | ||
| token=$(echo $sas_token| tr -d \'"\') | ||
| echo $token | ||
| link=https://$AzureAccountName.blob.core.windows.net/$BucketName/$file?$token | ||
| fi | ||
| if [ $CloudProvider == "aws" ] | ||
| then | ||
| echo "aws command" | ||
| docker run --rm -v $(pwd):/data -e AWS_ACCESS_KEY_ID=$AwsAccessKey -e AWS_SECRET_ACCESS_KEY=$AwsSecretKey amazon/aws-cli:latest s3 cp /data/$file s3://$BucketName --region $AswRegion | ||
| link=$(docker run --rm -v $(pwd):/data -e AWS_ACCESS_KEY_ID=$AwsAccessKey -e AWS_SECRET_ACCESS_KEY=$AwsSecretKey amazon/aws-cli:latest s3 presign s3://$BucketName/$file --region $AswRegion --expires-in $aws_secs ) | ||
| fi | ||
| echo "***Copy the below link to download the tar file***" | ||
| echo $link | ||
| ', | ||
| 'SHELL', | ||
| 'f', | ||
| 'now()', | ||
| 1, | ||
| 'now()', | ||
| 1 | ||
| ); | ||
|
|
||
|
|
||
| --Plugin Step | ||
|
|
||
| INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_step'), (SELECT id FROM plugin_metadata WHERE name='Container Image Exporter v1.0.0'),'Step 1','Creating Image Tar of image','1','INLINE',(SELECT last_value FROM id_seq_plugin_pipeline_script),'f','now()', 1, 'now()', 1); | ||
pawan-mehta-dt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| -- Input Variables | ||
|
|
||
| INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value", "variable_type", "value_type", "variable_step_index", "deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'Platform','STRING','Please specify the platform architecture of the image being exported (arm64 or amd64).',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
pawan-mehta-dt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'AswRegion','STRING','Please specify the AWS region where your S3 bucket is located ',true,true,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'AwsAccessKey','STRING','Please provide your AWS access key ID. ',true,true,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'AwsSecretKey','STRING','Please provide your AWS secret access key. Keep this key confidential.',true,true,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'AzureAccountKey','STRING','Please provide the access key for your Azure storage account.',true,true,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'AzureAccountName','STRING','Please specify the name of your Azure storage account.',true,true,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'FilePrefix','STRING','If youd like to add a prefix to the exported image files name, please enter it here.',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'CloudProvider','STRING','Please indicate which cloud storage provider you want to use: "aws" for Amazon S3 or "azure" for Azure Blob Storage.',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'Expiry','STRING','Must be a whole number between 1 and 720 minutes',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'BucketName','STRING','Please enter the name of the storage container where you want to upload the exported image file.',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), (SELECT ps.id FROM plugin_metadata p inner JOIN plugin_step ps on ps.plugin_id=p.id WHERE p.name='Container Image Exporter v1.0.0' and ps."index"=1 and ps.deleted=false), 'ContainerImage','STRING','Provide the image from system variable',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.