mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
renamed to extend, read module name and description at prompt
This commit is contained in:
parent
ad77f799df
commit
ee3ea218f8
4 changed files with 68 additions and 0 deletions
56
salt/utils/extend.py
Normal file
56
salt/utils/extend.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
SaltStack Extend
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from datetime import date
|
||||
|
||||
try:
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
from cookiecutter.main import cookiecutter as cookie
|
||||
import cookiecutter.prompt as prompt
|
||||
HAS_COOKIECUTTER = True
|
||||
except ImportError as ie:
|
||||
HAS_COOKIECUTTER = False
|
||||
|
||||
MODULE_OPTIONS = [
|
||||
('module', 'Execution module'),
|
||||
('state', 'State module'),
|
||||
]
|
||||
|
||||
|
||||
def run():
|
||||
assert HAS_COOKIECUTTER
|
||||
|
||||
print('Choose which kind of extension you are developing for SaltStack')
|
||||
extension_type = 'Extension type'
|
||||
extension_type = prompt.read_user_choice(extension_type, MODULE_OPTIONS)
|
||||
|
||||
print('Enter the short name for the module (e.g. mymodule)')
|
||||
extension_module_name = prompt.read_user_variable('Module name', '')
|
||||
|
||||
short_description = prompt.read_user_variable('Short description of the module', '')
|
||||
|
||||
template_dir = 'templates/{0}'.format(extension_type[0])
|
||||
project_name = extension_module_name
|
||||
|
||||
param_dict = {
|
||||
"full_name": "",
|
||||
"email": "",
|
||||
"project_name": project_name,
|
||||
"project_slug": 'salt',
|
||||
"repo_name": project_name,
|
||||
"project_short_description": short_description,
|
||||
"release_date": date.today().strftime('%Y-%m-%d'),
|
||||
"year": date.today().strftime('%Y'),
|
||||
"version": "0.1.1"
|
||||
}
|
||||
|
||||
cookie(template=template_dir,
|
||||
no_input=True,
|
||||
extra_context=param_dict)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
8
scripts/salt-extend
Executable file
8
scripts/salt-extend
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
'''
|
||||
Quickstart for creating an/or extending the functionality of your SaltStack installation
|
||||
'''
|
||||
from salt.scripts import salt_extend
|
||||
|
||||
if __name__ == '__main__':
|
||||
salt_extend()
|
4
templates/module/cookiecutter.json
Normal file
4
templates/module/cookiecutter.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"project_slug": "salt",
|
||||
"open_source_license": ["Apache Software License 2.0"]
|
||||
}
|
Loading…
Add table
Reference in a new issue