Blog

  • KeyMapper

    GitHub release fdroid release


    Get it on Google Play Get it on F-Droid
    Buy Me a Coffee at ko-fi.com Donate using Liberapay Donate using Stripe

    Unleash your keys!

    Make custom macros on your keyboard or gamepad, make on-screen buttons in any app, and unlock new functionality from your volume buttons!

    Key Mapper supports a huge variety of buttons and keys:

    • ALL your phone buttons (volume AND side key)
    • Game controllers (D-pad, ABXY, and most others)
    • Keyboards
    • Headsets and headphones
    • Fingerprint sensor

    Most devices are already supported, with new devices being added over time. Let us know if it’s not working for you and we can prioritize your device.

    Not currently supported:

    • Mouse buttons
    • Joysticks and triggers (LT,RT) on gamepads

    Not enough keys? Design your own on-screen button layouts and remap those just like real keys!

    What shortcuts can I make?

    With over 100 individual actions, the sky is the limit.

    Build complex macros with screen taps and gestures, keyboard inputs, open apps, control media, and even send intents directly to other apps.

    How much control do I have?

    TRIGGERS: You decide how to trigger a key map. Long press, double press, press as many times as you like! Combine keys on different devices, and even include your on-screen buttons.

    ACTIONS: Design specific macros for what you want to do. Combine over 100 actions, and choose the delay between each one. Set repeating actions to automate and speed up slow tasks.

    CONSTRAINTS: You choose when key maps should run and when they shouldn’t. Only need it in one specific app? Or when media is playing? On your lockscreen? Constrain your key maps for maximum control.

    Links

    Come say hi in our Discord community!

    Read the documentation!

    Translations

    cs proofreading es-ES proofreading pl proofreading pt-BR proofreading ru proofreading sk proofreading zh-CN proofreading

    Star History

    Star History Chart

    Contributing

    There are many ways to help with this project. 😃 Check out the contributing guide in the documentation.

    Visit original content creator repository https://github.com/keymapperorg/KeyMapper
  • KeyMapper

    GitHub release fdroid release


    Get it on Google Play Get it on F-Droid
    Buy Me a Coffee at ko-fi.com Donate using Liberapay Donate using Stripe

    Unleash your keys!

    Make custom macros on your keyboard or gamepad, make on-screen buttons in any app, and unlock new functionality from your volume buttons!

    Key Mapper supports a huge variety of buttons and keys:

    • ALL your phone buttons (volume AND side key)
    • Game controllers (D-pad, ABXY, and most others)
    • Keyboards
    • Headsets and headphones
    • Fingerprint sensor

    Most devices are already supported, with new devices being added over time. Let us know if it’s not working for you and we can prioritize your device.

    Not currently supported:

    • Mouse buttons
    • Joysticks and triggers (LT,RT) on gamepads

    Not enough keys? Design your own on-screen button layouts and remap those just like real keys!

    What shortcuts can I make?

    With over 100 individual actions, the sky is the limit.

    Build complex macros with screen taps and gestures, keyboard inputs, open apps, control media, and even send intents directly to other apps.

    How much control do I have?

    TRIGGERS: You decide how to trigger a key map. Long press, double press, press as many times as you like! Combine keys on different devices, and even include your on-screen buttons.

    ACTIONS: Design specific macros for what you want to do. Combine over 100 actions, and choose the delay between each one. Set repeating actions to automate and speed up slow tasks.

    CONSTRAINTS: You choose when key maps should run and when they shouldn’t. Only need it in one specific app? Or when media is playing? On your lockscreen? Constrain your key maps for maximum control.

    Links

    Come say hi in our Discord community!

    Read the documentation!

    Translations

    cs proofreading es-ES proofreading pl proofreading pt-BR proofreading ru proofreading sk proofreading zh-CN proofreading

    Star History

    Star History Chart

    Contributing

    There are many ways to help with this project. 😃 Check out the contributing guide in the documentation.

    Visit original content creator repository https://github.com/keymapperorg/KeyMapper
  • puppet-nfs

    puppet-nfs

    Build Status Release Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores puppetmodule.info docs Apache-2.0 License Donated by Daniel Klockenkaemper

    Table of Contents

    1. Module Description – What the module does and why it is useful
    2. Setup – The basics of getting started with puppet-nfs
    3. Usage – Configuration options and additional functionality
    4. Reference – An under-the-hood peek at what the module is doing and how
    5. Limitations – OS compatibility, etc.
    6. Development – Guide for contributing to the module

    Module Description

    Github Master: Test Suite

    This module installs, configures and manages everything on NFS clients and servers.

    This module is a complete refactor of the module haraldsk/nfs, because Harald Skoglund sadly is not maintaining his module actively anymore. It is stripped down to use only the class ‘nfs’ and parametrized to act as a server, client or both with the parameters ‘server_enabled’ and ‘client_enabled’. It also has some dependencies on newer stdlib functions like ‘difference’.

    It supports the OS Families Ubuntu, Debian, Redhat, SUSE, Gentoo and Archlinux. It supports also Strict Variables, so if you pass all OS specific parameters correctly it should work on your preferred OS too. Feedback, bugreports, and feature requests are always welcome, visit https://github.com/voxpupuli/puppet-nfs or send me an email.

    When you are using a puppet version 3.x like it is shipped with Redhat Satellite 6, please use a version 1.x.x from puppet forge or the branch puppet3 when cloning directly from Github. (Note: #49 (comment)). I’ll recommend using puppet >= 4.6.1, puppet versions up until 4.6.0 had various issues.

    If you want to contribute, please do a fork on github, create a branch “feature name” with your features and do a pull request.

    Warning: I’ve introduced new dependencies with version 2.1.0 which were needed to fix buggy rpcbind-socket restarting with systemd:

    • puppetlabs/transition
    • herculesteam/augeasproviders_core
    • herculesteam/augeasproviders_shellvar

    Setup

    What puppet-nfs affects

    This module can be used to configure your nfs client and/or server, it could export nfs mount resources via storeconfigs or simply mount nfs shares on a client. You can also easily use the create_resources function when you store your exports i.e. via hiera.

    Setup requirements

    This Module depends on puppetlabs-stdlib >= 4.5.0 and puppetlabs-concat >= 1.1.2, you need to have these modules installed to use puppet-nfs module.

    Beginning with puppet-nfs

    On a nfs server the following code is sufficient to get all packages installed and services running to use nfs:

      node server {
        class { '::nfs':
          server_enabled => true,
        }
      }

    On a client the following code is sufficient:

      node server {
        class { '::nfs':
          client_enabled => true,
        }
      }

    Usage

    Simple NFSv3 server and client example

    This will export /data_folder on the server and automagically mount it on client.

      node server {
        class { '::nfs':
          server_enabled => true
        }
        nfs::server::export{ '/data_folder':
          ensure  => 'mounted',
          clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)'
        }
      }
    
      # By default, mounts are mounted in the same folder on the clients as
      # they were exported from on the server
      node client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| |>>
      }

    Simple NFSv4 client example

    This will mount /data on client in /share/data.

      node client {
        class { '::nfs':
          server_enabled => false,
          client_enabled => true,
          nfs_v4_client => true,
          nfs_v4_idmap_domain => $::domain,
        }
    
        nfs::client::mount { '/share/data':
            server => '192.168.0.1',
            share => 'data',
        }
      }

    NFSv3 multiple exports, servers and multiple node example

      node server1 {
        class { '::nfs':
          server_enabled => true,
        }
        nfs::server::export { '/data_folder':
          ensure  => 'mounted',
          clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)',
        }
        nfs::server::export { '/homeexport':
          ensure  => 'mounted',
          clients => '10.0.0.0/24(rw,insecure,async,root_squash)',
          mount   => '/srv/home',
        }
      }
    
      node server2 {
        class { '::nfs':
          server_enabled => true,
        }
        # ensure is passed to mount, which will make the client not mount it
        # the directory automatically, just add it to fstab
        nfs::server::export { '/media_library':
          ensure  => 'present',
          nfstag     => 'media',
          clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)',
        }
      }
    
      node client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| |>>
      }
    
      # Using a storeconfig override, to change ensure option, so we mount
      # all shares
      node greedy_client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| |>> {
          ensure => 'mounted',
        }
      }
    
    
      # only the mount tagged as media
      # also override mount point
      node media_client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| nfstag == 'media' |>> {
          ensure => 'mounted',
          mount  => '/import/media',
        }
      }
    
      # All @@nfs::server::mount storeconfigs can be filtered by parameters
      # Also all parameters can be overridden (not that it's smart to do
      # so).
      # Check out the doc on exported resources for more info:
      # http://docs.puppetlabs.com/guides/exported_resources.html
      node single_server_client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| server == 'server1' |>> {
          ensure => 'absent',
        }
      }

    NFSv4 Simple example

      # We use the $::domain fact for the Domain setting in
      # /etc/idmapd.conf.
      # For NFSv4 to work this has to be equal on servers and clients
      # set it manually if unsure.
      #
      # All nfsv4 exports are bind mounted into /export/$mount_name
      # and mounted on /srv/$mount_name on the client.
      # Both values can be overridden through parameters both globally
    
      # and on individual nodes.
      node server {
        file { ['/data_folder', '/homeexport']:
          ensure => 'directory',
        }
        class { '::nfs':
          server_enabled => true,
          nfs_v4 => true,
          nfs_v4_idmap_domain => 'example.com',
          nfs_v4_export_root  => '/export',
          nfs_v4_export_root_clients => '*(rw,fsid=0,insecure,no_subtree_check,async,no_root_squash)',
        }
        nfs::server::export { '/data_folder':
          ensure  => 'mounted',
          clients => '*(rw,insecure,async,no_root_squash,no_subtree_check)',
        }
        nfs::server::export { '/homeexport':
          ensure  => 'mounted',
          clients => '*(rw,insecure,async,root_squash,no_subtree_check)',
          mount   => '/srv/home',
        }
      }
    
      # By default, mounts are mounted in the same folder on the clients as
      # they were exported from on the server
    
      node client {
        class { '::nfs':
          client_enabled  => true,
          nfs_v4_client   => true,
        }
        Nfs::Client::Mount <<| |>>
      }
    
      # We can also mount the NFSv4 Root directly through nfs::client::mount::nfsv4::root.
      # By default /srv will be used for as mount point, but can be overriden through
      # the 'mounted' option.
    
      node client2 {
        $server = 'server'
        class { '::nfs':
          client_enabled => true,
          nfs_v4_client  => true,
        }
        Nfs::Client::Mount::Nfs_v4::Root <<| server == $server |>> {
          mount => "/srv/${server}",
        }
      }

    NFSv4 insanely overcomplicated reference example

      # and on individual nodes.
      node server {
        class { '::nfs':
          server_enabled      => true,
          nfs_v4              => true,
          # Below are defaults
          nfs_v4_idmap_domain => $::domain,
          nfs_v4_export_root  => '/export',
          # Default access settings of /export root
          nfs_v4_export_root_clients =>
            "*.${::domain}(ro,fsid=root,insecure,no_subtree_check,async,root_squash)",
    
    
        }
        nfs::server::export { '/data_folder':
          # These are the defaults
          ensure  => 'mounted',
          # rbind or bind mounting of folders bindmounted into /export
          # google it
          bind    => 'rbind',
          # everything below here is propogated by to storeconfigs
          # to clients
          #
          # Directory where we want export mounted on client
          mount     => undef,
          remounts  => false,
          atboot    => false,
          #  Don't remove that option, but feel free to add more.
          options_nfs   => '_netdev',
          # If set will mount share inside /srv (or overridden mount_root)
          # and then bindmount to another directory elsewhere in the fs -
          # for fanatics.
          bindmount => undef,
          # Used to identify a catalog item for filtering by by
          # storeconfigs, kick ass.
          nfstag     => 'kick-ass',
          # copied directly into /etc/exports as a string, for simplicity
          clients => '10.0.0.0/24(rw,insecure,no_subtree_check,async,no_root_squash)',
        }
      }
    
      node client {
        class { '::nfs':
          client_enabled      => true,
          nfs_v4_client       => true,
          nfs_v4_idmap_domain => $::domain,
          nfs_v4_mount_root   => '/srv',
        }
    
        # We can as you by now know, override options set on the server
        # on the client node.
        # Be careful. Don't override mount points unless you are sure
        # that only one export will match your filter!
    
        Nfs::Client::Mount <<| nfstag == 'kick-ass' |>> {
          # Directory where we want export mounted on client
          mount       => undef,
          remounts    => false,
          atboot      => false,
          #  Don't remove that option, but feel free to add more.
          options_nfs => '_netdev',
          # If set will mount share inside /srv (or overridden mount_root)
          # and then bindmount to another directory elsewhere in the fs -
          # for fanatics.
          bindmount   => undef,
        }
      }

    Simple create nfs export resources with hiera example

    Hiera Server Role:

      classes:
        - nfs
    
      nfs::server_enabled: true
      nfs::client_enabled: false
      nfs::nfs_v4: true
      nfs::nfs_v4_idmap_domain: %{::domain}
      nfs::nfs_v4_export_root: '/share'
      nfs::nfs_v4_export_root_clients: '192.168.0.0/24(rw,fsid=root,insecure,no_subtree_check,async,no_root_squash)'
    
    
      nfs::nfs_exports_global:
        /var/www: {}
        /var/smb: {}

    Hiera Client Role:

      classes:
        - nfs
    
      nfs::client_enabled: true
      nfs::nfs_v4_client: true
      nfs::nfs_v4_idmap_domain: %{::domain}
      nfs::nfs_v4_mount_root: '/share'
      nfs::nfs_server: 'nfs-server-fqdn'
    

    Puppet:

      node server {
        hiera_include('classes')
        $nfs_exports_global = hiera_hash('nfs::nfs_exports_global', false)
    
        $defaults_nfs_exports = {
          ensure  => 'mounted',
          clients => '192.168.0.0/24(rw,insecure,no_subtree_check,async,no_root_squash)',
          nfstag     => $::fqdn,
        }
    
        if $nfs_exports_global {
          create_resources('::nfs::server::export', $nfs_exports_global, $defaults_nfs_exports)
        }
      }
    
      node client {
        hiera_include('classes')
        $nfs_server = hiera('nfs::nfs_server', false)
    
        if $nfs_server {
          Nfs::Client::Mount <<| nfstag == $nfs_server |>>
        }
      }

    Reference

    Classes

    Public Classes

    • nfs: Main class, includes all other classes

    Public Defines

    Private Classes

    • nfs::client: Includes all relevant classes for configuring as a client.

    • nfs::client::config: Handles the configuration files.

    • nfs::client::package: Handles the packages.

    • nfs::client::service: Handles the services.

    • nfs::server: Includes all relevant classes for configuring as a server.

    • nfs::server::config: Handles the configuration files.

    • nfs::server::package: Handles the packages.

    • nfs::server::service: Handles the services.

    • nfs::params: Includes all os specific parameters.

    Private Defines

    • nfs::bindmount: Creates the bindmounts of nfs 3 exports.
    • nfs::nfsv4_bindmount: Creates the bindmounts of nfs 4 exports.
    • nfs::create_export: Creates the nfs exports.
    • nfs::mkdir: Creates directories recursive.

    Parameters

    Class: ::nfs

    The following parameters are available in the ::nfs class:

    ensure

    String. Controls if the managed resources shall be present or absent. If set to absent:

    • The managed software packages are being uninstalled.
    • Any traces of the packages will be purged as good as possible. This may include existing configuration files. The exact behavior is provider dependent. Q.v.:
    • System modifications (if any) will be reverted as good as possible (e.g. removal of created users, services, changed log settings, …).
    • This is thus destructive and should be used with care. Defaults to present.
    server_enabled

    Boolean. If set to true, this module will configure the node to act as a nfs server.

    client_enabled

    Boolean. If set to true, this module will configure the node to act as a nfs client, you can use the exported mount resources from configured servers.

    storeconfigs_enabled

    Boolean. If set to false, this module will not export any resources as storeconfigs. Defaults to true.

    nfs_v4

    Boolean. If set to true, this module will use nfs version 4 for exporting and mounting nfs resources. It defaults to true.

    nfs_v4_client

    Boolean. If set to true, this module will use nfs version 4 for mounting nfs resources. If set to false it will use nfs version 3 to mount nfs resources. It defaults to true.

    exports_file

    String. It defines the location of the file with the nfs export resources used by the nfs server.

    idmapd_file

    String. It defines the location of the file with the idmapd settings.

    defaults_file

    String. It defines the location of the file with the nfs settings.

    manage_packages

    Boolean. It defines if the packages should be managed through this module

    server_packages

    Array. It defines the packages needed to be installed for acting as a nfs server

    server_package_ensure

    String. It defines the packages state – any of present, installed, absent, purged, held, latest

    client_packages

    Array. It defines the packages needed to be installed for acting as a nfs client

    client_package_ensure

    String. It defines the packages state – any of present, installed, absent, purged, held, latest

    manage_server_service

    Boolean. Defines if module should manage server_service

    manage_server_servicehelper

    Boolean. Defines if module should manage server_servicehelper

    manage_client_service

    Boolean. Defines if module should manage client_service

    server_service_name

    String. It defines the servicename of the nfs server service

    server_service_ensure

    Boolean. It defines the service parameter ensure for nfs server services.

    server_service_enable

    Boolean. It defines the service parameter enable for nfs server service.

    server_service_hasrestart

    Boolean. It defines the service parameter hasrestart for nfs server service.

    server_service_hasstatus

    Boolean. It defines the service parameter hasstatus for nfs server service.

    server_service_restart_cmd

    String. It defines the service parameter restart for nfs server service.

    server_nfsv4_servicehelper

    Array. It defines the service helper like idmapd for servers configured with nfs version 4.

    client_services

    Nested Hash. It defines the servicenames need to be started when acting as a nfs client

    client_nfsv4_services

    Nested Hash. It defines the servicenames need to be started when acting as a nfs client version 4.

    client_service_hasrestart

    Boolean. It defines the service parameter hasrestart for nfs client services.

    client_service_hasstatus

    Boolean. It defines the service parameter hasstatus for nfs client services.

    client_idmapd_setting

    Array. It defines the Augeas parameter added in defaults_file when acting as a nfs version 4 client.

    client_nfs_fstype

    String. It defines the name of the nfs filesystem, when adding entries to /etc/fstab on a client node.

    client_nfs_options

    String. It defines the options for the nfs filesystem, when adding entries to /etc/fstab on a client node.

    client_nfsv4_fstype

    String. It defines the name of the nfs version 4 filesystem, when adding entries to /etc/fstab on a client node.

    client_nfsv4_options

    String. It defines the options for the nfs version 4filesystem, when adding entries to /etc/fstab on a client node.

    nfs_v4_export_root

    String. It defines the location where nfs version 4 exports should be bindmounted to on a server node. Defaults to /export.

    nfs_v4_export_root_clients

    String. It defines the clients that are allowed to mount nfs version 4 exports and includes the option string. Defaults to *.${::domain}(ro,fsid=root,insecure,no_subtree_check,async,root_squash).

    nfs_v4_mount_root

    String. It defines the location where nfs version 4 clients find the mount root on a server node. Defaults to /srv.

    nfs_v4_idmap_domain

    String. It defines the name of the idmapd domain setting in idmapd_file needed to be set to the same value on a server and client node to do correct uid and gid mapping. Defaults to $::domain.

    nfsv4_bindmount_enable

    Boolean. It defines if the module should create a bindmount for the export. Defaults to true.

    client_need_gssd

    Boolean. If true, sets NEED_GSSD=yes in /etc/defauls/nfs-common, usable on Debian/Ubuntu

    client_gssd_service

    Boolean. If true enable rpc-gssd service.

    client_gssd_options

    String. Options for rpc-gssd service. Defaults to ''

    client_d9_gssdopt_workaround

    Boolean. If enabled, workaround for passing gssd_options which is broken on Debian 9. Usable only on Debian 9

    nfs_v4_idmap_localrealms

    String or Array. ‘Local-Realms’ option for idmapd. Defaults to ''

    nfs_v4_idmap_cache

    Integer. ‘Cache-Expiration’ option for idmapd. Defaults to 0 – unused.

    manage_nfs_v4_idmap_nobody_mapping

    Boolean. Enable setting Nobody mapping in idmapd. Defaults to false.

    nfs_v4_idmap_nobody_user

    String. ‘Nobody-User’ option for idmapd. Defaults to nobody.

    nfs_v4_idmap_nobody_group

    String. ‘Nobody-Group’ option for idmapd. Defaults to nobody or nogroup.

    client_rpcbind_config

    String. It defines the location of the file with the rpcbind config.

    client_rpcbind_optname

    String. It defines the name of env variable that holds the rpcbind config. E.g. OPTIONS for Debian

    client_rpcbind_opts

    String. Options for rpcbind service.

    Define: ::nfs::client::mount

    The following parameters are available in the ::nfs::client::mount define:

    server

    String. Sets the ip address of the server with the nfs export

    share

    String. Sets the name of the nfs share on the server

    ensure

    String. Sets the ensure parameter of the mount.

    remounts

    String. Sets the remounts parameter of the mount.

    atboot

    String. Sets the atboot parameter of the mount.

    options_nfsv4

    String. Sets the mount options for a nfs version 4 mount.

    options_nfs

    String. Sets the mount options for a nfs mount.

    bindmount

    String. When not undef it will create a bindmount on the node for the nfs mount.

    nfstag

    String. Sets the nfstag parameter of the mount.

    nfs_v4

    Boolean. When set to true, it uses nfs version 4 to mount a share.

    owner

    String. Set owner of mount dir

    group

    String. Set group of mount dir

    mode

    String. Set mode of mount dir

    mount_root

    String. Overwrite mount root if differs from server config

    Define: ::nfs::server::export

    The following parameters are available in the ::nfs::server::export define:

    clients

    String. Sets the allowed clients and options for the export in the exports file. Defaults to localhost(ro)

    bind

    String. Sets the bind options setted in /etc/fstab for the bindmounts created. Defaults to rbind. When you have any submounts in your exported folders, the rbind option will submount them in the bindmount folder. You have to set the  crossmnt option in your nfs export to have the submounts from rbind available on your client. Your export should look like this:

    node client {
      nfs::server::export { '/home':
        ensure  => 'mounted',
        clients => '*(rw,insecure,no_subtree_check,async,no_root_squash,crossmnt)',
      }
    }
    ensure

    String. If enabled the mount will be created. Defaults to mounted

    remounts

    String. Sets the remounts parameter of the mount.

    atboot

    String. Sets the atboot parameter of the mount.

    options_nfsv4

    String. Sets the mount options for a nfs version 4 exported resource mount.

    options_nfs

    String. Sets the mount options for a nfs exported resource mount.

    bindmount

    String. When not undef it will create a bindmount on the node for the nfs mount.

    nfstag

    String. Sets the nfstag parameter of the mount.

    mount

    String. Sets the mountpoint the client will mount the exported resource mount on. If undef it defaults to the same path as on the server

    owner

    String. Sets the owner of the exported directory

    group

    String. Sets the group of the exported directory

    mode

    String. Sets the permissions of the exported directory.

    Requirements

    Modules needed:

    puppetlabs/stdlib >= 4.5.0 puppetlabs/concat >= 1.1.2

    Software versions needed:

    facter > 1.6.2 puppet > 3.2.0

    Ruby Gems needed:

    augeas

    Limitations

    If you want to have specific package versions installed you may manage the needed packages outside of this module (use manage_packages => false). It is only tested to use ‘present’, ‘installed’, ‘absent’, ‘purged’, ‘held’ and ‘latest’ as argument for the parameters server_package_ensure and client_package_ensure.

    Development

    Derdanne modules are open projects. So if you want to make this module even better, you can contribute to this module on Github.

    Before pushing PRs to Github i would recommend you to test your work locally. So you can ensure all test builds on Travis CI were passing. I have prepared an easy way to test your code locally with the help of Docker.

    For running the complete static code analysis, it is sufficient to run a make test-all.

    Default settings

    I have set some defaults which you can change by setting the following environment variables.

    PUPPET_VERSION

    Changes the puppet version which will be used for the tests. Defaults to 6.0.

    STRICT_VARIABLES

    Sets strict variables on or off. Defaults to yes.

    RVM

    Sets the ruby version which will be used for the tests. Defaults to 2.4.1.

    BEAKER_set

    Sets the beaker docker target host. Defaults to ubuntu-20.04.

    PUPPET_collection

    Sets the puppet version for acceptance tests. Defaults to puppet6.

    Running tests

    You can run the following commands to setup and run the testsuite on your local machine.

    make build

    Build a docker image with a Ruby version which is not available on Docker hub. Check out https://hub.docker.com/r/derdanne/rvm/ to see if i have already prepared a rvm build for the ruby version you want to test. Take a look at the Dockerfile located in spec/local-testing if you want to customize your builds.

    make pull

    Pull a prebuild rvm docker image with the Ruby version defined in the variable RVM.

    make install-gems

    Install all needed gems locally to vendor/bundle.

    make test-metadata-lint

    Run linting of metadata.

    make test-lint

    Run puppet lint tests.

    make test-syntax

    Run syntax tests.

    make test-rspec

    Run rspec puppet tests.

    make test-rubocop

    Run rubocop tests.

    make test-all

    Run the whole testsuite.

    make test-beaker

    Run puppetlabs beaker rspec tests.

    Disclaimer

    This module based on Harald Skoglund haraldsk@redpill-linpro.com from https://github.com/haraldsk/puppet-module-nfs/ but has been fundementally refactored

    Transfer Notice

    This plugin was originally authored by Daniel Klockenkaemper dk@marketing-factory.de. The maintainer preferred that Vox Pupuli take ownership of the module for future improvement and maintenance. Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.

    Previously: https://github.com/derdanne/puppet-nfs

    Visit original content creator repository https://github.com/voxpupuli/puppet-nfs
  • puppet-nfs

    puppet-nfs

    Build Status Release Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores puppetmodule.info docs Apache-2.0 License Donated by Daniel Klockenkaemper

    Table of Contents

    1. Module Description – What the module does and why it is useful
    2. Setup – The basics of getting started with puppet-nfs
    3. Usage – Configuration options and additional functionality
    4. Reference – An under-the-hood peek at what the module is doing and how
    5. Limitations – OS compatibility, etc.
    6. Development – Guide for contributing to the module

    Module Description

    Github Master: Test Suite

    This module installs, configures and manages everything on NFS clients and servers.

    This module is a complete refactor of the module haraldsk/nfs, because Harald Skoglund sadly is not maintaining his module actively anymore. It is stripped down to use only the class ‘nfs’ and parametrized to act as a server, client or both with the parameters ‘server_enabled’ and ‘client_enabled’. It also has some dependencies on newer stdlib functions like ‘difference’.

    It supports the OS Families Ubuntu, Debian, Redhat, SUSE, Gentoo and Archlinux. It supports also Strict Variables, so if you pass all OS specific parameters correctly it should work on your preferred OS too. Feedback, bugreports, and feature requests are always welcome, visit https://github.com/voxpupuli/puppet-nfs or send me an email.

    When you are using a puppet version 3.x like it is shipped with Redhat Satellite 6, please use a version 1.x.x from puppet forge or the branch puppet3 when cloning directly from Github. (Note: #49 (comment)). I’ll recommend using puppet >= 4.6.1, puppet versions up until 4.6.0 had various issues.

    If you want to contribute, please do a fork on github, create a branch “feature name” with your features and do a pull request.

    Warning: I’ve introduced new dependencies with version 2.1.0 which were needed to fix buggy rpcbind-socket restarting with systemd:

    • puppetlabs/transition
    • herculesteam/augeasproviders_core
    • herculesteam/augeasproviders_shellvar

    Setup

    What puppet-nfs affects

    This module can be used to configure your nfs client and/or server, it could export nfs mount resources via storeconfigs or simply mount nfs shares on a client. You can also easily use the create_resources function when you store your exports i.e. via hiera.

    Setup requirements

    This Module depends on puppetlabs-stdlib >= 4.5.0 and puppetlabs-concat >= 1.1.2, you need to have these modules installed to use puppet-nfs module.

    Beginning with puppet-nfs

    On a nfs server the following code is sufficient to get all packages installed and services running to use nfs:

      node server {
        class { '::nfs':
          server_enabled => true,
        }
      }

    On a client the following code is sufficient:

      node server {
        class { '::nfs':
          client_enabled => true,
        }
      }

    Usage

    Simple NFSv3 server and client example

    This will export /data_folder on the server and automagically mount it on client.

      node server {
        class { '::nfs':
          server_enabled => true
        }
        nfs::server::export{ '/data_folder':
          ensure  => 'mounted',
          clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)'
        }
      }
    
      # By default, mounts are mounted in the same folder on the clients as
      # they were exported from on the server
      node client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| |>>
      }

    Simple NFSv4 client example

    This will mount /data on client in /share/data.

      node client {
        class { '::nfs':
          server_enabled => false,
          client_enabled => true,
          nfs_v4_client => true,
          nfs_v4_idmap_domain => $::domain,
        }
    
        nfs::client::mount { '/share/data':
            server => '192.168.0.1',
            share => 'data',
        }
      }

    NFSv3 multiple exports, servers and multiple node example

      node server1 {
        class { '::nfs':
          server_enabled => true,
        }
        nfs::server::export { '/data_folder':
          ensure  => 'mounted',
          clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)',
        }
        nfs::server::export { '/homeexport':
          ensure  => 'mounted',
          clients => '10.0.0.0/24(rw,insecure,async,root_squash)',
          mount   => '/srv/home',
        }
      }
    
      node server2 {
        class { '::nfs':
          server_enabled => true,
        }
        # ensure is passed to mount, which will make the client not mount it
        # the directory automatically, just add it to fstab
        nfs::server::export { '/media_library':
          ensure  => 'present',
          nfstag     => 'media',
          clients => '10.0.0.0/24(rw,insecure,async,no_root_squash) localhost(rw)',
        }
      }
    
      node client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| |>>
      }
    
      # Using a storeconfig override, to change ensure option, so we mount
      # all shares
      node greedy_client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| |>> {
          ensure => 'mounted',
        }
      }
    
    
      # only the mount tagged as media
      # also override mount point
      node media_client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| nfstag == 'media' |>> {
          ensure => 'mounted',
          mount  => '/import/media',
        }
      }
    
      # All @@nfs::server::mount storeconfigs can be filtered by parameters
      # Also all parameters can be overridden (not that it's smart to do
      # so).
      # Check out the doc on exported resources for more info:
      # http://docs.puppetlabs.com/guides/exported_resources.html
      node single_server_client {
        class { '::nfs':
          client_enabled => true,
        }
        Nfs::Client::Mount <<| server == 'server1' |>> {
          ensure => 'absent',
        }
      }

    NFSv4 Simple example

      # We use the $::domain fact for the Domain setting in
      # /etc/idmapd.conf.
      # For NFSv4 to work this has to be equal on servers and clients
      # set it manually if unsure.
      #
      # All nfsv4 exports are bind mounted into /export/$mount_name
      # and mounted on /srv/$mount_name on the client.
      # Both values can be overridden through parameters both globally
    
      # and on individual nodes.
      node server {
        file { ['/data_folder', '/homeexport']:
          ensure => 'directory',
        }
        class { '::nfs':
          server_enabled => true,
          nfs_v4 => true,
          nfs_v4_idmap_domain => 'example.com',
          nfs_v4_export_root  => '/export',
          nfs_v4_export_root_clients => '*(rw,fsid=0,insecure,no_subtree_check,async,no_root_squash)',
        }
        nfs::server::export { '/data_folder':
          ensure  => 'mounted',
          clients => '*(rw,insecure,async,no_root_squash,no_subtree_check)',
        }
        nfs::server::export { '/homeexport':
          ensure  => 'mounted',
          clients => '*(rw,insecure,async,root_squash,no_subtree_check)',
          mount   => '/srv/home',
        }
      }
    
      # By default, mounts are mounted in the same folder on the clients as
      # they were exported from on the server
    
      node client {
        class { '::nfs':
          client_enabled  => true,
          nfs_v4_client   => true,
        }
        Nfs::Client::Mount <<| |>>
      }
    
      # We can also mount the NFSv4 Root directly through nfs::client::mount::nfsv4::root.
      # By default /srv will be used for as mount point, but can be overriden through
      # the 'mounted' option.
    
      node client2 {
        $server = 'server'
        class { '::nfs':
          client_enabled => true,
          nfs_v4_client  => true,
        }
        Nfs::Client::Mount::Nfs_v4::Root <<| server == $server |>> {
          mount => "/srv/${server}",
        }
      }

    NFSv4 insanely overcomplicated reference example

      # and on individual nodes.
      node server {
        class { '::nfs':
          server_enabled      => true,
          nfs_v4              => true,
          # Below are defaults
          nfs_v4_idmap_domain => $::domain,
          nfs_v4_export_root  => '/export',
          # Default access settings of /export root
          nfs_v4_export_root_clients =>
            "*.${::domain}(ro,fsid=root,insecure,no_subtree_check,async,root_squash)",
    
    
        }
        nfs::server::export { '/data_folder':
          # These are the defaults
          ensure  => 'mounted',
          # rbind or bind mounting of folders bindmounted into /export
          # google it
          bind    => 'rbind',
          # everything below here is propogated by to storeconfigs
          # to clients
          #
          # Directory where we want export mounted on client
          mount     => undef,
          remounts  => false,
          atboot    => false,
          #  Don't remove that option, but feel free to add more.
          options_nfs   => '_netdev',
          # If set will mount share inside /srv (or overridden mount_root)
          # and then bindmount to another directory elsewhere in the fs -
          # for fanatics.
          bindmount => undef,
          # Used to identify a catalog item for filtering by by
          # storeconfigs, kick ass.
          nfstag     => 'kick-ass',
          # copied directly into /etc/exports as a string, for simplicity
          clients => '10.0.0.0/24(rw,insecure,no_subtree_check,async,no_root_squash)',
        }
      }
    
      node client {
        class { '::nfs':
          client_enabled      => true,
          nfs_v4_client       => true,
          nfs_v4_idmap_domain => $::domain,
          nfs_v4_mount_root   => '/srv',
        }
    
        # We can as you by now know, override options set on the server
        # on the client node.
        # Be careful. Don't override mount points unless you are sure
        # that only one export will match your filter!
    
        Nfs::Client::Mount <<| nfstag == 'kick-ass' |>> {
          # Directory where we want export mounted on client
          mount       => undef,
          remounts    => false,
          atboot      => false,
          #  Don't remove that option, but feel free to add more.
          options_nfs => '_netdev',
          # If set will mount share inside /srv (or overridden mount_root)
          # and then bindmount to another directory elsewhere in the fs -
          # for fanatics.
          bindmount   => undef,
        }
      }

    Simple create nfs export resources with hiera example

    Hiera Server Role:

      classes:
        - nfs
    
      nfs::server_enabled: true
      nfs::client_enabled: false
      nfs::nfs_v4: true
      nfs::nfs_v4_idmap_domain: %{::domain}
      nfs::nfs_v4_export_root: '/share'
      nfs::nfs_v4_export_root_clients: '192.168.0.0/24(rw,fsid=root,insecure,no_subtree_check,async,no_root_squash)'
    
    
      nfs::nfs_exports_global:
        /var/www: {}
        /var/smb: {}

    Hiera Client Role:

      classes:
        - nfs
    
      nfs::client_enabled: true
      nfs::nfs_v4_client: true
      nfs::nfs_v4_idmap_domain: %{::domain}
      nfs::nfs_v4_mount_root: '/share'
      nfs::nfs_server: 'nfs-server-fqdn'
    

    Puppet:

      node server {
        hiera_include('classes')
        $nfs_exports_global = hiera_hash('nfs::nfs_exports_global', false)
    
        $defaults_nfs_exports = {
          ensure  => 'mounted',
          clients => '192.168.0.0/24(rw,insecure,no_subtree_check,async,no_root_squash)',
          nfstag     => $::fqdn,
        }
    
        if $nfs_exports_global {
          create_resources('::nfs::server::export', $nfs_exports_global, $defaults_nfs_exports)
        }
      }
    
      node client {
        hiera_include('classes')
        $nfs_server = hiera('nfs::nfs_server', false)
    
        if $nfs_server {
          Nfs::Client::Mount <<| nfstag == $nfs_server |>>
        }
      }

    Reference

    Classes

    Public Classes

    • nfs: Main class, includes all other classes

    Public Defines

    Private Classes

    • nfs::client: Includes all relevant classes for configuring as a client.

    • nfs::client::config: Handles the configuration files.

    • nfs::client::package: Handles the packages.

    • nfs::client::service: Handles the services.

    • nfs::server: Includes all relevant classes for configuring as a server.

    • nfs::server::config: Handles the configuration files.

    • nfs::server::package: Handles the packages.

    • nfs::server::service: Handles the services.

    • nfs::params: Includes all os specific parameters.

    Private Defines

    • nfs::bindmount: Creates the bindmounts of nfs 3 exports.
    • nfs::nfsv4_bindmount: Creates the bindmounts of nfs 4 exports.
    • nfs::create_export: Creates the nfs exports.
    • nfs::mkdir: Creates directories recursive.

    Parameters

    Class: ::nfs

    The following parameters are available in the ::nfs class:

    ensure

    String. Controls if the managed resources shall be present or absent. If set to absent:

    • The managed software packages are being uninstalled.
    • Any traces of the packages will be purged as good as possible. This may include existing configuration files. The exact behavior is provider dependent. Q.v.:
    • System modifications (if any) will be reverted as good as possible (e.g. removal of created users, services, changed log settings, …).
    • This is thus destructive and should be used with care. Defaults to present.
    server_enabled

    Boolean. If set to true, this module will configure the node to act as a nfs server.

    client_enabled

    Boolean. If set to true, this module will configure the node to act as a nfs client, you can use the exported mount resources from configured servers.

    storeconfigs_enabled

    Boolean. If set to false, this module will not export any resources as storeconfigs. Defaults to true.

    nfs_v4

    Boolean. If set to true, this module will use nfs version 4 for exporting and mounting nfs resources. It defaults to true.

    nfs_v4_client

    Boolean. If set to true, this module will use nfs version 4 for mounting nfs resources. If set to false it will use nfs version 3 to mount nfs resources. It defaults to true.

    exports_file

    String. It defines the location of the file with the nfs export resources used by the nfs server.

    idmapd_file

    String. It defines the location of the file with the idmapd settings.

    defaults_file

    String. It defines the location of the file with the nfs settings.

    manage_packages

    Boolean. It defines if the packages should be managed through this module

    server_packages

    Array. It defines the packages needed to be installed for acting as a nfs server

    server_package_ensure

    String. It defines the packages state – any of present, installed, absent, purged, held, latest

    client_packages

    Array. It defines the packages needed to be installed for acting as a nfs client

    client_package_ensure

    String. It defines the packages state – any of present, installed, absent, purged, held, latest

    manage_server_service

    Boolean. Defines if module should manage server_service

    manage_server_servicehelper

    Boolean. Defines if module should manage server_servicehelper

    manage_client_service

    Boolean. Defines if module should manage client_service

    server_service_name

    String. It defines the servicename of the nfs server service

    server_service_ensure

    Boolean. It defines the service parameter ensure for nfs server services.

    server_service_enable

    Boolean. It defines the service parameter enable for nfs server service.

    server_service_hasrestart

    Boolean. It defines the service parameter hasrestart for nfs server service.

    server_service_hasstatus

    Boolean. It defines the service parameter hasstatus for nfs server service.

    server_service_restart_cmd

    String. It defines the service parameter restart for nfs server service.

    server_nfsv4_servicehelper

    Array. It defines the service helper like idmapd for servers configured with nfs version 4.

    client_services

    Nested Hash. It defines the servicenames need to be started when acting as a nfs client

    client_nfsv4_services

    Nested Hash. It defines the servicenames need to be started when acting as a nfs client version 4.

    client_service_hasrestart

    Boolean. It defines the service parameter hasrestart for nfs client services.

    client_service_hasstatus

    Boolean. It defines the service parameter hasstatus for nfs client services.

    client_idmapd_setting

    Array. It defines the Augeas parameter added in defaults_file when acting as a nfs version 4 client.

    client_nfs_fstype

    String. It defines the name of the nfs filesystem, when adding entries to /etc/fstab on a client node.

    client_nfs_options

    String. It defines the options for the nfs filesystem, when adding entries to /etc/fstab on a client node.

    client_nfsv4_fstype

    String. It defines the name of the nfs version 4 filesystem, when adding entries to /etc/fstab on a client node.

    client_nfsv4_options

    String. It defines the options for the nfs version 4filesystem, when adding entries to /etc/fstab on a client node.

    nfs_v4_export_root

    String. It defines the location where nfs version 4 exports should be bindmounted to on a server node. Defaults to /export.

    nfs_v4_export_root_clients

    String. It defines the clients that are allowed to mount nfs version 4 exports and includes the option string. Defaults to *.${::domain}(ro,fsid=root,insecure,no_subtree_check,async,root_squash).

    nfs_v4_mount_root

    String. It defines the location where nfs version 4 clients find the mount root on a server node. Defaults to /srv.

    nfs_v4_idmap_domain

    String. It defines the name of the idmapd domain setting in idmapd_file needed to be set to the same value on a server and client node to do correct uid and gid mapping. Defaults to $::domain.

    nfsv4_bindmount_enable

    Boolean. It defines if the module should create a bindmount for the export. Defaults to true.

    client_need_gssd

    Boolean. If true, sets NEED_GSSD=yes in /etc/defauls/nfs-common, usable on Debian/Ubuntu

    client_gssd_service

    Boolean. If true enable rpc-gssd service.

    client_gssd_options

    String. Options for rpc-gssd service. Defaults to ''

    client_d9_gssdopt_workaround

    Boolean. If enabled, workaround for passing gssd_options which is broken on Debian 9. Usable only on Debian 9

    nfs_v4_idmap_localrealms

    String or Array. ‘Local-Realms’ option for idmapd. Defaults to ''

    nfs_v4_idmap_cache

    Integer. ‘Cache-Expiration’ option for idmapd. Defaults to 0 – unused.

    manage_nfs_v4_idmap_nobody_mapping

    Boolean. Enable setting Nobody mapping in idmapd. Defaults to false.

    nfs_v4_idmap_nobody_user

    String. ‘Nobody-User’ option for idmapd. Defaults to nobody.

    nfs_v4_idmap_nobody_group

    String. ‘Nobody-Group’ option for idmapd. Defaults to nobody or nogroup.

    client_rpcbind_config

    String. It defines the location of the file with the rpcbind config.

    client_rpcbind_optname

    String. It defines the name of env variable that holds the rpcbind config. E.g. OPTIONS for Debian

    client_rpcbind_opts

    String. Options for rpcbind service.

    Define: ::nfs::client::mount

    The following parameters are available in the ::nfs::client::mount define:

    server

    String. Sets the ip address of the server with the nfs export

    share

    String. Sets the name of the nfs share on the server

    ensure

    String. Sets the ensure parameter of the mount.

    remounts

    String. Sets the remounts parameter of the mount.

    atboot

    String. Sets the atboot parameter of the mount.

    options_nfsv4

    String. Sets the mount options for a nfs version 4 mount.

    options_nfs

    String. Sets the mount options for a nfs mount.

    bindmount

    String. When not undef it will create a bindmount on the node for the nfs mount.

    nfstag

    String. Sets the nfstag parameter of the mount.

    nfs_v4

    Boolean. When set to true, it uses nfs version 4 to mount a share.

    owner

    String. Set owner of mount dir

    group

    String. Set group of mount dir

    mode

    String. Set mode of mount dir

    mount_root

    String. Overwrite mount root if differs from server config

    Define: ::nfs::server::export

    The following parameters are available in the ::nfs::server::export define:

    clients

    String. Sets the allowed clients and options for the export in the exports file. Defaults to localhost(ro)

    bind

    String. Sets the bind options setted in /etc/fstab for the bindmounts created. Defaults to rbind. When you have any submounts in your exported folders, the rbind option will submount them in the bindmount folder. You have to set the  crossmnt option in your nfs export to have the submounts from rbind available on your client. Your export should look like this:

    node client {
      nfs::server::export { '/home':
        ensure  => 'mounted',
        clients => '*(rw,insecure,no_subtree_check,async,no_root_squash,crossmnt)',
      }
    }
    ensure

    String. If enabled the mount will be created. Defaults to mounted

    remounts

    String. Sets the remounts parameter of the mount.

    atboot

    String. Sets the atboot parameter of the mount.

    options_nfsv4

    String. Sets the mount options for a nfs version 4 exported resource mount.

    options_nfs

    String. Sets the mount options for a nfs exported resource mount.

    bindmount

    String. When not undef it will create a bindmount on the node for the nfs mount.

    nfstag

    String. Sets the nfstag parameter of the mount.

    mount

    String. Sets the mountpoint the client will mount the exported resource mount on. If undef it defaults to the same path as on the server

    owner

    String. Sets the owner of the exported directory

    group

    String. Sets the group of the exported directory

    mode

    String. Sets the permissions of the exported directory.

    Requirements

    Modules needed:

    puppetlabs/stdlib >= 4.5.0 puppetlabs/concat >= 1.1.2

    Software versions needed:

    facter > 1.6.2 puppet > 3.2.0

    Ruby Gems needed:

    augeas

    Limitations

    If you want to have specific package versions installed you may manage the needed packages outside of this module (use manage_packages => false). It is only tested to use ‘present’, ‘installed’, ‘absent’, ‘purged’, ‘held’ and ‘latest’ as argument for the parameters server_package_ensure and client_package_ensure.

    Development

    Derdanne modules are open projects. So if you want to make this module even better, you can contribute to this module on Github.

    Before pushing PRs to Github i would recommend you to test your work locally. So you can ensure all test builds on Travis CI were passing. I have prepared an easy way to test your code locally with the help of Docker.

    For running the complete static code analysis, it is sufficient to run a make test-all.

    Default settings

    I have set some defaults which you can change by setting the following environment variables.

    PUPPET_VERSION

    Changes the puppet version which will be used for the tests. Defaults to 6.0.

    STRICT_VARIABLES

    Sets strict variables on or off. Defaults to yes.

    RVM

    Sets the ruby version which will be used for the tests. Defaults to 2.4.1.

    BEAKER_set

    Sets the beaker docker target host. Defaults to ubuntu-20.04.

    PUPPET_collection

    Sets the puppet version for acceptance tests. Defaults to puppet6.

    Running tests

    You can run the following commands to setup and run the testsuite on your local machine.

    make build

    Build a docker image with a Ruby version which is not available on Docker hub. Check out https://hub.docker.com/r/derdanne/rvm/ to see if i have already prepared a rvm build for the ruby version you want to test. Take a look at the Dockerfile located in spec/local-testing if you want to customize your builds.

    make pull

    Pull a prebuild rvm docker image with the Ruby version defined in the variable RVM.

    make install-gems

    Install all needed gems locally to vendor/bundle.

    make test-metadata-lint

    Run linting of metadata.

    make test-lint

    Run puppet lint tests.

    make test-syntax

    Run syntax tests.

    make test-rspec

    Run rspec puppet tests.

    make test-rubocop

    Run rubocop tests.

    make test-all

    Run the whole testsuite.

    make test-beaker

    Run puppetlabs beaker rspec tests.

    Disclaimer

    This module based on Harald Skoglund haraldsk@redpill-linpro.com from https://github.com/haraldsk/puppet-module-nfs/ but has been fundementally refactored

    Transfer Notice

    This plugin was originally authored by Daniel Klockenkaemper dk@marketing-factory.de. The maintainer preferred that Vox Pupuli take ownership of the module for future improvement and maintenance. Existing pull requests and issues were transferred over, please fork and continue to contribute here instead of Camptocamp.

    Previously: https://github.com/derdanne/puppet-nfs

    Visit original content creator repository https://github.com/voxpupuli/puppet-nfs
  • simple_go_struct_interface_method_example

    Simple Go Struct-Interface Method Example

    Overview

    This Go program demonstrates the use of interface-typed objects that are declared to link some functions to their specified struct. This technique, although using the property of interface-typed objects, is not the same as demonstrated here where interface-typed arguments are passed into functions. As for the code in this repository, we can use functions as methods for the created structs since we are not passing interface-typed objects as conventional argument, but we are using them as receiver arguments instead.

    Program manual

    Since this program is very similar to the one in the repository in this link, I’m just going to copy-paste the program manual from there as the following:

    When run, the program asks the user to input the following information in the following order:

    Note title
    Note content
    Todo
    Then, the program will show messages containing the input information and, if there’s no error, will notify the user that the note and todo are successfully saved (in json file format).

    There is no input validation for this program because every piece of information are in the form of free text. However, the program is designed to catch error when saving the files. The user will be notified if there’s any error while saving each file. In case of error, the program will stops after displaying the error message.

    Code structure

    Although, the program in this project works exactly the same as the one from this link, the code structure was designed differently in order to demonstrate another way of using interface to link common methods to different struct types from different packages.

    The project comprises the main.go file which contains the code of the main program, and the codes which make up the note and todo packages. The main.go file contains the code declaring interface objects that link the save and display functions in the mentioned packages to their native structs. Those functions can, in turn, be used as the structs’ methods.

    Program flow

    Since this program works exactly as another one in a different repository as mentioned in several places above, I’m just going to copy an paste the same program flow from there as the following:

    1. The user inputs the note title as a string
    2. The user inputs the note content as a string
    3. The program takes those inputs to create a struct which stores the note title, content, and the timestamp at its creation
    4. The user inputs the todo text
    5. The program takes the todo text input to create another struct which stores the todo text (without any title)
    6. The program displays messages to confirm the note’s title and its content from the inputs
    7. The program displays a message to confirm the todo
    8. The program displays a message to notify the user that it’s saving the note
    9. The program attempts to save the inputs as a json file with json field names according to the struct tags given in the code
    10. The program displays the message that it saves the file successfully
    11. The program repeat the same process from 8. for the todo (the todo’s file name is already hard-coded in the program and can’t be changed)

    Visit original content creator repository
    https://github.com/pkx8326/simple_go_struct_interface_method_example

  • PaginationView

    PaginationView

    Pagination view for Android to show large amount of data just like PHP paginator.

    Screen Shots

    Usage

    1. Add the following in the dependencies section of the application’s build.gradle (the one in the app folder).
        dependencies {
            compile 'com.pkj.wow.paginationview:PaginationView:1.0.2-7'
        }
    
    1. Add PaginationView to your activity’s layout and set parent property “clipChildren” to false.
        <com.pkj.wow.paginationview.PaginationView
            android:id="@+id/pagination_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipChildren="false"
            />
    1. Set total data size, page size and add page update listener which will call after pager update.
        mPaginationView.setPager(list.size());
        mPaginationView.setOnPagerUpdate(new PaginationView.OnPagerUpdate() {
            @Override
            public void onUpdate(int pageNumber, int pageSize) {
                // query your data from page number to page size according to your requirement
                ...
                // notify your adapter
            }
        });
    

    Example

    Activity layout file

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:clipChildren="false"
        tools:context=".MainActivity">
    
        <android.support.v7.widget.RecyclerView
            android:id="@+id/my_recycler_view"
            android:scrollbars="vertical"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/>
    
        <com.pkj.wow.paginationview.PaginationView
            android:id="@+id/pagination_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipChildren="false"
            />
            
    </LinearLayout>

    Activity code

    mAdapter = new MyAdapter(getDataset(0, pageSize));
    mRecyclerView.setAdapter(mAdapter);
    
    mPaginationView.setPager(size);
    mPaginationView.setOnPagerUpdate(new PaginationView.OnPagerUpdate() {
        @Override
        public void onUpdate(int pageNumber, int pageSize) {
            mAdapter.setDataset(getDataset(pageNumber, pageSize));
            mAdapter.notifyDataSetChanged();
        }
    });
    

    Licence

    Copyright 2018 Pankaj Jangid
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
       http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    
    Visit original content creator repository https://github.com/pkjvit/PaginationView
  • bin

    Short scripts, which do not belong to my dotfiles. Unless otherwise stated,
    these files are in the public domain.

    List:

    Visit original content creator repository
    https://github.com/d630/bin

  • modsurfer-validate-action

    Modsurfer validate GitHub Action

    Overview

    Modsurfer by Dylibso is an application to help teams debug and observe their
    WebAssembly modules and components. It scans WASM binaries and extracts critical information about
    the code contained within, as well as makes WASM code searchable and visible to the teams creating
    and executing it. See a demo of the Modsurfer application here: https://modsurfer.app

    This GitHub Action runs Modsurfer’s CLI, found here, using
    the validate command. This command expects two inputs:

    • path (-p from the CLI): pointing to the .wasm file to validate
    • check (-c from the CLI): pointing to the YAML file (default: mod.yaml) to validate against

    Usage

    To use this action, add the following step in your workflow:

        # ...
        steps:
          - uses: actions/checkout@v3
          - name: modsurfer validate
            uses: dylibso/modsurfer-validate-action@main
            with:
                path: path/to/your.wasm
                check: path/to/mod.yaml

    An example mod.yaml (a “check file”) could be:

    # For more information about other checkfile options, see the documentation at https://dev.dylib.so/docs/modsurfer/cli#checkfile
    validate:
      # mandate that WASI support is allowed or not
      allow_wasi: false
      # define requirements for existence (or non-existence) of a module's import functions
      imports:
        include:
        # specify the function and its signature, optionally scoping it to a particular module name / namespace
        - name: http_get
          namespace: env
          params: 
          - I32
          - I32
          results:
          - I32
        # or, simply use the function name
        - log_message
        - proc_exit
        exclude: 
        - fd_write
        # declare module-wide requirements for existence (or non-existence) of imports from modules / namespaces
        namespace:
          include:
            - env
          exclude:
            - some_future_deprecated_module_name
            - wasi_snapshot_preview1
      # define requirements for existence (or non-existence) of a module's export functions
      exports: 
      # set a threshold for maximum number of exports
        max: 2
        include:
        - name: _start
          params: []
          results: []
        - name: bar
          params:
          - I32
          - I32
          results:
          - I32
        exclude:
          - main
          - foo
      # restrict binary size of a module (supports suffixes listed here: https://docs.rs/parse-size/1.0.0/parse_size/index.html)
      size:
        max: 4MB
      # restrict WASM code complexity to a risk profile (low, medium, high) based on Cyclomatic Complexity analysis
      complexity:
        max_risk: low

    When a module fails to validate against the provided check file, a report is printed (seen below),
    and will issue a non-zero exit code, failing the CI workflow.

    ┌────────┬──────────────────────────────────────────────────┬──────────┬──────────┬───────────────────┬────────────┐
    │ Status │ Property                                         │ Expected │ Actual   │ Classification    │ Severity   │
    ╞════════╪══════════════════════════════════════════════════╪══════════╪══════════╪═══════════════════╪════════════╡
    │ FAIL   │ allow_wasi                                       │ false    │ true     │ ABI Compatibility │ |||||||||| │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ complexity.max_risk                              │ <= low   │ medium   │ Resource Limit    │ |          │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ exports.exclude.main                             │ excluded │ included │ Security          │ |||||      │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ exports.include.bar                              │ included │ excluded │ ABI Compatibility │ |||||||||| │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ exports.max                                      │ <= 100   │ 151      │ Security          │ ||||||     │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ imports.include.http_get                         │ included │ excluded │ ABI Compatibility │ ||||||||   │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ imports.include.log_message                      │ included │ excluded │ ABI Compatibility │ ||||||||   │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ imports.namespace.exclude.wasi_snapshot_preview1 │ excluded │ included │ ABI Compatibility │ |||||||||| │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ imports.namespace.include.env                    │ included │ excluded │ ABI Compatibility │ ||||||||   │
    ├────────┼──────────────────────────────────────────────────┼──────────┼──────────┼───────────────────┼────────────┤
    │ FAIL   │ size.max                                         │ <= 4MB   │ 4.4 MiB  │ Resource Limit    │ |          │
    └────────┴──────────────────────────────────────────────────┴──────────┴──────────┴───────────────────┴────────────┘
    

    Visit original content creator repository
    https://github.com/dylibso/modsurfer-validate-action

  • natagora-occurrences

    Observations.be – Species occurrence datasets published by Natagora

    Rationale

    This repository contains the functionality to standardize datasets of observations.be to Darwin Core Occurrence datasets that can be harvested by GBIF. It was originally developed for the TrIAS project.

    Workflow

    observations.be database → Darwin Core SQL view → Direct connection with the IPT or CSV upload

    Datasets

    Title (and GitHub directory) IPT GBIF
    Observations.be – Non-native species occurrences in Wallonia, Belgium natagora-alien-occurrences https://doi.org/10.15468/p58ip1
    Observations.be – Orthoptera occurrences in Wallonia, Belgium natagora-orthoptera-occurrences https://doi.org/10.15468/r763pb

    Repo structure

    The structure for each dataset in datasets is based on Cookiecutter Data Science and the Checklist recipe. Files and directories indicated with GENERATED should not be edited manually.

    ├── sql                      : Darwin Core SQL queries
    │
    └── specs                    : Whip specifications for validation
    

    references contains controlled vocabularies for:

    These are shared with the waarnemingen.be datasets.

    Validating with whip

    Published data can be validated with whip:

    1. Download the published DwC Archive from the IPT
    2. Unzip the data in the directory data (git ignored), so data are available at data/data_file.txt
    3. In terminal, start jupyter notebook from the repository root
    4. Open notebooks/whip.ipynb
    5. In the notebook, set the correct paths at the top of the file
    6. Run the notebook
    7. Update dataset or specifications until they align

    Contributors

    List of contributors

    License

    MIT License

    Visit original content creator repository
    https://github.com/BelgianBiodiversityPlatform/natagora-occurrences

  • Podcast-Feed-Extractor

    Podcast-Feed-Extractor

    Getting all your RSS feed addresses from your iTunes directory

    This is a follow-up from my POD-igy repo.

    I realized that there was no easy way to extract the RSS feeds from your podcast app. I use iTunes on my desktop for downloading my podcasts. So I created this repo that extracts the podcasts from your iTunes folder and provides you with the RSS feeds.

    Instructions:

    1. Download this repo to your disk.
    2. Open your command prompt and navigate to this repo
    3. Enter the repo:
      cd Podcast-Feed-Extractor
    4. Install the requirements:
      pip install -r requirements.txt
    5. Find the path to your iTunes folder. By default, on Windows, it is installed at “C:\Users<user>\Music\iTunes”
    6. Run this code:
      python3 podcast.py <path of the iTunes folder as identified in step 5>
    7. The output files are as follows:
      1. A pickle file (podcast_feed.pkl) (if you want to load the dictionary { podcast_name : rss_feed} for further manipulation in python
      2. A text file (error_podcasts): A text file that contains the names of podcasts whose RSS feeds could not be identified
      3. A text file (rss_feeds): A text file that contains the name of podcasts and the RSS URL for each podcast

    Sample output files are available in the sample_outputs folder

    Screenshots from command window

    1. List of podcasts in the iTunes library


    2. List of podcasts whose RSS feeds could not be extracted


    3. List of podcasts with the url of the RSS feeds


    Visit original content creator repository https://github.com/SwamiKannan/Podcast-Feed-Extractor