← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~hyask/autopkgtest-cloud:skia/vimrc into autopkgtest-cloud:master

 

Skia has proposed merging ~hyask/autopkgtest-cloud:skia/vimrc into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/463822

Set a default vimrc on autopkgtest-cloud machines.
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/vimrc into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/layer.yaml b/charms/focal/autopkgtest-cloud-worker/layer.yaml
index 692d9af..70be935 100644
--- a/charms/focal/autopkgtest-cloud-worker/layer.yaml
+++ b/charms/focal/autopkgtest-cloud-worker/layer.yaml
@@ -29,4 +29,5 @@ options:
       - python3-openstackclient
       - python3-swiftclient
       - ssmtp
+      - vim
     include_system_packages: true
diff --git a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
index 4b5b22d..84adb0c 100644
--- a/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
+++ b/charms/focal/autopkgtest-cloud-worker/reactive/autopkgtest_cloud_worker.py
@@ -4,6 +4,7 @@ import json
 import os
 import socket
 import subprocess
+from pathlib import Path
 from textwrap import dedent
 
 import pygit2
@@ -51,6 +52,24 @@ AUTOPKGTEST_PER_PACKAGE_CLONE_LOCATION = (
 RABBITMQ_CRED_PATH = os.path.expanduser("~ubuntu/rabbitmq.cred")
 
 
+@when("apt.installed.vim")
+def configure_vim():
+    status.maintenance("Configuring vim")
+    Path("/etc/vim/vimrc.local").write_text(
+        # pylint: disable=line-too-long
+        """" autopkgtest-cloud vimrc, nicer for admins
+" This file is written by the autopkgtest-cloud charm, do not edit manually, or
+" you may loose your changes.
+set background=dark                                                " dark bg gives lighter colors by default
+set number                                                         " show line numbers
+set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,nbsp:‡     " set display of special characters
+set list                                                           " show those special characters
+highlight ExtraWhitespace ctermbg=red guibg=red                    " highlight extra whitespaces
+match ExtraWhitespace /\\s\\+$\\| \\+\\ze\\t/                            " define what are the extra whitespaces
+    """
+    )
+
+
 @when_not("autopkgtest.autopkgtest_cloud_symlinked")
 def symlink_autopkgtest_cloud():
     status.maintenance("Creating symlink to charmed autopkgtest-cloud code")
diff --git a/charms/focal/autopkgtest-web/layer.yaml b/charms/focal/autopkgtest-web/layer.yaml
index 5c81bdb..6fd70d5 100644
--- a/charms/focal/autopkgtest-web/layer.yaml
+++ b/charms/focal/autopkgtest-web/layer.yaml
@@ -21,4 +21,5 @@ options:
       - python3-flask-openid
       - python3-swiftclient
       - python3-werkzeug
+      - vim
     include_system_packages: true
diff --git a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
index d195127..01d5282 100644
--- a/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
+++ b/charms/focal/autopkgtest-web/reactive/autopkgtest_web.py
@@ -41,6 +41,24 @@ def install_apt_packages():
     clear_flag("apt.queued_installs")
 
 
+@when("apt.installed.vim")
+def configure_vim():
+    status.maintenance("Configuring vim")
+    pathlib.Path("/etc/vim/vimrc.local").write_text(
+        # pylint: disable=line-too-long
+        """" autopkgtest-cloud vimrc, nicer for admins
+" This file is written by the autopkgtest-cloud charm, do not edit manually, or
+" you may loose your changes.
+set background=dark                                                " dark bg gives lighter colors by default
+set number                                                         " show line numbers
+set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,nbsp:‡     " set display of special characters
+set list                                                           " show those special characters
+highlight ExtraWhitespace ctermbg=red guibg=red                    " highlight extra whitespaces
+match ExtraWhitespace /\\s\\+$\\| \\+\\ze\\t/                            " define what are the extra whitespaces
+    """
+    )
+
+
 @when_not("autopkgtest-web.autopkgtest_web_symlinked")
 def symlink_autopkgtest_cloud():
     status.maintenance("Creating symlink to charmed autopkgtest-web code")

Follow ups