Giter Site home page Giter Site logo

extension_migration's Introduction

Salt Extension Migration

This repository is used to track and coordinate the migration of Salt modules to extensions.

Getting Started

Follow these steps to set up your development environment and migrate Salt modules to extensions.

1. Set Up Your Working Environment

Create an empty working directory and navigate into it:

mkdir working-dir
cd working-dir

2. Create a Directory for Extension Migration

Inside the working directory, create an empty directory to hold the extension migration files:

mkdir apache
cd apache

3. Create the New Salt Extension

Use the copier template for the latest framework of Salt Extensions. This is the preferred way to create a new extension, as there is a lot of shared code between extensions that is easier to keep in sync with copier.

Install copier

pip install copier copier-templates-extensions
copier copy --trust https://github.com/salt-extensions/salt-extension-copier saltext-apache

4. Set Up the Extension Repository

Navigate into the extension directory:

cd saltext-apache

If you used the copier command to create the extension, it creates some boilerplate modules and tests that we want to get rid of before we pull in the actual code from Salt.

find src tests -type f ! -name __init__.py ! -name conftest.py -delete

Initialize it as a Git repository:

git init --initial-branch=main
pip install pre-commit  # may not need to be done again if in a pre-existing virtual environment
pre-commit install
git add .
git commit -m "Initial commit of extension framework"

*You may need to pip install git-filter-repo and pylint. If you are using git < 2.28, the initial-branch option is not present and git init will default to the branch being "master" instead of "main". Note that you won't be able to change it with git branch -m master main until after your first commit.

Note: In case of failures due to pinned project dependencies, clean out build and artifacts like below, and try again.

sudo rm -rf ./build/*
sudo rm -rf ./artifacts/*
git add .
git commit -m "Initial commit of extension framework"

Migrating Salt Modules to Extensions

Follow these instructions to migrate Salt modules to extensions.

1. Dry Run Migration

First, git clone this extension-migration to your local environment into a separate folder, not in your saltext-_____ (if it isn't already).

then, cd into the directory before saltext-_______ (example, the helm directory instead of saltext-helm)

To perform a dry run migration of modules that contain "apache" in their name from a branch called "filter-source" into an extension directory called "saltext-apache", use the following command:

extension-migrate.py --dry_run \
    --file_filter apache \
    --source_branch filter-source \
    --extension_dir saltext-apache

Note that all the dry-run does is preprare the command and then echo it to the terminal. If you run the dry run, and then the actual migration, you may get a fatal error complaining something already is created. This is not actaully a fatal error and can be safely ignored.

2. Actual Migration

To perform the actual migration of modules, use the following command:

extension-migrate.py --file_filter apache \
    --source_branch filter-source \
    --extension_dir saltext-apache

3. Conflict Resolution

If there are any merge conflicts, resolve them manually.

4. Merge Changes

Merge the "filter-target" branch into the main branch:

git add .
git commit -m "Merging in modules from Salt"
git checkout main
git merge filter-target

5. Code Refactoring

Change any references of __utils__ to salt.utils:

SALTEXT_NAME=apache salt-rewrite -F fix_saltext_utils_imports .

6. Push Changes

Finally, push the changes to the Salt extension's repository. Contact an Owner of the salt-extensions organization to obtain a repository for your Extension.

extension_migration's People

Contributors

garethgreenaway avatar nicholasmhughes avatar snelzing avatar m3gh4nn avatar lkubb avatar

Watchers

 avatar Megan Wilhite avatar

extension_migration's Issues

Migrate FreeBSD modules to extension

modules/freebsdjail.py
modules/freebsdkmod.py
modules/freebsdpkg.py
modules/freebsdports.py states/ports.py
modules/freebsdservice.py
modules/freebsd_sysctl.py
modules/freebsd_update.py

Migrate smartos modules to extension

modules/smartos_imgadm.py
beacons/smartos_imgadm.py
modules/smartos_vmadm.py
modules/smartos_nictagadm.py
modules/smartos_vmadm.py
beacons/smartos_vmadm.py
modules/smartos_virt.py
states/smartos.py

test

Nothing\nworks

Migrate boto modules to extension

modules/boto3_elasticache.py, states/boto3_elasticache.py
modules/boto3_elasticsearch.py, states/boto3_elasticsearch.py
modules/boto3_route53.py, states/boto3_route53.py
modules/boto3_sns.py, states/boto3_sns.py
modules/boto_apigateway.py, states/boto_apigateway.py
modules/boto_asg.py, modules/boto_cloudwatch.py, states/boto_asg.py, states/boto_lc.py
modules/boto_cfn.py, states/boto_cfn.py
modules/boto_cloudfront.py, states/boto_cloudfront.py
modules/boto_cloudtrail.py, states/boto_cloudtrail.py
modules/boto_cloudwatch_event.py, states/boto_cloudwatch_event.py
modules/boto_cloudwatch.py, states/boto_cloudwatch_alarm.py
modules/boto_cognitoidentity.py, states/boto_cognitoidentity.py
modules/boto_datapipeline.py, states/boto_datapipeline.py
modules/boto_dynamodb.py, states/boto_dynamodb.py
modules/boto_ec2.py, states/boto_asg.py, states/boto_ec2.py, states/boto3_route53.py, states/boto_elb.py, states/boto_vpc.py, states/boto_route53.py
modules/boto_efs.py,
modules/boto_elasticache.py, states/boto_elasticache.py
modules/boto_elasticsearch_domain.py, states/boto_elasticsearch_domain.py
modules/boto_elb.py, states/boto_elb.py
modules/boto_elbv2.py, states/boto_elbv2.py
modules/boto_iam.py, modules/boto_cognitoidentity.py, modules/boto_sns.py, modules/boto_s3_bucket.py, modules/boto_apigateway.py, modules/boto_cloudtrail.py, modules/boto_lambda.py, states/boto_iam_role.py, states/boto_s3_bucket.py, states/boto_iam.py, states/boto_lambda.py
modules/boto_iot.py, states/boto_iot.py
modules/boto_kinesis.py, states/boto_kinesis.py
modules/boto_kms.py, states/boto_kms.py
modules/boto_lambda.py, states/boto_apigateway.py, states/boto_lambda.py
modules/boto_rds.py, modules/boto_rds.py, states/boto_rds.py
modules/boto_route53.py, states/boto_route53.py
modules/boto_s3_bucket.py, states/boto_s3_bucket.py
modules/boto_s3.py, states/boto_s3.py
modules/boto_secgroup.py, modules/boto_asg.py, modules/boto_ec2.py, modules/boto_lambda.py, modules/boto3_elasticache.py, modules/boto_rds.py, states/boto_asg.py, states/boto_ec2.py, states/boto_elasticache.py, states/boto_elb.py, states/boto_secgroup.py, states/boto_lambda.py
modules/boto_sns.py, states/boto_sns.py
modules/boto_sqs.py, states/boto_sqs.py
modules/boto_ssm.py,
modules/boto_vpc.py, modules/boto_ec2.py, modules/boto_elasticache.py, modules/boto3_route53.py, modules/boto_secgroup.py, modules/boto_lambda.py, modules/boto3_elasticache.py, modules/boto_route53.py, states/boto_asg.py, states/boto3_route53.py, states/boto_elb.py, states/boto_vpc.py, states/boto_lambda.py, states/boto_route53.py, states/boto_rds.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.