Commit f1b69a12 authored by Yi Yang's avatar Yi Yang
Browse files

by MiSc,yang_yi_cn: Updated this module with code from...

by MiSc,yang_yi_cn: Updated this module with code from https://gitlab.wklive.net/wk-public/config_push
parent 917a00e0
Loading
Loading
Loading
Loading

README.md

0 → 100644
+59 −0
Original line number Diff line number Diff line
Config push
===========
The module let's you track changes in your configuration in production to be
to a seperate git repo. When you have that in place you could compare your local
sync directory with the directory (git repo) that is tracking you changes like:
`meld sync config-extras/mysite-prod-conf` (suing meld to compare).


Requirements
============
* Git installed localy and on production.
* A dedicated configuration repo (not the same as sync)
* A git user with ssh keys

Setup
=====
Create a git repo to store a copy of your configuration. Put it outside your web
root, like:

```
├── web
│   ├── autoload.php
│   ├── core
│   ├── index.php
│   ├── profiles
│   ├── robots.txt
│   ├── sites
config-extras
└── mysite-prod-conf
```

Here I created a folder called config-extras an in that I created a git repo in
the folder mysite-prod-conf.

I also pushed that repo to a git repository, and added a user to it. For security
reason - create a new git user that only has access to this repo. That user
should not have access to your normal site-repo.


Modules
=======
To work with this, you need to enable `config_tools` and the sub modules
`git_config` and `config_files`. Add the needed settings in the setup at:
/admin/config/development/configuration/config-push

Recommendation
==============
You should not track changes in config in your development environment after
the initial setup (all your config is written to `mysite-prod-conf` after that),
to not do so, disable the config push functionality, preferably in
settings.local.php.
Like:
```
$config['config_tools.settings']['disabled'] = 1;
```
You could also disable config pushing in th Drupal UI, but when you need
something like config_split (recommended) or config_ignore to not have the module
active locally after the first installation.
+20 −0
Original line number Diff line number Diff line
{
    "name": "drupal/config_tools",
    "description": "Tools for managing config with git",
    "type": "drupal-module",
    "license": "GPL-2.0+",
    "homepage": "https://drupal.org/project/config_tools",
    "authors": [
        {
            "name": "Kris Vanderwater (EclipseGc)",
            "role": "Maintainer"
        },
        {
            "name": "Mikke Schirén (MiSc)",
            "role": "Co-maintainer"
        },
        {
            "name": "Yi Yang (yang_yi_cn)",
            "role": "Co-maintainer"
        }
    ],
    "minimum-stability": "dev",
    "require": {
        "cpliakas/git-wrapper": "^1.7"
    }
+1 −1
Original line number Diff line number Diff line
name: Active configuration file handling.
name: Config push active configuration files
type: module
description: 'Allows you to specify an active file directory to save current configuration.'
package: Configuration
+2 −6
Original line number Diff line number Diff line
config_files.settings:
  route_name: config_files.settings
  base_route: config.sync
  title: 'Tools'
config_files.settings.files:
  route_name: config_files.settings
  parent_id: config_files.settings
  parent_id: config_tools.settings
  title: 'Files'
  weight: -100
 No newline at end of file
  weight: -99
+32 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Allows site administrators to store config seperatly.
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function config_files_help($route_name, RouteMatchInterface $route_match) {




  switch ($route_name) {
    case 'config_files.settings':
      $config = \Drupal::config('git_config.config');
      $git_url = $config->get('git_url');
      if (!isset($git_url)) {
        $output = '<p>' . t('You need to set git settings before setting Active files directory.') . '</p>';
      }
      else {
        $output = '<p>' . t('Config files uses a seperate folder to track changes
        to active configuration. When you push save, all of the active
        configuration will be written to the path specified.') . '</p>';
      }
      return $output;
  }
}
Loading