Class: Inspec::Resources::PodmanNetwork
- Inherits:
-
Object
- Object
- Inspec::Resources::PodmanNetwork
- Includes:
- Utils::Podman
- Defined in:
- lib/inspec/resources/podman_network.rb
Constant Summary collapse
- LABELS =
{ id: "ID", name: "Name", driver: "Driver", labels: "Labels", options: "Options", ipam_options: "IPAMOptions", internal: "Internal", created: "Created", ipv6_enabled: "IPv6Enabled", dns_enabled: "DNSEnabled", network_interface: "NetworkInterface", subnets: "Subnets", }.freeze
Instance Attribute Summary collapse
-
#network_info ⇒ Object
readonly
Returns the value of attribute network_info.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(param) ⇒ PodmanNetwork
constructor
A new instance of PodmanNetwork.
-
#k ⇒ Object
This creates all the required properties methods dynamically.
- #resource_id ⇒ Object
- #to_s ⇒ Object
Methods included from Utils::Podman
#generate_go_template, #parse_command_output, #podman_running?
Constructor Details
#initialize(param) ⇒ PodmanNetwork
Returns a new instance of PodmanNetwork.
38 39 40 41 42 43 44 45 |
# File 'lib/inspec/resources/podman_network.rb', line 38 def initialize(param) skip_resource "The `podman_network` resource is not yet available on your OS." unless inspec.os.unix? @param = param raise Inspec::Exceptions::ResourceFailed, "Podman is not running. Please make sure it is installed and running." unless podman_running? @network_info = get_network_info end |
Instance Attribute Details
#network_info ⇒ Object (readonly)
Returns the value of attribute network_info.
37 38 39 |
# File 'lib/inspec/resources/podman_network.rb', line 37 def network_info @network_info end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
37 38 39 |
# File 'lib/inspec/resources/podman_network.rb', line 37 def param @param end |
Instance Method Details
#exist? ⇒ Boolean
54 55 56 |
# File 'lib/inspec/resources/podman_network.rb', line 54 def exist? !network_info.empty? end |
#k ⇒ Object
This creates all the required properties methods dynamically.
48 49 50 51 52 |
# File 'lib/inspec/resources/podman_network.rb', line 48 LABELS.each do |k, v| define_method(k) do network_info[k.to_s] end end |
#resource_id ⇒ Object
58 59 60 |
# File 'lib/inspec/resources/podman_network.rb', line 58 def resource_id id || param || "" end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/inspec/resources/podman_network.rb', line 62 def to_s "podman_network #{resource_id}" end |