pub_keys v0.0.1 PubKeys.Helper
Summary
Functions
Given a list and a string, checks if the list contains the specified string
Examples
iex> PubKeys.Helper.contains?([], "apple")
false
iex> PubKeys.Helper.contains?(["apple", "banana", "orange"], "apple")
true
Checks if given argument is an empty string.
Examples
iex> PubKeys.Helper.empty?("")
true
iex> PubKeys.Helper.empty?("apple")
false
returns path “example_auth_keys_files” if argument is :test. Otherwise returns a path to .ssh_keys directory in your home/username directory, for example: “/home/git/.ssh_keys”.
Examples
iex> PubKeys.Helper.files_path(:test)
"example_auth_keys_files/"
Given an input of ssh_key string in format like ssh-rsa My_unique_key john@test123
, returns the main unique key
Examples
iex> PubKeys.Helper.parse_key("ssh-rsa My_unique_key john@test123")
"My_unique_key"
Given a tuple containing ip address and a list of keys, a target ssh key, and action, returns false if the list of keys does not contain the target key and the action is :add or if the list of keys contains the target key and the action is :remove. Otherwise, returns true.
Examples
iex> path = PubKeys.Helper.files_path(:test)
iex> file_keys = PubKeys.read_keys("192.168.0.10", path)
iex> PubKeys.Helper.should_skip?(file_keys, "ssh-rsa XXX123YZA john@test", :add)
false
iex> PubKeys.Helper.should_skip?(file_keys, "ssh-rsa ABCD123abcd john@test", :add)
true
iex> PubKeys.Helper.should_skip?(file_keys, "ssh-rsa ABCD123abcd john@test", :remove)
false
iex> PubKeys.Helper.should_skip?(file_keys, "ssh-rsa XXX123YZA john@test", :remove)
true
Functions
Given a list and a string, checks if the list contains the specified string
Examples
iex> PubKeys.Helper.contains?([], "apple")
false
iex> PubKeys.Helper.contains?(["apple", "banana", "orange"], "apple")
true
Checks if given argument is an empty string.
Examples
iex> PubKeys.Helper.empty?("")
true
iex> PubKeys.Helper.empty?("apple")
false
returns path “example_auth_keys_files” if argument is :test. Otherwise returns a path to .ssh_keys directory in your home/username directory, for example: “/home/git/.ssh_keys”.
Examples
iex> PubKeys.Helper.files_path(:test)
"example_auth_keys_files/"
Given an input of ssh_key string in format like ssh-rsa My_unique_key john@test123
, returns the main unique key
Examples
iex> PubKeys.Helper.parse_key("ssh-rsa My_unique_key john@test123")
"My_unique_key"
Given a tuple containing ip address and a list of keys, a target ssh key, and action, returns false if the list of keys does not contain the target key and the action is :add or if the list of keys contains the target key and the action is :remove. Otherwise, returns true.
Examples
iex> path = PubKeys.Helper.files_path(:test)
iex> file_keys = PubKeys.read_keys("192.168.0.10", path)
iex> PubKeys.Helper.should_skip?(file_keys, "ssh-rsa XXX123YZA john@test", :add)
false
iex> PubKeys.Helper.should_skip?(file_keys, "ssh-rsa ABCD123abcd john@test", :add)
true
iex> PubKeys.Helper.should_skip?(file_keys, "ssh-rsa ABCD123abcd john@test", :remove)
false
iex> PubKeys.Helper.should_skip?(file_keys, "ssh-rsa XXX123YZA john@test", :remove)
true