legion-data 0.2.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop-analysis.yml +28 -0
  3. data/.github/workflows/sourcehawk-scan.yml +20 -0
  4. data/.gitignore +4 -2
  5. data/.rubocop.yml +6 -14
  6. data/CHANGELOG.md +2 -9
  7. data/CODE_OF_CONDUCT.md +75 -0
  8. data/CONTRIBUTING.md +55 -0
  9. data/Gemfile +7 -1
  10. data/INDIVIDUAL_CONTRIBUTOR_LICENSE.md +30 -0
  11. data/LICENSE +201 -0
  12. data/NOTICE.txt +9 -0
  13. data/README.md +60 -23
  14. data/SECURITY.md +9 -0
  15. data/attribution.txt +1 -0
  16. data/legion-data.gemspec +22 -38
  17. data/lib/legion/data.rb +18 -21
  18. data/lib/legion/data/connection.rb +29 -26
  19. data/lib/legion/data/migration.rb +3 -3
  20. data/lib/legion/data/migrations/001_add_schema_columns.rb +1 -1
  21. data/lib/legion/data/migrations/002_add_nodes.rb +20 -0
  22. data/lib/legion/data/migrations/003_add_settings.rb +18 -0
  23. data/lib/legion/data/migrations/004_add_extensions.rb +25 -0
  24. data/lib/legion/data/migrations/005_add_runners.rb +21 -0
  25. data/lib/legion/data/migrations/006_add_functions.rb +23 -0
  26. data/lib/legion/data/migrations/007_add_default_extensions.rb +25 -0
  27. data/lib/legion/data/migrations/008_add_tasks.rb +29 -0
  28. data/lib/legion/data/model.rb +5 -2
  29. data/lib/legion/data/models/extension.rb +0 -2
  30. data/lib/legion/data/models/function.rb +2 -6
  31. data/lib/legion/data/models/node.rb +1 -3
  32. data/lib/legion/data/models/runner.rb +0 -2
  33. data/lib/legion/data/models/setting.rb +0 -0
  34. data/lib/legion/data/models/task.rb +0 -2
  35. data/lib/legion/data/models/task_log.rb +0 -0
  36. data/lib/legion/data/settings.rb +25 -19
  37. data/lib/legion/data/version.rb +1 -1
  38. data/sonar-project.properties +12 -0
  39. data/sourcehawk.yml +4 -0
  40. metadata +41 -189
  41. data/.circleci/config.yml +0 -148
  42. data/.rspec +0 -1
  43. data/Rakefile +0 -55
  44. data/bin/console +0 -14
  45. data/bin/setup +0 -8
  46. data/bitbucket-pipelines.yml +0 -26
  47. data/lib/legion/data/connections/base.rb +0 -61
  48. data/lib/legion/data/connections/jdbc.rb +0 -21
  49. data/lib/legion/data/connections/mysql.rb +0 -26
  50. data/lib/legion/data/connections/mysql2.rb +0 -11
  51. data/lib/legion/data/connections/mysql_base.rb +0 -19
  52. data/lib/legion/data/migrations/002_add_users.rb +0 -17
  53. data/lib/legion/data/migrations/003_add_groups.rb +0 -16
  54. data/lib/legion/data/migrations/004_add_chains.rb +0 -25
  55. data/lib/legion/data/migrations/005_add_envs.rb +0 -24
  56. data/lib/legion/data/migrations/006_add_dcs.rb +0 -24
  57. data/lib/legion/data/migrations/007_add_nodes.rb +0 -26
  58. data/lib/legion/data/migrations/008_add_settings.rb +0 -18
  59. data/lib/legion/data/migrations/009_add_extensions.rb +0 -25
  60. data/lib/legion/data/migrations/010_add_runners.rb +0 -21
  61. data/lib/legion/data/migrations/011_add_functions.rb +0 -29
  62. data/lib/legion/data/migrations/012_add_tasks.rb +0 -25
  63. data/lib/legion/data/migrations/013_add_task_logs.rb +0 -17
  64. data/lib/legion/data/migrations/014_add_relationships.rb +0 -27
  65. data/lib/legion/data/models/chain.rb +0 -13
  66. data/lib/legion/data/models/datacenter.rb +0 -13
  67. data/lib/legion/data/models/environment.rb +0 -13
  68. data/lib/legion/data/models/group.rb +0 -10
  69. data/lib/legion/data/models/namespace.rb +0 -14
  70. data/lib/legion/data/models/relationship.rb +0 -18
  71. data/lib/legion/data/models/user.rb +0 -10
@@ -1,25 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `chains` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `name` varchar(128) NOT NULL DEFAULT '',
6
- `active` tinyint(1) unsigned DEFAULT '1',
7
- `version` int(11) unsigned NOT NULL DEFAULT '1',
8
- `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
9
- `updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
10
- `user_owner` int(11) unsigned DEFAULT NULL,
11
- `group_owner` int(11) unsigned DEFAULT NULL,
12
- PRIMARY KEY (`id`),
13
- UNIQUE KEY `name` (`name`),
14
- KEY `active` (`active`),
15
- KEY `chains_user_owner` (`user_owner`),
16
- KEY `chains_group_owner` (`group_owner`),
17
- CONSTRAINT `chains_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
18
- CONSTRAINT `chains_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
19
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
20
- end
21
-
22
- down do
23
- drop :chains
24
- end
25
- end
@@ -1,24 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `environments` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `name` varchar(128) NOT NULL DEFAULT '',
6
- `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
7
- `user_owner` int(11) unsigned DEFAULT NULL,
8
- `group_owner` int(11) unsigned DEFAULT NULL,
9
- `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
10
- `updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
11
- PRIMARY KEY (`id`),
12
- UNIQUE KEY `name` (`name`),
13
- KEY `active` (`active`),
14
- KEY `environments_user_owner` (`user_owner`),
15
- KEY `environments_group_owner` (`group_owner`),
16
- CONSTRAINT `environments_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
17
- CONSTRAINT `environments_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
18
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
19
- end
20
-
21
- down do
22
- drop :environments
23
- end
24
- end
@@ -1,24 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `datacenters` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `name` varchar(128) NOT NULL DEFAULT '',
6
- `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
7
- `user_owner` int(11) unsigned DEFAULT NULL,
8
- `group_owner` int(11) unsigned DEFAULT NULL,
9
- `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
10
- `updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
11
- PRIMARY KEY (`id`),
12
- UNIQUE KEY `name` (`name`),
13
- KEY `active` (`active`),
14
- KEY `datacenters_user_owner` (`user_owner`),
15
- KEY `datacenters_group_owner` (`group_owner`),
16
- CONSTRAINT `datacenters_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
17
- CONSTRAINT `datacenters_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
18
- ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;"
19
- end
20
-
21
- down do
22
- drop :datacenters
23
- end
24
- end
@@ -1,26 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `nodes` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `name` varchar(128) NOT NULL DEFAULT '',
6
- `datacenter_id` int(11) unsigned DEFAULT NULL,
7
- `environment_id` int(11) unsigned DEFAULT NULL,
8
- `status` varchar(255) NOT NULL DEFAULT 'unknown',
9
- `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
10
- `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
11
- `updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
12
- PRIMARY KEY (`id`),
13
- UNIQUE KEY `name` (`name`),
14
- KEY `active` (`active`),
15
- KEY `status` (`status`),
16
- KEY `node_datacenter_id` (`datacenter_id`),
17
- KEY `node_environment_id` (`environment_id`),
18
- CONSTRAINT `node_datacenter_id` FOREIGN KEY (`datacenter_id`) REFERENCES `datacenters` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
19
- CONSTRAINT `node_environment_id` FOREIGN KEY (`environment_id`) REFERENCES `environments` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
20
- ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;"
21
- end
22
-
23
- down do
24
- drop :nodes
25
- end
26
- end
@@ -1,18 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `settings` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `key` varchar(128) NOT NULL,
6
- `value` varchar(256) NOT NULL,
7
- `encrypted` tinyint(1) unsigned NOT NULL DEFAULT '0',
8
- `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
9
- `updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
10
- PRIMARY KEY (`id`),
11
- UNIQUE KEY `key` (`key`)
12
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
13
- end
14
-
15
- down do
16
- drop :settings
17
- end
18
- end
@@ -1,25 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `extensions` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
6
- `name` varchar(128) NOT NULL,
7
- `namespace` varchar(128) NOT NULL DEFAULT '',
8
- `exchange` varchar(255) DEFAULT NULL,
9
- `uri` varchar(256) DEFAULT NULL,
10
- `user_owner` int(11) unsigned DEFAULT NULL,
11
- `group_owner` int(11) unsigned DEFAULT NULL,
12
- `updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
13
- `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
14
- PRIMARY KEY (`id`),
15
- UNIQUE KEY `name_namespace` (`name`,`namespace`),
16
- KEY `active` (`active`),
17
- KEY `name` (`name`),
18
- KEY `namespace` (`namespace`)
19
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
20
- end
21
-
22
- down do
23
- drop :extensions
24
- end
25
- end
@@ -1,21 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `runners` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `extension_id` int(11) unsigned NOT NULL,
6
- `name` varchar(256) NOT NULL DEFAULT '',
7
- `namespace` varchar(256) NOT NULL DEFAULT '',
8
- `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
9
- `queue` varchar(256) DEFAULT NULL,
10
- `uri` varchar(256) DEFAULT NULL,
11
- `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
12
- `updated` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
13
- PRIMARY KEY (`id`),
14
- CONSTRAINT `runner_extension_id` FOREIGN KEY (`extension_id`) REFERENCES `extensions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
15
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
16
- end
17
-
18
- down do
19
- drop :runners
20
- end
21
- end
@@ -1,29 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `functions` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `name` varchar(128) NOT NULL,
6
- `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
7
- `runner_id` int(11) unsigned NOT NULL,
8
- `args` text,
9
- `user_owner` int(11) unsigned DEFAULT NULL,
10
- `group_owner` int(11) unsigned DEFAULT NULL,
11
- `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
12
- `updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
13
- PRIMARY KEY (`id`),
14
- UNIQUE KEY `runner_id` (`runner_id`,`name`),
15
- KEY `active` (`active`),
16
- KEY `namespace` (`runner_id`),
17
- KEY `name` (`name`),
18
- KEY `functions_user_owner` (`user_owner`),
19
- KEY `functions_group_owner` (`group_owner`),
20
- CONSTRAINT `function_runner_id` FOREIGN KEY (`runner_id`) REFERENCES `runners` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
21
- CONSTRAINT `functions_group_owner` FOREIGN KEY (`group_owner`) REFERENCES `groups` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
22
- CONSTRAINT `functions_user_owner` FOREIGN KEY (`user_owner`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
23
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
24
- end
25
-
26
- down do
27
- drop :functions
28
- end
29
- end
@@ -1,25 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `tasks` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `relationship_id` int(11) unsigned NOT NULL,
6
- `status` varchar(255) NOT NULL,
7
- `parent_id` int(11) unsigned DEFAULT NULL,
8
- `master_id` int(11) unsigned DEFAULT NULL,
9
- `args` text,
10
- `results` text,
11
- `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
12
- `updated` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
13
- PRIMARY KEY (`id`),
14
- KEY `status` (`status`),
15
- KEY `parent_id` (`parent_id`),
16
- KEY `master_id` (`master_id`),
17
- CONSTRAINT `parent_id` FOREIGN KEY (`parent_id`) REFERENCES `tasks` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
18
- CONSTRAINT `master_id` FOREIGN KEY (`master_id`) REFERENCES `tasks` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
19
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
20
- end
21
-
22
- down do
23
- drop :tasks
24
- end
25
- end
@@ -1,17 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `task_logs` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `task_id` int(11) unsigned NOT NULL,
6
- `entry` text NOT NULL,
7
- `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
8
- `updated` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
9
- PRIMARY KEY (`id`),
10
- CONSTRAINT `task_log_task_id` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
11
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
12
- end
13
-
14
- down do
15
- drop :task_logs
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run "CREATE TABLE `relationships` (
4
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
5
- `name` varchar(255) DEFAULT NULL,
6
- `active` tinyint(1) unsigned NOT NULL DEFAULT '1',
7
- `chain_id` int(11) unsigned DEFAULT NULL,
8
- `trigger_id` int(11) unsigned NOT NULL,
9
- `action_id` int(11) unsigned NOT NULL,
10
- `delay` int(11) unsigned NOT NULL DEFAULT '0',
11
- `allow_new_chains` tinyint(1) unsigned NOT NULL DEFAULT '1',
12
- `conditions` text,
13
- `transformation` text,
14
- `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
15
- `updated` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
16
- PRIMARY KEY (`id`),
17
- KEY `chain_id` (`chain_id`),
18
- CONSTRAINT `function_chain_id` FOREIGN KEY (`chain_id`) REFERENCES `chains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
19
- CONSTRAINT `relationship_action_id` FOREIGN KEY (`action_id`) REFERENCES `functions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
20
- CONSTRAINT `relationship_trigger_id` FOREIGN KEY (`trigger_id`) REFERENCES `functions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
21
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
22
- end
23
-
24
- down do
25
- drop :task_logs
26
- end
27
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Data
5
- module Model
6
- class Chain < Sequel::Model
7
- one_to_many :relationship
8
- many_to_one :user_owner, class: Legion::Data::Model::User
9
- many_to_one :group_owner, class: Legion::Data::Model::Group
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Data
5
- module Model
6
- class Datacenter < Sequel::Model
7
- one_to_many :node
8
- many_to_one :user_owner, class: Legion::Data::Model::User
9
- many_to_one :group_owner, class: Legion::Data::Model::Group
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Data
5
- module Model
6
- class Environment < Sequel::Model
7
- one_to_many :node
8
- many_to_one :user_owner, class: Legion::Data::Model::User
9
- many_to_one :group_owner, class: Legion::Data::Model::Group
10
- end
11
- end
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Data
5
- module Model
6
- class Group < Sequel::Model
7
- end
8
- end
9
- end
10
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Data
5
- module Model
6
- class Namespace < Sequel::Model
7
- one_to_many :function
8
- many_to_one :extension
9
- many_to_one :user_owner, class: Legion::Data::Model::User
10
- many_to_one :group_owner, class: Legion::Data::Model::Group
11
- end
12
- end
13
- end
14
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'function'
4
-
5
- module Legion
6
- module Data
7
- module Model
8
- class Relationship < Sequel::Model
9
- many_to_one :chain
10
- one_to_many :task
11
- many_to_one :trigger, class: Legion::Data::Model::Function
12
- many_to_one :action, class: Legion::Data::Model::Function
13
- many_to_one :user_owner, class: Legion::Data::Model::User
14
- many_to_one :group_owner, class: Legion::Data::Model::Group
15
- end
16
- end
17
- end
18
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Data
5
- module Model
6
- class User < Sequel::Model
7
- end
8
- end
9
- end
10
- end