power_stencil 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/README.md +36 -22
- data/bin/update_plugin_template +0 -0
- data/doc/builds.md +1 -1
- data/doc/entities.md +10 -4
- data/doc/faq.md +106 -0
- data/doc/templates.md +1 -1
- data/etc/base_commands_definition.yml +12 -0
- data/etc/meta_templates/plugin_seed/etc/plugin_config.yaml +24 -1
- data/etc/meta_templates/plugin_seed/lib/{entity}/{entity}_processor.rb.erb +0 -1
- data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +2 -2
- data/etc/power_stencil.yaml +13 -1
- data/etc/templates/plugin_definition/.travis.yml +3 -1
- data/etc/templates/plugin_definition/Gemfile +0 -2
- data/etc/templates/plugin_definition/etc/plugin_config.yaml +24 -1
- data/etc/templates/plugin_definition/lib/{entity}/{entity}_processor.rb.erb +0 -1
- data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +2 -2
- data/etc/templates/project/.ps_project/personal-config.yaml +29 -4
- data/etc/templates/project/.ps_project/versioned-config.yaml +24 -1
- data/lib/power_stencil.rb +1 -0
- data/lib/power_stencil/command_processors/entity_helper.rb +2 -1
- data/lib/power_stencil/command_processors/get.rb +13 -4
- data/lib/power_stencil/project/config.rb +5 -3
- data/lib/power_stencil/system_entity_definitions/entity_project_common.rb +14 -0
- data/lib/power_stencil/utils/graphviz.rb +56 -0
- data/lib/power_stencil/version.rb +1 -1
- data/power_stencil.gemspec +2 -2
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9852320333b0476c1e74b31ea327946e3a6d94b9
|
4
|
+
data.tar.gz: 44de44adfb97d695d8f1e7311566cea9b4ae47a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d867a9e2efa622ecce40dac7446309a1164c1a8b2750855ef4217708e519984c31698a1c567090d5defe630045c056397f9083ebbdfd15b698acdf4a295063b5
|
7
|
+
data.tar.gz: fc06c6240c6d8f60a4eabe4f0c1a7fc3cb83a9d72c5e2ed7878296466637f8fa03519994f8ec66222f7a4d838e38081f15ab2a593d965be583900fed7a5f59aa
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@ PowerStencil
|
|
5
5
|
|
6
6
|
<!-- TOC -->
|
7
7
|
|
8
|
-
- [
|
8
|
+
- [Overview](#overview)
|
9
9
|
- [Pfff, yet another templating engine...](#pfff-yet-another-templating-engine)
|
10
10
|
- [Installation](#installation)
|
11
11
|
- [Usage](#usage)
|
@@ -13,36 +13,37 @@ PowerStencil
|
|
13
13
|
- [Creating a `PowerStencil` project](#creating-a-powerstencil-project)
|
14
14
|
- [`PowerStencil` project structure](#powerstencil-project-structure)
|
15
15
|
- [Getting started](#getting-started)
|
16
|
+
- [Project status](#project-status)
|
16
17
|
- [Contributing](#contributing)
|
17
18
|
- [License](#license)
|
18
19
|
- [Code of Conduct](#code-of-conduct)
|
19
20
|
|
20
21
|
<!-- /TOC -->
|
21
22
|
|
22
|
-
#
|
23
|
+
# Overview
|
23
24
|
|
24
25
|
`PowerStencil` proposes a radical approach on how to manage your shared configuration.
|
25
26
|
|
26
|
-
|
27
|
+
**Configuration** is one of the most complex things to maintain, and anyone who participated in a large scale piece of software or documentation knows how complex it is to maintain, **keep consistent and avoid duplication** on the long run across the various projects that may share this configuration.
|
27
28
|
|
28
|
-
|
29
|
+
From a very high level point of view, the workfow `PowerStencil` proposes looks like:
|
29
30
|
|
30
|
-
|
31
|
+
![simple-flow-image]
|
31
32
|
|
32
33
|
`PowerStencil` provides **development and operations friendly workflows to fully manage the maintenance of a complex shared config** in order to generate anything you may want like _documentation_, _static sites_, _code_, _configuration_ for multiple tools..., while **avoiding duplication, and manage it like code** !
|
33
34
|
|
34
|
-
It is a common pattern to introduce a database to manage
|
35
|
+
It is a common pattern to introduce a database to manage shared configuration for CI/CD processes, and it is a very bad idea (see [F.A.Q.]) because it implies extra tooling, and specific developments that de-facto become single point of failure at the heart of your development process. Why would you do that when something as versatile and ubiquitous as Git exists that will integrate smoothly within your existing development and operations workflows, builds, CI/CD processes, while benefiting from all the goodness provided by Git, like branches, decentralization, versioning, tags, code reviews, traceability, simplified fallbacks etc... ?
|
35
36
|
|
36
|
-
**
|
37
|
+
A `PowerStencil` project is composed of a data repository and a pretty standard templating flow to generate whatever is needed by your project or organization and **with `PowerStencil` everything is maintained in a git repository**: data, templates, specific code **without sacrificing on data integrity and relational features**. No more config loss, no more change applied without a full lineage.
|
37
38
|
|
38
|
-
|
39
|
+
**:information_source: With `PowerStencil` data can either be managed as documents to edit (Yaml) or code !!**. Use the best method depending on what you are doing.
|
39
40
|
|
40
41
|
The `PowerStencil` gem provides the `power_stencil` executable which is a pluggable CLI to:
|
41
42
|
|
42
|
-
-
|
43
|
-
- Manage
|
44
|
-
- Manage
|
45
|
-
- Create and manipulate
|
43
|
+
- Manage the project data
|
44
|
+
- Manage templates
|
45
|
+
- Manage builds
|
46
|
+
- Create and manipulate plugins
|
46
47
|
|
47
48
|
# Pfff, yet another templating engine...
|
48
49
|
|
@@ -110,17 +111,19 @@ The program uses the standard paradigm of sub-commands (à-la-git), and each can
|
|
110
111
|
|
111
112
|
To create a new project, use the `init` sub-command. It works as you would expect. If you run it in an existing directory it will create the project here but you can specify the directory where you want the project to be created (the path will be created provided you have the rights on the filesystem):
|
112
113
|
|
113
|
-
$ power_stencil init
|
114
|
+
$ power_stencil init /where/you/want/your/project
|
114
115
|
|
115
|
-
|
116
|
+
Once the project created, if you are anywhere within the project tree, you don't need to specify the project path anymore (if needed, any `power_stencil` sub-command supports a `--project-path` option). If you're used to the Git command line, it works the same way, and you should not feel in uncharted territory...
|
116
117
|
|
117
118
|
:information_source: The rest of this documentation will assume you are at the root of this created project.
|
118
119
|
|
119
|
-
|
120
|
+
**:information_source: Of course, once you've been creating a new project, you should version it with Git:**
|
120
121
|
|
121
122
|
$ git init
|
123
|
+
$ git add .
|
122
124
|
$ git commit -a -m 'Initial commit'
|
123
125
|
|
126
|
+
This will allow you to track any change resulting of your interactions with `power_stencil` command line.
|
124
127
|
|
125
128
|
## `PowerStencil` project structure
|
126
129
|
|
@@ -141,9 +144,9 @@ The structure of a brand new `PowerStencil` project is the following:
|
|
141
144
|
│ └── README.md
|
142
145
|
└── versioned-config.yaml
|
143
146
|
```
|
144
|
-
New directories will appear once you start some [builds] or when you will define [templates].
|
147
|
+
New directories will appear once you start some [builds] or when you will define [templates], but this is the initial state.
|
145
148
|
|
146
|
-
Not all the files in this directory should be versioned, and this the reason why there is a preconfigured `.gitignore` at the root of the project.
|
149
|
+
Not all the files in this directory should be versioned, and this the reason why there is a preconfigured `.gitignore` at the root of the project. It is prefilled so that unless you want to specifically avoid a file to be versioned, you don't need any action regarding `PowerStencil` project files.
|
147
150
|
|
148
151
|
The project has two distinct config files. Keep the official project config in the `.ps_project/versioned-config.yaml` which, as its name suggest will be versioned. But any developer who wants to temporarily override some configuration should do it in the `.ps_project/personal-config.yaml` which is not be versioned. The content defined in the latter overrides the content of the official one. This is a clean way for anyone who wants to test something to safely do it locally without the risk to pollute the central repo.
|
149
152
|
|
@@ -155,19 +158,28 @@ The `plugins` directory can optionally contain project specific plugins. Plugins
|
|
155
158
|
|
156
159
|
The core of the system is the `entity`, so you should start by having a look at what entities are, how they are easily managed using the `PowerStencil` CLI and shell.
|
157
160
|
|
158
|
-
:arrow_forward: [Entities]
|
161
|
+
> :arrow_forward: [Entities]
|
159
162
|
|
160
163
|
Then it is important to understand how to use entities within `templates`. Templates are the way to generate something (doc, code, descriptors, sites, whatever...) from the data that the entities represent.
|
161
164
|
|
162
|
-
:arrow_forward: [Templates]
|
165
|
+
> :arrow_forward: [Templates]
|
163
166
|
|
164
167
|
The mechanism that combines entities and templates is called a `build`. A build is always attached to an entity (you build something). The result of a build is a set of files. Optionally an action can be triggered after the files are generated (could be as simple as calling a script that has been generated).
|
165
168
|
|
166
|
-
:arrow_forward: [Builds]
|
169
|
+
> :arrow_forward: [Builds]
|
167
170
|
|
168
171
|
`PowerStencil` could stop there, and you would be able to do whatever you want, but there is a whole world beyond. `Plugins` provide a way to completely extend `PowerStencil`, further control relations between entities, implement complex post-build actions, add CLI sub-commands and options. Plugins can be local to the project or coming in the form of standard Ruby Gems ! The icing on the cake...
|
169
172
|
|
170
|
-
:arrow_forward: [Plugins]
|
173
|
+
> :arrow_forward: [Plugins]
|
174
|
+
|
175
|
+
And course, you may:
|
176
|
+
|
177
|
+
- Read the [F.A.Q.]
|
178
|
+
- See some real world [example use cases].
|
179
|
+
|
180
|
+
# Project status
|
181
|
+
|
182
|
+
Check `PowerStencil` [status in the F.A.Q.].
|
171
183
|
|
172
184
|
# Contributing
|
173
185
|
|
@@ -189,6 +201,8 @@ Everyone interacting in the PowerStencil project’s codebases, issue trackers,
|
|
189
201
|
[builds]: doc/builds.md "Builds in PowerStencil"
|
190
202
|
[plugins]: doc/plugins.md "Plugins in PowerStencil"
|
191
203
|
[example use cases]: doc/example_use_cases.md "Example uses cases using PowerStencil"
|
204
|
+
[F.A.Q.]: doc/faq.md "PowerStencil F.A.Q."
|
205
|
+
[status in the F.A.Q.]: doc/faq.md#what-is-the-status-of-powerstencil- "PowerStencil project status"
|
192
206
|
[code of conduct]: CODE_OF_CONDUCT.md
|
193
207
|
|
194
208
|
<!-- Code links -->
|
@@ -201,4 +215,4 @@ Everyone interacting in the PowerStencil project’s codebases, issue trackers,
|
|
201
215
|
[MIT License]: http://opensource.org/licenses/MIT "The MIT license"
|
202
216
|
[ERB]: https://ruby-doc.org/stdlib-2.6.3/libdoc/erb/rdoc/ERB.html "Quick ERB description"
|
203
217
|
[Haml]: http://haml.info/ "The templating engine for XML-like documents"
|
204
|
-
[Ruby]: https://www.ruby-lang.org "The powerful Ruby language"
|
218
|
+
[Ruby]: https://www.ruby-lang.org "The powerful Ruby language"
|
data/bin/update_plugin_template
CHANGED
File without changes
|
data/doc/builds.md
CHANGED
@@ -255,7 +255,7 @@ If you want to do something more custom after the build process completed, this
|
|
255
255
|
[entities]: entities.md "Entities in PowerStencil"
|
256
256
|
[templates]: templates.md "Templates in PowerStencil"
|
257
257
|
[plugins]: plugins.md "Plugins in PowerStencil"
|
258
|
-
[buildable]: entities.md#buildable
|
258
|
+
[buildable]: entities.md#buildable-and-buildable_by "How to make an entity buildable ?"
|
259
259
|
[local entities]: entities.md#local-unversioned-entities "Local unversioned entities"
|
260
260
|
|
261
261
|
<!-- Code links -->
|
data/doc/entities.md
CHANGED
@@ -33,7 +33,7 @@ Entities
|
|
33
33
|
- [not_empty](#not_empty)
|
34
34
|
- [should_match](#should_match)
|
35
35
|
- [class_name](#class_name)
|
36
|
-
- [buildable
|
36
|
+
- [buildable and buildable_by](#buildable-and-buildable_by)
|
37
37
|
- [Module you could include in your entity types](#module-you-could-include-in-your-entity-types)
|
38
38
|
- [Adding functional code](#adding-functional-code)
|
39
39
|
|
@@ -272,7 +272,12 @@ $ power_stencil get base_entity --names-only --regexp
|
|
272
272
|
|
273
273
|
- my_1st_entity
|
274
274
|
```
|
275
|
-
There are 2 other options (`--compiled` and `--scenario`) but they will be covered in the scope of [builds].
|
275
|
+
There are 2 other interesting options (`--compiled` and `--scenario`) but they will be covered in the scope of [builds].
|
276
|
+
|
277
|
+
:information_source: Another very interesting option is `--graph`. **It will generate a [Graphviz] graph of the relations of the entities within the repository.** This is actually provided by the [universe_compiler] Gem. The display of this graph can be completed customized at project level (the 2 versioned and unversioned config files), at entity level (by providing a `#graphviz_label` method in your entities. You'll see later in that document what it means in [creating custom entity types](#creating-custom-entity-types)), and even at plugin level.
|
278
|
+
|
279
|
+
By default the graph is generated in a temporary folder, but of course you can specify the file name using the `--graph-file` options. The default is to generate an svg file (best viewed in a browser as it contains _hover_ over its nodes).
|
280
|
+
|
276
281
|
|
277
282
|
## Creating entities
|
278
283
|
|
@@ -908,7 +913,7 @@ PowerStencil DSL> e.valid? raise_error: true
|
|
908
913
|
|
909
914
|
:warning: Use this one with caution, as it does not test anything regarding inheritance...
|
910
915
|
|
911
|
-
### buildable
|
916
|
+
### buildable and buildable_by
|
912
917
|
|
913
918
|
One of the most important directives !
|
914
919
|
More information is provided in the [builds] documentation, but basically this defines an `entity_type` as a potential target for the build process.
|
@@ -963,4 +968,5 @@ Now you know an entity type is just a regular Ruby class. As such you could add
|
|
963
968
|
[Pry]: https://github.com/pry/pry "The awesome Pry console"
|
964
969
|
[ActiveRecord]: https://guides.rubyonrails.org/active_record_basics.html "The ultimate ORM"
|
965
970
|
[Ruby On Rails]: https://rubyonrails.org/ "One of the best Web framework"
|
966
|
-
[universe_compiler]: https://gitlab.com/tools4devops/universe_compiler "The underlying engine to manage entities and compilation !"
|
971
|
+
[universe_compiler]: https://gitlab.com/tools4devops/universe_compiler "The underlying engine to manage entities and compilation !"
|
972
|
+
[Graphviz]: (https://www.graphviz.org/) "Graph Visualization Software"
|
data/doc/faq.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
F.A.Q.
|
2
|
+
======
|
3
|
+
|
4
|
+
<!-- TOC -->
|
5
|
+
|
6
|
+
- [How does `PowerStencil` compare with a CMDB ?](#how-does-powerstencil-compare-with-a-cmdb-)
|
7
|
+
- [Why is a "real" database a bad idea as configuration store for CI/CD ?](#why-is-a-real-database-a-bad-idea-as-configuration-store-for-cicd-)
|
8
|
+
- [How does `PowerStencil` compare to environment variables + subst ?](#how-does-powerstencil-compare-to-environment-variables--subst-)
|
9
|
+
- [Why data persisted in YAML ?](#why-data-persisted-in-yaml-)
|
10
|
+
- [What are the system requirements ?](#what-are-the-system-requirements-)
|
11
|
+
- [What is the status of `PowerStencil` ?](#what-is-the-status-of-powerstencil-)
|
12
|
+
|
13
|
+
<!-- /TOC -->
|
14
|
+
[:back:][Documentation root]
|
15
|
+
|
16
|
+
# How does `PowerStencil` compare with a CMDB ?
|
17
|
+
|
18
|
+
It could sound like a strange question. `PowerStencil` is absolutelly not designed with ITIL in mind but in the end its true that its data management part looks a lot like a [CMDB].
|
19
|
+
|
20
|
+
- [Entities][entities] (and more specifically entity types) can cover most aspects (I am not ITIL expert enough to say it covers all of them) of ITIL's _Configuration Items_. Default entities provided with `PowerStencil` do not contain all necessary attributes to do be really considered as _configuration items_, but it should be very easy to achieve with custom entities. In fact it could be a good idea of [plugin][plugins]...
|
21
|
+
- Relation semantics in `PowerStencil` cover 1-1, 1-n and composition relation patterns.
|
22
|
+
- Versioning is achieved through Git. Implying on top of versioning, branching, merging
|
23
|
+
|
24
|
+
But `PowerStencil` cannot be simplified to it's "database" aspect. It goes well beyond, and is as well a pragmatic workflow for developers and operations to actually do something out of this data. A [CMDB] may be used by external processes in order to achieve what `PowerStencil` does out of the box.
|
25
|
+
|
26
|
+
|
27
|
+
# Why is a "real" database a bad idea as configuration store for CI/CD ?
|
28
|
+
|
29
|
+
There are some reasons why using a database in the scope of CI/CD is not a good idea.
|
30
|
+
|
31
|
+
Basically the CI/CD infrastructure could be built around Jenkins, containerized tools (Drone for example), Travis, GitlabCI... The goal being to provide the **easiest possible way for the developer** to perform integration tests and eventually build and deploy software.
|
32
|
+
|
33
|
+
But the easiest possible way for the developer doesn't mean that the underlying infrastructure is simple to put in place or maintain. In fact it is not !
|
34
|
+
|
35
|
+
Anything you add to this carefully crafted mechanic could turn into an infrastructure management nightmare. And a database (and its availability, maintenance) is clearly not the simplest component to inject in your infrastructure...
|
36
|
+
|
37
|
+
On top of this, a database does not not provide by default all the required features. Versioning is obviously one of them but of course not the only one (you may think about branching or others...). Meaning that **you need to have custom developments** on top of the chosen database in order to achieve all the required features. It immediately becomes a de-facto single point of failure in your CI/CD process...
|
38
|
+
|
39
|
+
Relying on Git to achieve the storage, versioning, branching, decentralization is a much easier way to achieve the same. There is no need to have specific developments as any CI/CD mechanism knows how to deal with extra git repository.
|
40
|
+
|
41
|
+
# How does `PowerStencil` compare to environment variables + subst ?
|
42
|
+
|
43
|
+
If you have very few files/templates, you may consider this as a solution, but as soon as your templates will complexify or some data need to reference some other, you will enter a loop of death that will make you regret your initial choice.
|
44
|
+
|
45
|
+
`PowerStencil` is not a templating engine, it is a framework!
|
46
|
+
|
47
|
+
Not only it [allows structured and relational data][entities], it structures your work as well, and provides mechanisms to allow developers to [easily perform tests without committing unwanted changes by mistake][overrides].
|
48
|
+
|
49
|
+
Due on how it is easy to use `PowerStencil`, even for the simplest use cases, there is no real reason not to use it.
|
50
|
+
|
51
|
+
|
52
|
+
# Why data persisted in YAML ?
|
53
|
+
|
54
|
+
Assuming Git is used for storage and versioning **we need to have a data format that is git-friendly**.
|
55
|
+
|
56
|
+
- So it discards local databases like SQLite, BerkeleyDB or others which are binary formats.
|
57
|
+
- XML is **not** a human readable format and is a real pain to _diff_. It should have been kept for what it has been designed for, ie machine to machine protocols...
|
58
|
+
|
59
|
+
So the two main remaining contenders are JSON and YAML. Although there is no real reason to take one more than the other, including the manipulating language, would I have written `PowerStencil` in JS or Go, I may probably have chosen JSON as storage format. But it is written in Ruby and therefore I went for YAML.
|
60
|
+
|
61
|
+
|
62
|
+
# What are the system requirements ?
|
63
|
+
|
64
|
+
`PowerStencil` has been developed under Linux, but it's only requiring a working Ruby installed on your machine.
|
65
|
+
|
66
|
+
As such, even if I never tested, I would expect it to probably work out of the box on MacOS, BSD or other Unices supporting Ruby 2.2+.
|
67
|
+
|
68
|
+
Regarding Windows, I stopped using spywareOS years ago so I can't really tell you. Last time I tried using Ruby on Windows (maybe 10 years ago), I did face a lot of dependency issues. Maybe things are better now, but I have no idea. As far as I understood you can now have an Ubuntu running on top of Windows 10 as a kind of blessed VM. I would probably more go this way...
|
69
|
+
|
70
|
+
|
71
|
+
# What is the status of `PowerStencil` ?
|
72
|
+
|
73
|
+
Although `PowerStencil` is still under development, **it can already be safely used**.
|
74
|
+
|
75
|
+
Regarding `PowerStencil` core:
|
76
|
+
|
77
|
+
- The part that may evolve the most is the plugin part (including documentation which is not really in par with the rest...), but it should not break anything developed now.
|
78
|
+
- New system entity types may appear.
|
79
|
+
|
80
|
+
Anyway `PowerStencil` follows the semantic versioning pattern and if incompatible changes arise it may be reflected in the version.
|
81
|
+
|
82
|
+
There are already some plugins in the pipe, especially around contenerization topics.
|
83
|
+
|
84
|
+
:information_source: Of course, `PowerStencil` is new software and it is expected to evolve with the needs of its users...
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
[:back:][Documentation root]
|
90
|
+
<!-- End of Document -->
|
91
|
+
|
92
|
+
<!-- Pages -->
|
93
|
+
[Documentation root]: ../README.md "Back to documentation root"
|
94
|
+
[entities]: entities.md "Entities in PowerStencil"
|
95
|
+
[plugins]: plugins.md "Plugins in PowerStencil"
|
96
|
+
[overrides]: builds.md#overriding-entities-and-build-scenarii "Overriding data locally"
|
97
|
+
|
98
|
+
|
99
|
+
<!-- Code links -->
|
100
|
+
|
101
|
+
|
102
|
+
<!-- Illustrations -->
|
103
|
+
|
104
|
+
|
105
|
+
<!-- External links -->
|
106
|
+
[CMDB]: https://en.wikipedia.org/wiki/Configuration_management_database "Configuration Management Database"
|
data/doc/templates.md
CHANGED
@@ -317,7 +317,7 @@ Flawless victory !!
|
|
317
317
|
[builds]: builds.md "Builds in PowerStencil"
|
318
318
|
[plugins]: plugins.md "Plugins in PowerStencil"
|
319
319
|
[example use cases]: example_use_cases.md "Example uses cases using PowerStencil"
|
320
|
-
[buildable]: entities.md#buildable
|
320
|
+
[buildable]: entities.md#buildable-and-buildable_by "How to make an entity buildable ?"
|
321
321
|
|
322
322
|
<!-- Code links -->
|
323
323
|
|
@@ -125,6 +125,13 @@
|
|
125
125
|
names-only:
|
126
126
|
:type: bool
|
127
127
|
:summary: Only returns the name of the entities found.
|
128
|
+
:long_aliases:
|
129
|
+
- names
|
130
|
+
- name
|
131
|
+
- short
|
132
|
+
:short_aliases:
|
133
|
+
- n
|
134
|
+
- s
|
128
135
|
compiled: &COMPILEDOPT
|
129
136
|
:type: bool
|
130
137
|
:summary: Entities as used by susbstitution engine.
|
@@ -141,6 +148,11 @@
|
|
141
148
|
:summary: Displays the query result as a graph.
|
142
149
|
:short_aliases:
|
143
150
|
- g
|
151
|
+
graph-file:
|
152
|
+
:type: string
|
153
|
+
:summary: Displays the query result as a graph in the specified file.
|
154
|
+
:long_aliases:
|
155
|
+
- gf
|
144
156
|
shell:
|
145
157
|
:banner: |
|
146
158
|
Opens a shell to interact with entities.
|
@@ -1,4 +1,27 @@
|
|
1
1
|
# This config file provided by the plugin '<%= main_entry_point %>' will be
|
2
2
|
# automatically merged into the global project config
|
3
3
|
|
4
|
-
|
4
|
+
:<%= plugin_name %>.property1: value 1
|
5
|
+
|
6
|
+
# Graphviz configuration
|
7
|
+
#
|
8
|
+
# If you are under Gnome, chances are that you have 'eog' installed
|
9
|
+
# or put you own there. Unless in the path specify full path to it:
|
10
|
+
# node defines the default graphviz node attributes. In customization
|
11
|
+
# each key can be an entity type, that you can fully customize using the
|
12
|
+
# same mechanism
|
13
|
+
|
14
|
+
#:graphviz:
|
15
|
+
# :viewer: eog '%s'
|
16
|
+
# :label: < Repository Entities <br/> >
|
17
|
+
# :labelloc: :t
|
18
|
+
# :show_config: false
|
19
|
+
# :file_type: svg
|
20
|
+
# :node:
|
21
|
+
# :shape: box
|
22
|
+
# :style: filled
|
23
|
+
# :fillcolor: grey95
|
24
|
+
# :customizations:
|
25
|
+
# :my_custom_entity:
|
26
|
+
# :shape: circle
|
27
|
+
# :fillcolor: red
|
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
|
32
|
-
spec.add_development_dependency 'bundler', '~>
|
32
|
+
spec.add_development_dependency 'bundler', '~> 2.0.2'
|
33
33
|
spec.add_development_dependency 'rake', '~> 10.0'
|
34
34
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
-
spec.add_development_dependency 'power_stencil', "~>
|
35
|
+
spec.add_development_dependency 'power_stencil', "~> <%= PowerStencil::VERSION %>"
|
36
36
|
end
|
data/etc/power_stencil.yaml
CHANGED
@@ -82,7 +82,19 @@
|
|
82
82
|
# are automatically discovered and loaded.
|
83
83
|
:project_plugins: []
|
84
84
|
|
85
|
-
|
85
|
+
# Graphviz
|
86
|
+
|
87
|
+
# Customize graphviz properties
|
88
|
+
:graphviz:
|
89
|
+
:label: < Repository Entities <br/> >
|
90
|
+
:labelloc: :t
|
91
|
+
:show_config: false
|
92
|
+
:file_type: :svg
|
93
|
+
:node:
|
94
|
+
:shape: box
|
95
|
+
:style: filled
|
96
|
+
:fillcolor: grey95
|
97
|
+
:customizations: {}
|
86
98
|
|
87
99
|
# MISC
|
88
100
|
|
@@ -1,4 +1,27 @@
|
|
1
1
|
# This config file provided by the plugin '<%= main_entry_point %>' will be
|
2
2
|
# automatically merged into the global project config
|
3
3
|
|
4
|
-
|
4
|
+
:<%= plugin_name %>.property1: value 1
|
5
|
+
|
6
|
+
# Graphviz configuration
|
7
|
+
#
|
8
|
+
# If you are under Gnome, chances are that you have 'eog' installed
|
9
|
+
# or put you own there. Unless in the path specify full path to it:
|
10
|
+
# node defines the default graphviz node attributes. In customization
|
11
|
+
# each key can be an entity type, that you can fully customize using the
|
12
|
+
# same mechanism
|
13
|
+
|
14
|
+
#:graphviz:
|
15
|
+
# :viewer: eog '%s'
|
16
|
+
# :label: < Repository Entities <br/> >
|
17
|
+
# :labelloc: :t
|
18
|
+
# :show_config: false
|
19
|
+
# :file_type: svg
|
20
|
+
# :node:
|
21
|
+
# :shape: box
|
22
|
+
# :style: filled
|
23
|
+
# :fillcolor: grey95
|
24
|
+
# :customizations:
|
25
|
+
# :my_custom_entity:
|
26
|
+
# :shape: circle
|
27
|
+
# :fillcolor: red
|
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
|
32
|
-
spec.add_development_dependency 'bundler', '~>
|
32
|
+
spec.add_development_dependency 'bundler', '~> 2.0.2'
|
33
33
|
spec.add_development_dependency 'rake', '~> 10.0'
|
34
34
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
-
spec.add_development_dependency 'power_stencil', "~>
|
35
|
+
spec.add_development_dependency 'power_stencil', "~> <%= PowerStencil::VERSION %>"
|
36
36
|
end
|
@@ -2,7 +2,32 @@
|
|
2
2
|
# THIS FILE *IS NOT* MEANT TO BE VERSIONED (and is not by default)
|
3
3
|
# You can use it for any configuration you want to keep local
|
4
4
|
|
5
|
-
#
|
6
|
-
|
7
|
-
# :
|
8
|
-
|
5
|
+
# Common configuration
|
6
|
+
|
7
|
+
# :debug: true
|
8
|
+
:log-level: 2
|
9
|
+
# :debug-on-stderr: true
|
10
|
+
# :verbose: true
|
11
|
+
|
12
|
+
# Graphviz configuration
|
13
|
+
#
|
14
|
+
# If you are under Gnome, chances are that you have 'eog' installed
|
15
|
+
# or put you own there. Unless in the path specify full path to it:
|
16
|
+
# node defines the default graphviz node attributes. In customization
|
17
|
+
# each key can be an entity type, that you can fully customize using the
|
18
|
+
# same mechanism
|
19
|
+
|
20
|
+
#:graphviz:
|
21
|
+
# :viewer: eog '%s'
|
22
|
+
# :label: < Repository Entities <br/> >
|
23
|
+
# :labelloc: :t
|
24
|
+
# :show_config: false
|
25
|
+
# :file_type: svg
|
26
|
+
# :node:
|
27
|
+
# :shape: box
|
28
|
+
# :style: filled
|
29
|
+
# :fillcolor: grey95
|
30
|
+
# :customizations:
|
31
|
+
# :my_custom_entity:
|
32
|
+
# :shape: circle
|
33
|
+
# :fillcolor: red
|
@@ -3,4 +3,27 @@
|
|
3
3
|
# You can use it for any configuration you want to keep at repository level
|
4
4
|
|
5
5
|
# If you want to ensure a minimal version number of PowerStencil
|
6
|
-
:min_power_stencil_version: <%= PowerStencil::VERSION %>
|
6
|
+
:min_power_stencil_version: <%= PowerStencil::VERSION %>
|
7
|
+
|
8
|
+
# Graphviz configuration
|
9
|
+
#
|
10
|
+
# If you are under Gnome, chances are that you have 'eog' installed
|
11
|
+
# or put you own there. Unless in the path specify full path to it:
|
12
|
+
# node defines the default graphviz node attributes. In customization
|
13
|
+
# each key can be an entity type, that you can fully customize using the
|
14
|
+
# same mechanism
|
15
|
+
|
16
|
+
#:graphviz:
|
17
|
+
# :viewer: eog '%s'
|
18
|
+
# :label: < Repository Entities <br/> >
|
19
|
+
# :labelloc: :t
|
20
|
+
# :show_config: false
|
21
|
+
# :file_type: svg
|
22
|
+
# :node:
|
23
|
+
# :shape: box
|
24
|
+
# :style: filled
|
25
|
+
# :fillcolor: grey95
|
26
|
+
# :customizations:
|
27
|
+
# :my_custom_entity:
|
28
|
+
# :shape: circle
|
29
|
+
# :fillcolor: red
|
data/lib/power_stencil.rb
CHANGED
@@ -13,6 +13,7 @@ require 'power_stencil/utils/directory_processor'
|
|
13
13
|
require 'power_stencil/utils/secure_require'
|
14
14
|
require 'power_stencil/utils/gem_utils'
|
15
15
|
require 'power_stencil/utils/file_edit'
|
16
|
+
require 'power_stencil/utils/graphviz'
|
16
17
|
|
17
18
|
require 'climatic/script/unimplemented_processor'
|
18
19
|
require 'power_stencil/project/proxy'
|
@@ -12,13 +12,14 @@ module PowerStencil
|
|
12
12
|
def display_entity(entity)
|
13
13
|
puts_and_logs "# Entity '#{entity.name}' (#{entity.type})"
|
14
14
|
if config[:'names-only']
|
15
|
-
puts "- #{entity.name}"
|
15
|
+
puts "- '#{entity.as_path}' ('#{entity.name}' of the type '#{entity.type}')"
|
16
16
|
else
|
17
17
|
if config[:raw]
|
18
18
|
puts entity.to_yaml
|
19
19
|
else
|
20
20
|
puts entity.to_hash.to_yaml
|
21
21
|
end
|
22
|
+
puts
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -7,16 +7,25 @@ module PowerStencil
|
|
7
7
|
include Climatic::Proxy
|
8
8
|
include PowerStencil::Project::Proxy
|
9
9
|
include PowerStencil::CommandProcessors::EntityHelper
|
10
|
+
include PowerStencil::Utils::Graphviz
|
10
11
|
|
11
12
|
def execute
|
12
13
|
targets = targets_from_criteria analyse_extra_params, project.engine.root_universe
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
if config[:graph] || config[:'graph-file']
|
15
|
+
filename = graph_entities targets, config[:'graph-file']
|
16
|
+
msg = "Graphviz graph saved into '#{filename}'."
|
17
|
+
logger.info msg
|
18
|
+
puts msg
|
19
|
+
if config[:graphviz][:viewer]
|
20
|
+
cmd = config[:graphviz][:viewer] % [filename]
|
21
|
+
`#{cmd}`
|
22
|
+
end
|
23
|
+
else
|
24
|
+
targets.sort{|a, b| a.as_path <=> b.as_path}.each {|target| display_entity target }
|
16
25
|
end
|
17
26
|
end
|
18
|
-
|
19
27
|
end
|
20
28
|
|
21
29
|
end
|
30
|
+
|
22
31
|
end
|
@@ -5,9 +5,9 @@ module PowerStencil
|
|
5
5
|
|
6
6
|
include PowerStencil::Project::Paths
|
7
7
|
|
8
|
-
PROJECT_CONFIG_PRIORITY =
|
9
|
-
USER_CONFIG_PRIORITY =
|
10
|
-
PLUGIN_CONFIG_PRIORITY_MIN =
|
8
|
+
PROJECT_CONFIG_PRIORITY = 990
|
9
|
+
USER_CONFIG_PRIORITY = 995
|
10
|
+
PLUGIN_CONFIG_PRIORITY_MIN = 100
|
11
11
|
|
12
12
|
attr_reader :plugin_priority_count
|
13
13
|
|
@@ -16,6 +16,8 @@ module PowerStencil
|
|
16
16
|
# Optional config files should have less priority than the command line layer
|
17
17
|
add_optional_config_layer project_versioned_config_file, 'versioned project config file', PROJECT_CONFIG_PRIORITY
|
18
18
|
add_optional_config_layer project_personal_config_file, 'personal project config file', USER_CONFIG_PRIORITY
|
19
|
+
Climatic.send :setup_logger
|
20
|
+
logger.debug 'Project config files loaded'
|
19
21
|
end
|
20
22
|
|
21
23
|
|
@@ -27,6 +27,20 @@ module PowerStencil
|
|
27
27
|
self.class.buildable?
|
28
28
|
end
|
29
29
|
|
30
|
+
protected
|
31
|
+
|
32
|
+
def project_engine
|
33
|
+
PowerStencil.project.engine
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_universe_entity(type, fields = {})
|
37
|
+
project_engine.new_entity project_engine.root_universe, type, fields: fields
|
38
|
+
end
|
39
|
+
|
40
|
+
def remove_entity_from_universe(entity)
|
41
|
+
project_engine.root_universe.delete entity
|
42
|
+
end
|
43
|
+
|
30
44
|
end
|
31
45
|
|
32
46
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Utils
|
3
|
+
|
4
|
+
module Graphviz
|
5
|
+
|
6
|
+
include UniverseCompiler::Utils::Graphviz
|
7
|
+
|
8
|
+
def graph_entities(entities, filename = nil)
|
9
|
+
entities_to_process = unless config[:graphviz][:show_config]
|
10
|
+
entities.reject {|e| e.type == :project_config}
|
11
|
+
else
|
12
|
+
entities
|
13
|
+
end
|
14
|
+
graph_entities_to_file entities_to_process,
|
15
|
+
output_file_name: filename,
|
16
|
+
file_type: config[:graphviz][:file_type] do |graph, cache|
|
17
|
+
graph[:label] = config[:graphviz][:label]
|
18
|
+
graph[:labelloc] = config[:graphviz][:labelloc]
|
19
|
+
graph.each_node do |node_name|
|
20
|
+
node = graph.get_node node_name
|
21
|
+
entity = cache[:by_node][node]
|
22
|
+
|
23
|
+
# Set default node attributes
|
24
|
+
config[:graphviz][:node].each do |k,v|
|
25
|
+
node[k] = v
|
26
|
+
end
|
27
|
+
fields_to_display = {}
|
28
|
+
|
29
|
+
# Define node tooltip
|
30
|
+
entity.fields.keys.each do |field_name|
|
31
|
+
constraints = entity.class.fields_constraints[field_name]
|
32
|
+
unless constraints.nil?
|
33
|
+
# Remove relations as they are represented as edges
|
34
|
+
next if constraints.keys.include? :has_one
|
35
|
+
next if constraints.keys.include? :has_many
|
36
|
+
end
|
37
|
+
fields_to_display[field_name] = entity[field_name]
|
38
|
+
end
|
39
|
+
node[:tooltip] = fields_to_display.to_yaml
|
40
|
+
|
41
|
+
# specific customizations
|
42
|
+
if config[:graphviz][:customizations][entity.type]
|
43
|
+
config[:graphviz][:customizations][entity.type].each do |k,v|
|
44
|
+
node[k] = v
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
data/power_stencil.gemspec
CHANGED
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
|
28
|
-
spec.add_dependency 'climatic', '~> 0.2', '>= 0.2.
|
28
|
+
spec.add_dependency 'climatic', '~> 0.2', '>= 0.2.29'
|
29
29
|
spec.add_dependency 'dir_glob_ignore', '~> 0.3'
|
30
|
-
spec.add_dependency 'universe_compiler', '~> 0.
|
30
|
+
spec.add_dependency 'universe_compiler', '~> 0.3.0', '>= 0.3.2'
|
31
31
|
spec.add_dependency 'pry'
|
32
32
|
|
33
33
|
spec.post_install_message = %Q{
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: power_stencil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent B.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: '0.2'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.2.
|
64
|
+
version: 0.2.29
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: '0.2'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.2.
|
74
|
+
version: 0.2.29
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: dir_glob_ignore
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,20 +92,20 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 0.3.0
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0.2
|
98
|
+
version: 0.3.2
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
101
|
version_requirements: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: 0.3.0
|
106
106
|
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: 0.2
|
108
|
+
version: 0.3.2
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: pry
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- doc/builds.md
|
144
144
|
- doc/entities.md
|
145
145
|
- doc/example_use_cases.md
|
146
|
+
- doc/faq.md
|
146
147
|
- doc/images/power-stencil-entity-build.svg
|
147
148
|
- doc/images/power-stencil-entity-creation.svg
|
148
149
|
- doc/images/power-stencil-simple-flow.svg
|
@@ -255,6 +256,7 @@ files:
|
|
255
256
|
- lib/power_stencil/utils/file_edit.rb
|
256
257
|
- lib/power_stencil/utils/file_helper.rb
|
257
258
|
- lib/power_stencil/utils/gem_utils.rb
|
259
|
+
- lib/power_stencil/utils/graphviz.rb
|
258
260
|
- lib/power_stencil/utils/secure_require.rb
|
259
261
|
- lib/power_stencil/utils/semantic_version.rb
|
260
262
|
- lib/power_stencil/version.rb
|
@@ -263,7 +265,7 @@ homepage: https://gitlab.com/tools4devops/power_stencil
|
|
263
265
|
licenses:
|
264
266
|
- MIT
|
265
267
|
metadata: {}
|
266
|
-
post_install_message: "\nThank you for installing PowerStencil 0.
|
268
|
+
post_install_message: "\nThank you for installing PowerStencil 0.4.0 !\nFrom the command
|
267
269
|
line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
|
268
270
|
\ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nFull documentation
|
269
271
|
here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
|