K9s edits are not applied when using neovim - kubernetes

When editing the yaml definition of a resource the changes are not applied in k9s.
I see that neovim is saving the changes I made to a file in /tmp but after exiting with :wq the changes are not being applied in k9s.
When I do the same thing with e.g. nano as editor, the changes are being applied immediately.
I saw this answer to a similar question that says the file in /tmp/ would need to be applied (using kubectl apply) which does work but I would like to have a similar experience to the nano case, where the changes are saved and applied immediately.

This is probably a case of Vim renaming the file during the process of writing the buffer to disk.
If so, you need to adjust :help 'backupcopy':
" in your vimrc
set backupcopy=yes

Related

Snakemake: how to realize a mechanism to copy input/output files to/from tmp folder and apply rule there

We use Slurm workload manager to submit jobs to our high performance cluster. During runtime of a job, we need to copy the input files from a network filesystem to the node's local filesystem, run our analysis there and then copy the output files back to the project directory on the network filesystem.
While the workflow management system Snakemake integrates with Slurm (by defining profiles) and allows to run each rule/step in the workflow as Slurm job, I haven't found a simple way to specify for each rule, wether a tmp folder should be used (with all the implications stated above or not.
I am very happy for simple solutions how to realise this behaviour.
I am not entirely sure if I understand correctly. I am guessing you do not want to copy the input of each rule to a certain directory, do the rule, then copy the output back to another filesystem, since that would be a lot of unnecessary files moving around. So for the first half of the answer I assume before execution you move your files to /scratch/mydir.
I believe you could use the --directory command (https://snakemake.readthedocs.io/en/stable/executing/cli.html). However I find this works poorly, since then snakemake has difficulty finding the config.yaml and samples.tsv.
The way I solve this is just by adding a working dir in front of my paths in each rule...
rule example:
input:
config["cwd"] + "{sample}.txt"
output:
config["cwd"] + "processed/{sample}.txt"
shell:
"""
touch {output}
"""
So all you then have to do is change cwd in your config.yaml.
local:
cwd: ./
slurm:
cwd: /scratch/mydir
You would then have to manually copy them back to your long-term filesystem or make a rule that would do that for you.
Now if however you do want to copy your files from filesystem A -> B, do your rule, and then move the result from B -> A, then I think you want to make use of shadow rules. I think the docs properly explain how to use that so I just give a link :).

Is it possible to use config fragments with Buildroot's .config?

I'm using Buildroot as a submodule, and I want to reuse existing in-tree defconfigs with a few modification of my own.
I'd like to store just the modified options in a config fragment, just like I can do with BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES for the Linux kernel config.
Right now I'm doing something like:
cd buildroot
make BR2_EXTERNAL="$(pwd)/../mypackage" qemu_x86_64_defconfig
echo '
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="../kernel_config_fragment"
BR2_ROOTFS_OVERLAY="../rootfs_overlay"
' >> .config
make
Is there a nicer way to avoid that echo with a config fragment, just like I'm using for the Linux kernel config fragment? I'd expect something like:
make BR2_CONFIG_FRAG=br_config_frag
where br_config_frag contains the lines:
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="../kernel_config_fragment"
BR2_ROOTFS_OVERLAY="../rootfs_overlay"
and then I'd be able to write just:
make -C buildroot BR2_CONFIG_FRAG=br_config_frag qemu_x86_64_defconfig all
Here's the full example repo.
Edit
One slight improvement is to put the "config fragment" in a separate file buildroot_config_fragment:
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="../kernel_config_fragment"
BR2_ROOTFS_OVERLAY="../rootfs_overlay"
and then cat that:
cat ../buildroot_config_fragment >> .config
First side note: your script should run make olddefconfig before make, so that any new options are set to their default value instead of being asked for interactively.
You could simplify the script a little by doing:
cat configs/qemu_x86_64_defconfig br_config_frag > .config
make olddefconfig
You can also use the script support/kconfig/merge_config.sh from the kconfig infrastructure. However, that script internally uses make alldefconfig which currently doesn't work - you need a patch for that.
If you would like to add support for BR2_CONFIG_FRAG to the Buildroot infrastructure, feel free to send a patch to the Buildroot mailing list!
I asked on the IRC, and an user who seems to be Yann E. Morin, who seems to be an active developer, said it is not possible currently.
Arnout's make alldefconfig patch is now merged in buildroot as of 26 Jul 2017
(https://github.com/buildroot/buildroot/commit/dab80981d15979eab3aea28a33694396635a52a1).
This means you can now do:
./support/kconfig/merge_config.sh configs/qemu_x86_64_defconfig fragment1.config fragment2.config
This will use qemu_x86_64_defconfig as the base and add modifications given in the listed fragment config files. The tool will also show nice warnings if you override items.

how to use backup files to create regular files in emacs

I am trying to create a file named caseexp.sml . Emacs created a backup file of this file when I was working on it at some earlier point, and now when I try to open it as caseexp.sml, emacs opens a #caseexp.sml# file and everytime I try to save it using C-x C-w, emacs saves it as another backup file with another tilde added to its name. Several attempts later, I have only managed to save it as #caseexp.sml"~~~.
How can I avoid creating these "tilde" backup files and save my file simply as caseexp.sml ?
There are a few unexpected behaviors here, so I can't be sure that this is what's going on, but usually what happens is that if files with hashes are left around, it's possible that Emacs crashed while you had unsaved changes. However, usually Emacs should prompt you to run "M-x recover-this-file" to restore changes from the unsaved-changes file (the filename with the hashes) to the actual file, so it's not clear what's going on there. Try fixing this from the command line.
You probably want to cp all the files to another location first, in order to have a backup (I'm assuming a Unix-like OS):
$ cp *caseexp* /tmp
Then delete the extra files while preserving the one with the most recent changes:
$ cp <most recent file with latest changes> caseexp.sml
$ rm \#caseexp*

How to create temporary files `.#filename` in `/tmp`, not working directory

When files are being modified in Emacs, a temporary file is created in the working directory that looks like this: .#filename. The file is deleted when the buffer is saved.
I found a few of these types of temporary files in my Git remote repositories, and I thought it might be better to nip the bud at the source instead of configuring Git to ignore them for every project.
How can we configure Emacs to create those files in the /tmp directory instead of the working directory?
The file at issue is called a lock file -- commencing with Emacs version 24.3, it can be controlled with the following setting:
(setq create-lockfiles nil)
https://stackoverflow.com/a/12974060/2112489
These files are auto-save files. The variable auto-save-file-name-transforms controls what modifications to make to the buffer's file name to generate the auto save file name. Usually, the default in file.el will suffice to put all the auto save files in the /tmp directory. It's default value is:
(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" "/tmp/\\2" t))
That /tmp comes by reading the variable temporary-file-directory. Check that value so that it points to /tmp. Then, the value constructed for auto-save-file-name-transforms (and hence for the auto save file name) will be correct.
As a more general solution, you could also make a global exclude file, which applies to all repositories locally. By default, this will be in $XDG_CONFIG_HOME/git/ignore (usually ~/.config/git/ignore). The path can be overridden using the core.excludesFile option. See the gitignore manpage for more details.
$ mkdir -p ~/.config/git
$ echo '.#*' >> ~/.config/git/ignore

Update ClearCase view config spec with command line with changed load rules

I have a base ClearCase snapshot view that being updated automatically overnight based on config spec file using this command
cleartool setcs -overwrite -ptime d:\CS.cs
The problem is that the config spec load rules are being changed and if I run the command it ask for confirmation to update load rules
R:\>cleartool setcs -overwrite -ptime d:\CS.cs
cleartool: Warning: 1 objects were eliminated from the new config spec's load rules:
"\QA\QTP"
Continue, and unload these objects? [no]
So is there a way to tell ClearCase using command line to automatically continue with the update without getting confirmation ?
As mentioned in "Batch Script to Automate a DOS Program with Options", you could write the right answer in a file, and redirect it to your command.
cleartool setcs -overwrite -ptime d:\CS.cs < yes.txt
That way, if the command stops for getting an input, it will have it immediately.
You find a similar approach in "how to userinput without typing to a batch file".
You should use the "-force" option