Browse Source

chore: First Jenkins build

pull/1/head
Michael COSTA 6 months ago
parent
commit
4000c1eafb
17 changed files with 116 additions and 2286 deletions
  1. +5
    -3
      .gitignore
  2. +0
    -708
      CHANGELOG.md
  3. +3
    -3
      CONTRIBUTING.md
  4. +3
    -2
      Jenkinsfile
  5. +11
    -8
      Makefile
  6. +32
    -1492
      README.md
  7. +0
    -2
      api/__init__.py
  8. +4
    -19
      requirements.txt
  9. BIN
      scrippy-api.png
  10. +10
    -0
      scrippy_api/__init__.py
  11. +4
    -0
      scrippy_api/api/__init__.py
  12. +15
    -17
      scrippy_api/api/apiloader.py
  13. +20
    -8
      scrippy_api/api/client.py
  14. +0
    -0
      scrippy_api/api/validator.py
  15. +7
    -22
      setup.cfg
  16. +2
    -2
      sonar-project.properties
  17. +0
    -0
      tests/__init__.py

+ 5
- 3
.gitignore View File

@ -1,13 +1,15 @@
*un~
*.swp
*.pyc
*/__pycache__
**/__pycache__/
build/
dist/
infra.egg-info/
python_infra.egg-info/
scrippy_api.egg-info/
test.py
populate_dir.py
.vscode/
venv/
.pytest_cache/
.idea
.coverage
junit_report.xml

+ 0
- 708
CHANGELOG.md View File

@ -1,708 +0,0 @@
# Changelog
Fichier généré automatiquement par auto-changelog
## 1.1.52 (2021-01-20)
#### Fixes
* Makefile: Bad VERSION number
* Makefile: Bad VERSION number
* Makefile: Bad VERSION number
* bumpversion current_version
* Makefile: More targets
* Makefile: More targets
* Makefile: More targets
* Makefile: More targets
* Makefile: More targets
* Makefile
#### Others
* Makefile bumpversion and release targets
* Makefile bumpversion and release targets
Full set of changes: [`1.1.46...1.1.52`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.46...1.1.52)
## 1.1.46 (2020-12-29)
#### Fixes
* remote.ssh.exec_command should not show command unless --debug is used
Full set of changes: [`1.1.45...1.1.46`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.45...1.1.46)
## 1.1.45 (2020-12-29)
#### Fixes
* remote.ssh.exec_command should not show command unless --debug is used
Full set of changes: [`1.1.44...1.1.45`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.44...1.1.45)
## 1.1.44 (2020-12-09)
#### Fixes
* TERM is not defined on remote execution
Full set of changes: [`1.1.43...1.1.44`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.43...1.1.44)
## 1.1.43 (2020-12-09)
#### Fixes
* No more color in Jobscheduler + colors in log files
* No more color in Jobscheduler + colors in log files
* No more color in Jobscheduler + colors in log files
Full set of changes: [`1.1.42...1.1.43`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.42...1.1.43)
## 1.1.42 (2020-11-25)
#### Fixes
* SIN-15126
Full set of changes: [`1.1.41...1.1.42`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.41...1.1.42)
## 1.1.41 (2020-11-25)
#### Fixes
* SIN-15126
* SIN-15126
* SIN-15126
Full set of changes: [`1.1.40...1.1.41`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.40...1.1.41)
## 1.1.40 (2020-11-25)
#### Fixes
* SIN-15126
* SIN-15126
Full set of changes: [`1.1.39...1.1.40`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.39...1.1.40)
## 1.1.39 (2020-10-27)
#### Fixes
* (errorhandler): correction gestion du sys.exit
Full set of changes: [`1.1.38...1.1.39`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.38...1.1.39)
## 1.1.38 (2020-10-27)
#### New Features
* (history): en cas d'exception affiche le nom de l'exception dans le hist à la place de l'exit_code
* (error_handler): ajout gestion d'exception
#### Fixes
* commit only if repo is dirty
Full set of changes: [`1.1.37...1.1.38`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.37...1.1.38)
## 1.1.37 (2020-10-26)
#### Fixes
* infra.git: Utilisation de l objet Repo.git
* infra.git: Prise en charge des suppressions de fichiers
* infra.git: Prise en charge des suppressions de fichiers
* infra.git: Prise en charge des suppressions de fichiers
Full set of changes: [`1.1.36...1.1.37`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.36...1.1.37)
## 1.1.36 (2020-10-26)
#### Fixes
* api.validator global catch
* infra.api: There is NO Validator class
* infra.api: Validator is available from infra.api
* api: flake8 ready
Full set of changes: [`1.1.35...1.1.36`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.35...1.1.36)
## 1.1.35 (2020-10-23)
#### New Features
* Added multi_options support to infra.git
Full set of changes: [`1.1.34...1.1.35`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.34...1.1.35)
## 1.1.34 (2020-10-23)
#### New Features
* infra.git: Gestion des dépôts Git
Full set of changes: [`1.1.33...1.1.34`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.33...1.1.34)
## 1.1.33 (2020-10-20)
#### Fixes
* remote.ssh: Secure regexp match + unshadowing dir builtin
Full set of changes: [`1.1.32...1.1.33`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.32...1.1.33)
## 1.1.32 (2020-10-19)
#### Fixes
* Lower remote.ssh default verbosity
#### Others
* SIN-13730 test execution sur le master
Full set of changes: [`1.1.31...1.1.32`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.31...1.1.32)
## 1.1.31 (2020-10-19)
#### Fixes
* Le controle de la conf se fait dans tous les cas
Full set of changes: [`1.1.30...1.1.31`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.30...1.1.31)
## 1.1.30 (2020-10-19)
#### Fixes
* (remote): Ssh exec_command correction bug commande qui ne se termine pas
Full set of changes: [`1.1.29...1.1.30`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.29...1.1.30)
## 1.1.29 (2020-10-16)
#### Fixes
* (remote): Ssh exec_command correction bug commande qui ne se termine pas
Full set of changes: [`1.1.28...1.1.29`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.28...1.1.29)
## 1.1.28 (2020-10-13)
Full set of changes: [`1.1.27...1.1.28`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.27...1.1.28)
## 1.1.27 (2020-10-13)
#### Fixes
* remote.ftp.put_file remove remote_dir first char only if needed
Full set of changes: [`1.1.26...1.1.27`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.26...1.1.27)
## 1.1.26 (2020-10-13)
#### Fixes
* remote.ftp.put_file remove remote_dir first char only if needed
Full set of changes: [`1.1.25...1.1.26`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.25...1.1.26)
## 1.1.25 (2020-10-13)
#### Fixes
* remote.ftp prot_c fallback to prot p
Full set of changes: [`1.1.24...1.1.25`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.24...1.1.25)
## 1.1.24 (2020-10-13)
#### Fixes
* remote.ftp prot_c fallback to prot p
Full set of changes: [`1.1.23...1.1.24`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.23...1.1.24)
## 1.1.23 (2020-10-13)
#### Fixes
* remote.ftp prot_c fallback to prot p
Full set of changes: [`1.1.22...1.1.23`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.22...1.1.23)
## 1.1.22 (2020-10-12)
#### Fixes
* (remote): Ssh exec_command correction bug commande qui ne se termine pas
Full set of changes: [`1.1.21...1.1.22`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.21...1.1.22)
## 1.1.21 (2020-10-06)
#### New Features
* (ssh): exec_command accept maintenant l'ensemble des paramètres de la methode de paramiko
* (ssh): exec_command changement du retour stdin -> exit_code voir readme https://gitlab-infra.ref.gnc/python-infra/python-infra/blob/master/README.md\[#ex](https://gitlab-infra.ref.gnc/python-infra/python-infra/issues/ex)%C3%A9cuter-une-commande-sur-un-h%C3%B4te-distant
Full set of changes: [`1.1.20...1.1.21`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.20...1.1.21)
## 1.1.20 (2020-10-02)
#### New Features
* (remote): remote Ssh ajout de la method sftp_stat
Full set of changes: [`1.1.19...1.1.20`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.19...1.1.20)
## 1.1.19 (2020-10-01)
Full set of changes: [`1.1.18...1.1.19`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.18...1.1.19)
## 1.1.18 (2020-10-01)
#### Fixes
* Check authorized user before using PIDStack
#### Others
* remote/gncftp: clean lint
Full set of changes: [`1.1.17...1.1.18`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.17...1.1.18)
## 1.1.17 (2020-10-01)
Full set of changes: [`1.1.16...1.1.17`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.16...1.1.17)
## 1.1.16 (2020-10-01)
#### New Features
* ajout des 'with' sur les class Ssh, DB, SpamAssassinClient, Ftp, GncFtp
#### Others
* correction gestion des tags
* suppression de la notification des Merge Request [ci-skip]
Full set of changes: [`1.1.15...1.1.16`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.15...1.1.16)
## 1.1.15 (2020-09-21)
Full set of changes: [`1.1.14...1.1.15`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.14...1.1.15)
## 1.1.14 (2020-09-17)
#### Fixes
* _find_remote_files: exit_on_error
#### Others
* Avertissement de non-confidentialité
Full set of changes: [`1.1.13...1.1.14`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.13...1.1.14)
## 1.1.13 (2020-09-16)
Full set of changes: [`1.1.12...1.1.13`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.12...1.1.13)
## 1.1.12 (2020-09-14)
#### Fixes
* (context): correction erreur sur le context en utilisant les 2 options --nolog et --no-log-file
Full set of changes: [`1.1.11...1.1.12`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.11...1.1.12)
## 1.1.11 (2020-08-24)
Full set of changes: [`1.1.10...1.1.11`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.10...1.1.11)
## 1.1.10 (2020-08-24)
Full set of changes: [`1.1.9...1.1.10`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.9...1.1.10)
## 1.1.9 (2020-08-24)
#### Fixes
* security fix + sonar quality fixes
* Jinja2 autoescape == True by default
Full set of changes: [`1.1.8...1.1.9`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.8...1.1.9)
## 1.1.8 (2020-08-24)
#### New Features
* stack_file_path extension
Full set of changes: [`1.1.7...1.1.8`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.7...1.1.8)
## 1.1.7 (2020-08-24)
#### Fixes
* PermissionError handling on lockfile
Full set of changes: [`1.1.6...1.1.7`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.6...1.1.7)
## 1.1.6 (2020-08-21)
#### Refactorings
* Better filelock logging handling
Full set of changes: [`1.1.5...1.1.6`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.5...1.1.6)
## 1.1.5 (2020-08-21)
#### Refactorings
* Better filelock logging handling
Full set of changes: [`1.1.4...1.1.5`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.4...1.1.5)
## 1.1.4 (2020-08-20)
Full set of changes: [`1.1.3...1.1.4`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.3...1.1.4)
## 1.1.3 (2020-08-20)
#### New Features
* max_instance
Full set of changes: [`1.1.2...1.1.3`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.2...1.1.3)
## 1.1.2 (2020-08-17)
Full set of changes: [`1.1.1...1.1.2`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.1.1...1.1.2)
## 1.1.1 (2020-08-17)
#### Refactorings
* api.apiloader
Full set of changes: [`1.0.153...1.1.1`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.153...1.1.1)
## 1.0.153 (2020-08-13)
#### Others
* auto-changlog fix diff url
* upgrade auto-changelog 0.4.0 -> 0.5.1
Full set of changes: [`1.0.152...1.0.153`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.152...1.0.153)
## 1.0.152 (2020-08-10)
Full set of changes: [`1.0.151...1.0.152`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.151...1.0.152)
## 1.0.151 (2020-08-07)
#### Refactorings
* VWMareApi
Full set of changes: [`1.0.150...1.0.151`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.150...1.0.151)
## 1.0.150 (2020-08-03)
#### New Features
* api.Client ajout SSL verify
Full set of changes: [`1.0.149...1.0.150`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.149...1.0.150)
## 1.0.149 (2020-08-03)
#### Fixes
* api.Client response referenced before assignement
Full set of changes: [`1.0.148...1.0.149`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.148...1.0.149)
## 1.0.148 (2020-08-03)
#### Others
* fix project url in setup.cfg
Full set of changes: [`1.0.147...1.0.148`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.147...1.0.148)
## 1.0.147 (2020-08-03)
#### New Features
* infra.api.Client
#### Fixes
* Better README.md
* Typo in README.md
* better doc
* grammar in README.dm
#### Others
* updated module requirements + added requirements.txt
Full set of changes: [`1.0.145...1.0.147`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.145...1.0.147)
## 1.0.145 (2020-07-30)
#### Others
* clean Jenkinsfile
Full set of changes: [`1.0.144...1.0.145`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.144...1.0.145)
## 1.0.144 (2020-07-30)
#### New Features
* notifyMergeRequest
Full set of changes: [`1.0.143...1.0.144`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.143...1.0.144)
## 1.0.143 (2020-07-30)
#### Docs
* Correction de la doc d install
Full set of changes: [`1.0.142...1.0.143`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.142...1.0.143)
## 1.0.142 (2020-07-27)
#### Fixes
* remote.gncftp.close
Full set of changes: [`1.0.141...1.0.142`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.141...1.0.142)
## 1.0.141 (2020-07-27)
#### New Features
* infra.conf.Config.get_section
Full set of changes: [`1.0.140...1.0.141`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.140...1.0.141)
## 1.0.140 (2020-07-16)
#### Fixes
* README.md: Ajoute doc sur nolog
Full set of changes: [`1.0.139...1.0.140`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.139...1.0.140)
## 1.0.139 (2020-07-16)
#### Fixes
* README.md: Ajoute doc sur nolog
Full set of changes: [`1.0.138...1.0.139`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.138...1.0.139)
## 1.0.138 (2020-07-16)
#### Fixes
* infra.db: type == postgres
Full set of changes: [`1.0.137...1.0.138`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.137...1.0.138)
## 1.0.137 (2020-07-08)
Full set of changes: [`1.0.136...1.0.137`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.136...1.0.137)
## 1.0.136 (2020-07-08)
#### Fixes
* python3.4 argparse.ArgumentParser has no allow_abbrev argument
Full set of changes: [`1.0.135...1.0.136`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.135...1.0.136)
## 1.0.135 (2020-06-22)
#### New Features
* infra.remote.Ssh.sftp_list
Full set of changes: [`1.0.134...1.0.135`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.134...1.0.135)
## 1.0.134 (2020-06-22)
#### Fixes
* sftp_delete must open sftp connection first
Full set of changes: [`1.0.133...1.0.134`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.133...1.0.134)
## 1.0.133 (2020-06-22)
#### New Features
* infra.remote.Ssh.sftp_delete
Full set of changes: [`1.0.132...1.0.133`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.132...1.0.133)
## 1.0.132 (2020-06-19)
#### New Features
* Ajout de la classe Db_from_cc
Full set of changes: [`1.0.131...1.0.132`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.131...1.0.132)
## 1.0.131 (2020-06-19)
#### Refactorings
* infra.remote.ssh
Full set of changes: [`1.0.130...1.0.131`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.130...1.0.131)
## 1.0.130 (2020-06-12)
#### Fixes
* Db.execute default params
* Db.execute default params
Full set of changes: [`1.0.129...1.0.130`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.129...1.0.130)
## 1.0.129 (2020-06-12)
#### Fixes
* Db.execute default params
Full set of changes: [`1.0.128...1.0.129`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.128...1.0.129)
## 1.0.128 (2020-06-12)
#### Fixes
* Db.execute default params
Full set of changes: [`1.0.127...1.0.128`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.127...1.0.128)
## 1.0.127 (2020-06-12)
#### Fixes
* Db.execute default params
Full set of changes: [`1.0.126...1.0.127`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.126...1.0.127)
## 1.0.126 (2020-06-12)
#### Fixes
* Db.execute default params
Full set of changes: [`1.0.125...1.0.126`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.125...1.0.126)
## 1.0.125 (2020-06-12)
#### Fixes
* Db.execute default params
Full set of changes: [`1.0.124...1.0.125`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.124...1.0.125)
## 1.0.124 (2020-06-12)
#### Fixes
* Db.execute default params
Full set of changes: [`1.0.123...1.0.124`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.123...1.0.124)
## 1.0.123 (2020-06-12)
#### Fixes
* Db.execute for Oracle
Full set of changes: [`1.0.122...1.0.123`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.122...1.0.123)
## 1.0.122 (2020-06-12)
#### Others
* Updated Readme for Oracle support
Full set of changes: [`1.0.121...1.0.122`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.121...1.0.122)
## 1.0.121 (2020-06-12)
#### Others
* ajustement ordre bump2version tag auto-changelog
Full set of changes: [`1.0.120...1.0.121`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.120...1.0.121)
## 1.0.120 (2020-06-12)
#### Fixes
* Typo in Jenkinsfile
Full set of changes: [`1.0.119...1.0.120`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.119...1.0.120)
## 1.0.119 (2020-06-12)
#### Others
* end of test
Full set of changes: [`1.0.118...1.0.119`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.118...1.0.119)
## 1.0.118 (2020-06-12)
#### Fixes
* default db_type is pgsql
#### Others
* This is a test
Full set of changes: [`1.0.117...1.0.118`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.117...1.0.118)
## 1.0.117 (2020-06-04)
#### Others
* mise en place du changelog auto-généré
Full set of changes: [`1.0.116...1.0.117`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.116...1.0.117)
## 1.0.116 (2020-06-03)
#### Fixes
* (args): pour le type bool correction de la valeur par défaut de la valeur par defaut
Full set of changes: [`1.0.115...1.0.116`](https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/1.0.115...1.0.116)
## 1.0.115 (2020-05-29)
#### New Features
* add bumpversion
#### Fixes
* ajout du push increment version

+ 3
- 3
CONTRIBUTING.md View File

@ -1,8 +1,8 @@
## Environnement de dev
```sh
python3 -m venv socle-infra-venv
source socle-infra-venv/bin/activate
python3 -m venv scrippy-template
source scrippy-template/bin/activate
pip install -e .
```
@ -57,7 +57,7 @@ Les scopes correspondent aux noms des modules jusqu'au deuxième niveau.
**Sans caratères speciaux !**
**exemple :** `infra.remote.ftp`, `infra.remote.ssh`, `infra.remote`, `infra.db`, `infra.mail.mailer`, etc...
**exemple :** `scrippy-remote.remote.ftp`, `scrippy-remote.remote.ssh`, `scrippy-remote.remote`, `scrippy-db.db`, `scrippy-mail.mail.mailer`, etc...
### Breaking change
Pour les breaking changes ajouter `!` avant le `: <description>`


+ 3
- 2
Jenkinsfile View File

@ -39,7 +39,7 @@ pipeline {
withPythonEnv('python3') {
sh "pip install --upgrade pip"
sh "python -m pip install .[dev]"
sh "python3 -m pytest --cov=scrippy_template --junitxml=./junit_report.xml"
}
}
}
@ -71,7 +71,7 @@ pipeline {
withPythonEnv('python3') {
sh "bump2version patch"
String version = getAppVersion()
sh "auto-changelog -v ${version} --issue-url https://gitlab-infra.ref.gnc/python-infra/python-infra/issues/{id} --starting-commit dbd7aa41a423126f5ede4e7c1c8436ca02ce022a -d 'Fichier généré automatiquement par auto-changelog' --diff-url https://gitlab-infra.ref.gnc/python-infra/python-infra/compare/{previous}...{current}"
sh "auto-changelog -v ${version} --issue-url https://gitlab-infra.ref.gnc/scrippy/scrippy-api/issues/{id} --starting-commit 547393a0eb6ecee1acd0b8d9a63374235d17a6ae -d 'Fichier généré automatiquement par auto-changelog' --diff-url https://gitlab-infra.ref.gnc/scrippy/scrippy-api/compare/{previous}...{current}"
sh "git add setup.cfg .bumpversion.cfg CHANGELOG.md"
sh "git commit -m 'increment version and update changelog [ci-skip]'"
sh "git tag ${version}"
@ -94,6 +94,7 @@ pipeline {
post {
always {
junit allowEmptyResults: true, testResults: 'junit_report.xml'
commentMergeRequest()
cleanWs()
}


+ 11
- 8
Makefile View File

@ -1,7 +1,7 @@
VERSION=$(shell python3 ./setup.py --version)
.RECIPEPREFIX +=
.PHONY: install uninstall all distclean bumpversion autochangelog tag dist push release
.PHONY: install uninstall all distclean test bumpversion autochangelog tag dist push release
all: | uninstall install distclean
@ -9,10 +9,13 @@ install:
sudo python3 ./setup.py build install
uninstall:
sudo pip3 uninstall -y python-infra
sudo pip3 uninstall -y scrippy-api
distclean:
sudo rm -Rf ./build ./dist ./python_infra.egg-info
sudo rm -Rf ./build ./dist ./scrippy_api.egg-info ./scrippy_api/__pycache__ ./tests/__pycache__
test:
python3 -m pytest --cov=scrippy_api --junitxml=./junit_report.xml
bumpversion:
bump2version patch
@ -20,10 +23,10 @@ bumpversion:
autochangelog:
VERSION=$(shell python3 ./setup.py --version)
auto-changelog -v "${VERSION}" \
--issue-url https://git.mcos.nc/issues/{id} \
--starting-commit dbd7aa41a423126f5ede4e7c1c8436ca02ce022a \
-d 'Fichier généré automatiquement par auto-changelog' \
--diff-url https://git.mcos.nc/python/infra/src/tag/{current}
--issue-url https://git.mcos.nc/python/scrippy-api/issues/{id} \
--starting-commit 84d2fe411f1e89f85c05bb1f5de569630e6b9cdc \
-d 'Fichier généré automatiquement par auto-changelog' \
--diff-url https://git.mcos.nc/python/scrippy/src/tag/{current}
tag:
VERSION=$(shell python3 ./setup.py --version)
@ -38,4 +41,4 @@ push:
git push origin
git push --tags
release: | distclean bumpversion autochangelog tag dist push
release: | distclean test bumpversion autochangelog tag dist push

+ 32
- 1492
README.md
File diff suppressed because it is too large
View File


+ 0
- 2
api/__init__.py View File

@ -1,2 +0,0 @@
from infra.api.client import Client
from infra.api.apiloader import ApiLoader

+ 4
- 19
requirements.txt View File

@ -1,19 +1,4 @@
GitPython>=2.1.15
psycopg2-binary>=2.8.3
markupsafe>=1.1.1
pycparser>=2.19
paramiko>=2.6.0
argcomplete>=1.10.0
bcrypt>=3.1.7
coloredlogs>=10.0
pytz>=2019.3
pynacl>=1.3.0
cryptography>=2.7
six>=1.12.0
jinja2>=2.10.3
asn1crypto>=1.0.1
prettytable>=0.7.2
cffi>=1.12.3
humanfriendly>=4.18
sqlparse>=0.3.0
filelock>=3.0.12
requests>=2.24.0
PyYAML>=5.3.1
jsonschema>=3.2.0
setuptools>=39.2.0

BIN
scrippy-api.png View File

Before After
Width: 532  |  Height: 334  |  Size: 25 KiB

+ 10
- 0
scrippy_api/__init__.py View File

@ -0,0 +1,10 @@
"""Module d'utilisation des API REST."""
class ScrippyApiError(Exception):
"""Classe d'erreur spécifique."""
def __init__(self, message):
"""Initialise l'instance."""
self.message = message
super().__init__(self.message)

+ 4
- 0
scrippy_api/api/__init__.py View File

@ -0,0 +1,4 @@
"""Imports raccourcis."""
from scrippy_api.api.client import Client
from scrippy_api.api.apiloader import ApiLoader

api/apiloader.py → scrippy_api/api/apiloader.py View File

@ -1,20 +1,19 @@
import sys
"""Module de chargement de définition d'API."""
import yaml
import logging
from scrippy_api import ScrippyApiError as ScrippyApiError
class ApiLoader:
"""
L'objet ApiLoader permet le chargement d'une API définie à l'aide d'un fichier YAML.
Exemple: https://gitlab-infra.ref.gnc/python-infra/vmware-api.
"""
"""L'objet ApiLoader permet le chargement d'une API définie à l'aide d'un fichier YAML."""
def __init__(self):
"""Initialise la classe ApiLoader."""
self.api = {}
def _walk_api(self, dic, path=[]):
"""
Parcours la représentation de l'API passée en argument sous forme de dictionnaire.
"""
def _walk_api(self, dic, path):
"""Parcours la représentation de l'API passée en argument sous forme de dictionnaire."""
for k, v in dic.items():
if isinstance(v, list):
for action_list in v:
@ -30,9 +29,7 @@ class ApiLoader:
path.pop()
def load_api(self, api_definition):
"""
Charge l'API à partir du fichier YAML passé en argument.
"""
"""Charge l'API à partir du fichier YAML passé en argument."""
logging.info("[+] Chargement de l'API")
logging.info(" '-> {}".format(api_definition))
try:
@ -40,18 +37,19 @@ class ApiLoader:
api_yaml = yaml.load(yaml_file, Loader=yaml.FullLoader)
self._walk_api(api_yaml)
except Exception as e:
logging.critical("Erreur lors du chargement de l'API: [{}] {}".format(e.__class__.__name__, e))
sys.exit(1)
err_msg = "Erreur indefinie: [{}] {}".format(e.__class__.__name__, e)
raise ScrippyApiError(err_msg)
def get_endpoint_info(self, endpoint):
"""
Renvoi les informations du endpoint passé en argument.
Les informations renvoyées sont un dictionnaire tel que:
{"method": <HTTP METHOD>, "url": <URL>}
"""
logging.info("[+] Recuperation des informations pour: {}".format(endpoint))
try:
return self.api[endpoint]
except KeyError as e:
logging.critical("endpoint inconnu: [{}] {}".format(e.__class__.__name__, e))
sys.exit(1)
except KeyError:
err_msg = "Endpoint inconnu: {}".format(endpoint)
raise ScrippyApiError(err_msg)

api/client.py → scrippy_api/api/client.py View File

@ -1,14 +1,25 @@
import sys
"""Module facilitant l'utilisation d'API ReST."""
import logging
import requests
from scrippy_api import ScrippyApiError as ScrippyApiError
class Client:
"""
Classe permettant l'utilisation d'API REST
https://fr.wikipedia.org/wiki/Representational_state_transfer
Classe permettant l'utilisation d'API REST.
https://fr.wikipedia.org/wiki/Representational_state_transfer.
"""
def __init__(self, verify=True, exit_on_error=True):
"""
Initialise la classe Client.
:param method
:param: verify: Vérifie le certificat SSL, defaults to True
:exit_on_error: Lève immédiatement une erreur ScrippyApiError en cas d'erreur lors de la requète, defaults to True
"""
self.exit_on_error = exit_on_error
self.verify = verify
self.session = requests.Session()
@ -61,13 +72,14 @@ class Client:
logging.debug("api.Client: kwargs: {}".format({**default_get_kwargs, **default_post_kwargs}))
logging.debug("api.Client: {}: {}".format(response.url, response.status_code))
response.raise_for_status()
return response
except Exception as e:
if self.exit_on_error:
logging.critical("Erreur lors de la requete: [{}] {}".format(e.__class__.__name__, e))
sys.exit(1)
logging.warning("Erreur lors de la requete: [{}] {}".format(e.__class__.__name__, e))
finally:
return response
err_msg = "Erreur lors de la requete: [{}] {}".format(e.__class__.__name__, e)
raise ScrippyApiError(err_msg)
else:
logging.warning("Erreur lors de la requete: [{}] {}".format(e.__class__.__name__, e))
return response
def _get(self, url, **kwargs):
return self.session.get(url, **kwargs)

api/validator.py → scrippy_api/api/validator.py View File


+ 7
- 22
setup.cfg View File

@ -4,9 +4,9 @@ classifiers =
Programming Language :: Python :: 3
License :: WTFPL
Operating System :: POSIX :: Linux
url = https://gitlab-infra.ref.gnc/puppet/python-infra
description = "Socle de fonctions utilisées dans les scripts python de gestion d'infrastructure."
name = python-infra
url = https://gitlab-infra.ref.gnc/scrippy/scrippy-api
description = "Fonctions d'utilisation d'API ReST."
name = scrippy-api
long_description = file: README.md
long_description_content_type = text/markdown
author = Michael Costa, Florent Chevalier
@ -15,25 +15,10 @@ author_email = michael.costa@mcos.nc, florent.chevalier@gouv.nc
[options]
packages = find:
install_requires =
GitPython>=2.1.15
psycopg2-binary>=2.8.3
markupsafe>=1.1.1
pycparser>=2.19
paramiko>=2.6.0
argcomplete>=1.10.0
bcrypt>=3.1.7
coloredlogs>=10.0
pytz>=2019.3
pynacl>=1.3.0
cryptography>=2.7
six>=1.12.0
jinja2>=2.10.3
asn1crypto>=1.0.1
prettytable>=0.7.2
cffi>=1.12.3
humanfriendly>=4.18
sqlparse>=0.3.0
filelock>=3.0.12
requests>=2.24.0
PyYAML>=5.3.1
jsonschema>=3.2.0
setuptools>=39.2.0
[options.extras_require]
dev =


+ 2
- 2
sonar-project.properties View File

@ -1,5 +1,5 @@
sonar.projectName=python-infra
sonar.gitlab.project_id=puppet/python-infra
sonar.projectName=scrippy-apy
sonar.gitlab.project_id=scrippy/scrippy-apy
sonar.gitlab.url=https://gitlab-infra.ref.gnc


+ 0
- 0
tests/__init__.py View File


Loading…
Cancel
Save