Skip to content

Commit 755d916

Browse files
authored
Merge pull request #225 from myii/chore/standardise-structure
feat(yamllint): include for this repo and apply rules throughout
2 parents 272a1ae + 9f739fa commit 755d916

File tree

10 files changed

+296
-166
lines changed

10 files changed

+296
-166
lines changed

.travis.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
---
44
stages:
55
- test
6-
- commitlint
6+
- lint
77
- name: release
88
if: branch = master AND type != pull_request
99

@@ -49,16 +49,21 @@ script:
4949

5050
jobs:
5151
include:
52-
# Define the commitlint stage
53-
- stage: commitlint
52+
# Define the `lint` stage (runs `yamllint` and `commitlint`)
53+
- stage: lint
5454
language: node_js
5555
node_js: lts/*
5656
before_install: skip
5757
script:
58+
# Install and run `yamllint`
59+
- pip install --user yamllint
60+
# yamllint disable-line rule:line-length
61+
- yamllint -s . .yamllint pillar.example test/salt/pillar/mysql.sls
62+
# Install and run `commitlint`
5863
- npm install @commitlint/config-conventional -D
5964
- npm install @commitlint/travis-cli -D
6065
- commitlint-travis
61-
# Define the release stage that runs semantic-release
66+
# Define the release stage that runs `semantic-release`
6267
- stage: release
6368
language: node_js
6469
node_js: lts/*

.yamllint

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
# Extend the `default` configuration provided by `yamllint`
5+
extends: default
6+
7+
# Files to ignore completely
8+
# 1. All YAML files under directory `node_modules/`, introduced during the Travis run
9+
# 2. Any YAML files using Jinja (result in `yamllint` syntax errors)
10+
ignore: |
11+
node_modules/
12+
mysql/supported_sections.yaml
13+
14+
rules:
15+
line-length:
16+
# Increase from default of `80`
17+
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
18+
max: 88

mysql/defaults.yaml

+32-25
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
# vim: sts=2 ts=2 sw=2 et ai
2-
#
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
34
mysql:
45
serverpkg: mysql-server
56
clientpkg: mysql-client
67
service: mysql
7-
{%- if grains.pythonversion[0] == 2 %}
8-
pythonpkg: python-mysqldb
9-
{% else %}
10-
pythonpkg: python3-mysqldb
11-
{% endif %}
128
devpkg: mysql-devel
139
debconf_utils: debconf-utils
1410

@@ -40,66 +36,77 @@ mysql:
4036
retries: 2
4137
products:
4238
community_server:
43-
enabled: True
39+
enabled: true
40+
# yamllint disable-line rule:line-length
4441
url: https://downloads.mysql.com/archives/get/file/mysql-8.0.11-macos10.13-x86_64.dmg
4542
sum: 'md5=602a84390ecf3d82025b1d99fc594124'
46-
isapp: False
43+
isapp: false
4744
path: /usr/local/mysql
4845
app: mysql
4946
workbench:
50-
enabled: True
47+
enabled: true
48+
# yamllint disable-line rule:line-length
5149
url: https://downloads.mysql.com/archives/get/file/mysql-workbench-community-8.0.11-rc-macos-x86_64.dmg
5250
sum: 'md5=37c5ae5bd75a4e1804ae6e0127d68611'
53-
isapp: True
51+
isapp: true
5452
path: /Applications/MySQLWorkbench/Contents/Versions/latest
5553
app: MySQLWorkbench
5654
cluster:
57-
enabled: False
55+
enabled: false
56+
# yamllint disable-line rule:line-length
5857
url: https://downloads.mysql.com/archives/get/file/mysql-cluster-gpl-7.6.6-macos10.13-x86_64.dmg
5958
sum: 'md5=0df975908e7d8e4e8c1003d95edf4721'
60-
isapp: False
59+
isapp: false
6160
path: /usr/local/mysqlcluster
6261
app: MySQLCluster
6362
router:
64-
enabled: False
63+
enabled: false
64+
# yamllint disable-line rule:line-length
6565
url: https://downloads.mysql.com/archives/get/file/mysql-router-8.0.11-macos10.13-x86-64bit.dmg
6666
sum: 'md5=8dd536f2f223933ecbfb8b19e54ee2f6'
67-
isapp: False
67+
isapp: false
6868
app: MySQLRouter
6969
utilities:
70-
enabled: False
70+
enabled: false
71+
# yamllint disable-line rule:line-length
7172
url: https://downloads.mysql.com/archives/get/file/mysql-utilities-1.6.5-macos10.12.dmg
7273
sum: 'md5=4c8e75bb217b8293dcdeb915b649c2c8'
73-
isapp: True ## ??
74+
isapp: true ## ??
7475
app: MySQLUtilties
7576
shell:
76-
enabled: False
77+
enabled: false
78+
# yamllint disable-line rule:line-length
7779
url: https://downloads.mysql.com/archives/get/file/mysql-shell-8.0.11-macos10.13-x86-64bit.dmg
7880
sum: 'md5=43db4f0fc39f88c1d7be4a4f52cec363'
79-
isapp: True ## ??
81+
isapp: true ## ??
8082
app: MySQLShell
8183
proxy:
82-
enabled: False
84+
enabled: false
85+
# yamllint disable-line rule:line-length
8386
url: https://downloads.mysql.com/archives/get/file/mysql-proxy-0.8.5-osx10.7-x86-32bit.tar.gz
8487
sum: 'md5=107df22412aa8c483d2021e1af24ee22'
8588
connector:
86-
enabled: False
89+
enabled: false
90+
# yamllint disable-line rule:line-length
8791
url: https://downloads.mysql.com/archives/get/file/mysql-connector-nodejs-8.0.11.tar.gz
8892
sum: 'md5=dece7fe5607918ba68499ef07c31508d'
8993
forvisualstudio:
90-
enabled: False
94+
enabled: false
95+
# yamllint disable-line rule:line-length
9196
url: https://downloads.mysql.com/archives/get/file/mysql-for-visualstudio-2.0.4-src.zip
9297
sum: 'md5=fcf39316505ee2921e31a431eae77a9c'
9398
forexcel:
94-
enabled: False
99+
enabled: false
100+
# yamllint disable-line rule:line-length
95101
url: https://downloads.mysql.com/archives/get/file/mysql-for-excel-1.3.6-src.zip
96102
sum: 'md5=2cc8b65eb72a1b07a6e4e2665e2a29e3'
97103
notifier:
98-
enabled: False
104+
enabled: false
105+
# yamllint disable-line rule:line-length
99106
url: https://downloads.mysql.com/archives/get/file/mysql-notifier-1.1.6-src.zip
100107
sum: 'md5=349f1994681763fd6626a8ddf6be5363'
101108

102-
#The following dict names are reserved for pillar data (see pillar.example)
109+
# The following dict names are reserved for pillar data (see pillar.example)
103110
global: {}
104111
clients: {}
105112
library: {}

mysql/map.jinja

+57-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,61 @@
1-
{% import_yaml "mysql/defaults.yaml" as defaults %}
2-
{% import_yaml "mysql/osfamilymap.yaml" as osfamilymap %}
3-
{% import_yaml "mysql/osmap.yaml" as osmap %}
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=jinja
43

5-
{% set mysql = salt['grains.filter_by'](
6-
defaults,
7-
merge=salt['grains.filter_by'](
8-
osfamilymap,
9-
grain='os_family',
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
6+
{#- Start imports as #}
7+
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
8+
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
9+
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
10+
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
11+
12+
{#- Retrieve the config dict only once #}
13+
{%- set _config = salt['config.get'](tplroot, default={}) %}
14+
15+
{%- set py_ver_settings = {
16+
2: {'pythonpkg': 'python-mysqldb'},
17+
3: {'pythonpkg': 'python3-mysqldb'},
18+
} %}
19+
20+
{%- set defaults = salt['grains.filter_by'](
21+
py_ver_settings,
22+
default=grains.pythonversion[0],
23+
merge=salt['grains.filter_by'](
24+
default_settings,
25+
default=tplroot,
1026
merge=salt['grains.filter_by'](
27+
osfamilymap,
28+
grain='os_family',
29+
merge=salt['grains.filter_by'](
1130
osmap,
1231
grain='os',
13-
merge=salt['pillar.get']('mysql', {}),
14-
),
15-
),
16-
base='mysql',
17-
) %}
32+
merge=salt['grains.filter_by'](
33+
osfingermap,
34+
grain='osfinger',
35+
merge=salt['grains.filter_by'](
36+
_config,
37+
default='lookup'
38+
)
39+
)
40+
)
41+
)
42+
)
43+
)
44+
%}
45+
46+
{%- set config = salt['grains.filter_by'](
47+
{'defaults': defaults},
48+
default='defaults',
49+
merge=_config
50+
)
51+
%}
52+
53+
{%- set mysql = config %}
54+
55+
{#- Post-processing for specific non-YAML customisations #}
56+
{%- if grains.os == 'MacOS' %}
57+
{%- set macos_user = salt['pillar.get']('mysql:user', salt['cmd.run']("stat -f '%Su' /dev/console")) %}
58+
{%- set macos_group = salt['pillar.get']('mysql:group', salt['cmd.run']("stat -f '%Sg' /dev/console")) %}
59+
{%- do mysql.macos.update({'user': macos_user}) %}
60+
{%- do mysql.macos.update({'group': macos_group}) %}
61+
{%- endif %}

mysql/osfamilymap.yaml

+16-40
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
# vim: sts=2 ts=2 sw=2 et ai
2-
#
3-
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
44
Debian:
5-
{% if 'osmajorrelease' in grains and salt['grains.get']('osmajorrelease')|int >= 9 %}
6-
serverpkg: mariadb-server
7-
service: mariadb
8-
clientpkg: mariadb-client
9-
devpkg: libmariadbclient-dev
10-
{% else %}
115
devpkg: libmysqlclient-dev
12-
{% endif %}
136

147
config:
158
sections:
@@ -20,7 +13,7 @@ Debian:
2013
pid_file: /var/run/mysqld/mysqld.pid
2114
basedir: /usr
2215
tmpdir: /tmp
23-
lc_messages_dir: /usr/share/mysql
16+
lc_messages_dir: /usr/share/mysql
2417
skip_external_locking: noarg_present
2518
bind_address: 127.0.0.1
2619
key_buffer_size: 16M
@@ -31,9 +24,9 @@ Debian:
3124
query_cache_size: 16M
3225
expire_logs_days: 10
3326
max_binlog_size: 100M
34-
#innodb_flush_log_at_trx_commit: 1
35-
#innodb_lock_wait_timeout: 50
36-
#innodb_file_per_table: noarg_present
27+
# innodb_flush_log_at_trx_commit: 1
28+
# innodb_lock_wait_timeout: 50
29+
# innodb_file_per_table: noarg_present
3730
mysqldump:
3831
quick: noarg_present
3932
quote_names: noarg_present
@@ -42,31 +35,18 @@ Debian:
4235
key_buffer_size: 16M
4336
append: |
4437
!includedir /etc/mysql/conf.d/
45-
# {% if 'osmajorrelease' in grains and salt['grains.get']('osmajorrelease')|int >= 9 -%}
46-
# !includedir /etc/mysql/mariadb.conf.d/
47-
# {%- endif %}
4838
4939
RedHat:
50-
#https://mariadb.com/blog/rhel7-transition-mysql-mariadb-first-look
51-
{%- if 'osmajorrelease' in grains and salt['grains.get']('osmajorrelease')|int in [7] %}
52-
{% set fork = 'mariadb' %}
53-
serverpkg: mariadb-server
54-
service: mariadb
55-
devpkg: mariadb-devel
56-
{%- else %}
57-
{% set fork = 'mysql' %}
5840
service: mysqld
59-
{%- endif %}
60-
61-
clientpkg: {{ fork }}
41+
clientpkg: mysql
6242
pythonpkg: MySQL-python
6343
config:
6444
file: /etc/my.cnf
6545
sections:
6646
client:
6747
mysqld_safe:
68-
log_error: /var/log/{{ fork }}/mysqld.log
69-
pid_file: /var/run/{{ fork }}/mysqld.pid
48+
log_error: /var/log/mysql/mysqld.log
49+
pid_file: /var/run/mysql/mysqld.pid
7050
mysqld:
7151
socket: /var/lib/mysql/mysql.sock
7252
bind_address: 127.0.0.1
@@ -75,12 +55,7 @@ RedHat:
7555
Suse:
7656
serverpkg: mariadb
7757
clientpkg: mariadb-client
78-
{%- if 'osmajorrelease' in grains and salt['grains.get']('osmajorrelease')|int == 42 %}
79-
# "old" package name up to Leap 42.x
80-
pythonpkg: python-PyMySQL
81-
{% else %}
8258
pythonpkg: python2-pymysql
83-
{% endif %}
8459

8560
config:
8661
file: /etc/my.cnf
@@ -91,10 +66,10 @@ Suse:
9166
port:
9267
user:
9368
socket:
94-
datadir:
69+
datadir:
9570
tmpdir:
9671
innodb_file_format: Barracuda
97-
innodb_file_per_table: ON
72+
innodb_file_per_table: 'ON'
9873
server-id: 1
9974
sql_mode: NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
10075
mysqld_multi:
@@ -178,7 +153,7 @@ Gentoo:
178153
default_character_set: utf8
179154
myisamchk:
180155
character_sets_dir: /usr/share/mysql/charsets
181-
key_buffer: 20M ##????? key_buffer_size ?
156+
key_buffer: 20M ## ????? key_buffer_size ?
182157
sort_buffer_size: 20M
183158
read_buffer: 2M
184159
write_buffer: 2M
@@ -188,7 +163,8 @@ Gentoo:
188163
err_log: /var/log/mysql/mysql.err
189164
mysqld:
190165
character_set_serverpkg: utf8
191-
# note: the gentoo init.d script specifically needs pid-file (dash not underscore)
166+
# note: the gentoo init.d script specifically needs pid-file
167+
# (dash not underscore)
192168
pid-file: /var/run/mysqld/mysqld.pid
193169
log_error: /var/log/mysql/mysqld.err
194170
basedir: /usr
@@ -217,7 +193,7 @@ Gentoo:
217193
innodb_lock_wait_timeout: 50
218194
innodb_file_per_table: noarg_present
219195
isamchk:
220-
key_buffer: 20M ##????? key_buffer_size ?
196+
key_buffer: 20M ## ????? key_buffer_size ?
221197
sort_buffer_size: 20M
222198
read_buffer: 2M
223199
write_buffer: 2M

0 commit comments

Comments
 (0)