Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookstyle Bot Auto Corrections with Cookstyle 7.13.0 #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
# We cannot run Test Kitchen on Travis CI yet...
namespace :travis do
desc 'Run tests on Travis'
task ci: %w[style unit]
task ci: %w(style unit)
end

# The default rake task should just run it all
Expand Down
2 changes: 1 addition & 1 deletion libraries/_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
21 changes: 10 additions & 11 deletions libraries/_junos_api_client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,7 +38,7 @@ class ApiClient
ip_ports: ::Junos::Ez::IPports,
vlans: ::Junos::Ez::Vlans,
lag_ports: ::Junos::Ez::LAGports,
group: ::Junos::Ez::Group
group: ::Junos::Ez::Group,
}.freeze

KNOWN_RESOURCES.each_pair do |resource, provider_module|
Expand All @@ -62,20 +62,21 @@ def initialize(resource_name)

# The `Junos::Ez` providers expect certain values
# to be symbolized or requests will fail.
VALUES_TO_SYMBOLIZE = %w[auto up down half full active passive disabled].freeze
VALUES_TO_SYMBOLIZE = %w(auto up down half full active passive disabled).freeze

attr_reader :resource_type
attr_reader :resource_name

def initialize(resource_type, resource_name)
resource_name resource_name

def initialize(resource_type, _resource_name)
unless KNOWN_RESOURCES.keys.include?(resource_type)
error_message = "Invalid resource type :#{resource_type}."
error_message << " Try one of: :#{KNOWN_RESOURCES.keys.join(', :')}"
raise error_message
end

@resource_type = resource_type
@resource_name = resource_name
end

# Writes managed resource to the candidate configuration.
Expand Down Expand Up @@ -144,9 +145,9 @@ def updated_changed_properties(new_values, current_values)
def managed_resource
@managed_resource ||= begin
transport.send(resource_type)[resource_name]
rescue Netconf::RpcError => e
Chef::Log.debug("Managed Resource #{resource_name} not found: #{e}")
nil
rescue Netconf::RpcError => e
Chef::Log.debug("Managed Resource #{resource_name} not found: #{e}")
nil
end
end

Expand Down Expand Up @@ -217,7 +218,7 @@ def format_rpc_error(rpc_error)
# fall back to ugly xml
end

error_msg = <<-MSG
<<-MSG

JUNOS XML REQUEST:

Expand All @@ -227,8 +228,6 @@ def format_rpc_error(rpc_error)

#{response.to_xml}
MSG

error_msg
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions libraries/_junos_api_transaction_handler.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@
class JunosCommitTransactionHandler < Chef::Handler
def report
# Ensure handler is no-op in why-run mode and non-Junos platforms.
if (node['platform'] == 'junos' || (node['platform_version'].include? 'JNPR')) && !Chef::Config[:why_run]
if (platform?('junos') || (node['platform_version'].include? 'JNPR')) && !Chef::Config[:why_run]
begin
# on successful Chef-runs commit the transaction
if success?
Expand Down
2 changes: 1 addition & 1 deletion libraries/_junos_api_transport.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion libraries/platform_provider_mapping.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
9 changes: 3 additions & 6 deletions libraries/provider_group_junos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: group
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,9 +31,6 @@ class Provider::NetdevGroup::Junos < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevGroup.new(new_resource.name)
Expand Down Expand Up @@ -74,7 +71,7 @@ def action_create
@new_values[:path] = @file_path
format = @new_values[:template_path].split('/')[-1].split('.')
if format[1] != 'erb'
unless %w[xml text set].include? format[1]
unless %w(xml text set).include? format[1]
failure_msg = "Invalid format #{format[1]} in #{@new_values[:template_path]}. Valid format values: 'xml', 'text', 'set'.\n\n"
Chef::Log.fatal(failure_msg)
raise(failure_msg)
Expand Down
7 changes: 2 additions & 5 deletions libraries/provider_interface_eos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: interface
#
# Copyright 2013, Arista Networks
# Copyright:: 2013, Arista Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,9 +30,6 @@ class Provider::NetdevInterface::EOS < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevInterface.new(@new_resource.name)
Expand Down
7 changes: 2 additions & 5 deletions libraries/provider_interface_junos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: interface
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,9 +31,6 @@ class Provider::NetdevInterface::Junos < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevInterface.new(new_resource.name)
Expand Down
7 changes: 2 additions & 5 deletions libraries/provider_l2_interface_eos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: l2_interface
#
# Copyright 2013, Arista Networks
# Copyright:: 2013, Arista Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,9 +30,6 @@ class Provider::NetdevL2Interface::EOS < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevL2Interface.new(new_resource.name)
Expand Down
7 changes: 2 additions & 5 deletions libraries/provider_l2_interface_junos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: l2_interface
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,9 +31,6 @@ class Provider::NetdevL2Interface::Junos < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevL2Interface.new(new_resource.name)
Expand Down
7 changes: 2 additions & 5 deletions libraries/provider_lag_eos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: lag
#
# Copyright 2013, Arista Networks
# Copyright:: 2013, Arista Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,9 +30,6 @@ class Provider::NetdevLinkAggregationGroup::EOS < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevLinkAggregationGroup.new(new_resource.name)
Expand Down
7 changes: 2 additions & 5 deletions libraries/provider_lag_junos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: lag
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,9 +31,6 @@ class Provider::NetdevLinkAggregationGroup::Junos < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevLinkAggregationGroup.new(new_resource.name)
Expand Down
7 changes: 2 additions & 5 deletions libraries/provider_vlan_eos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: vlan
#
# Copyright 2013, Arista Networks
# Copyright:: 2013, Arista Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,9 +30,6 @@ class Provider::NetdevVirtualLAN::EOS < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevVirtualLAN.new(new_resource.name)
Expand Down
7 changes: 2 additions & 5 deletions libraries/provider_vlan_junos.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Provider:: vlan
#
# Copyright 2014, Chef Software, Inc.
# Copyright:: 2014, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,9 +31,6 @@ class Provider::NetdevVirtualLAN::Junos < Provider
#
# This provider supports why-run mode.
#
def whyrun_supported?
true
end

def load_current_resource
@current_resource = Chef::Resource::NetdevVirtualLAN.new(new_resource.name)
Expand Down
14 changes: 8 additions & 6 deletions libraries/resource_group.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
# Cookbook Name:: netdev
# Cookbook:: netdev
# Resource:: JUNOS apply group
#
# Copyright 2014, Chef Software, Inc.
# Copyright 2015, Juniper Network.
# Copyright:: 2014, Chef Software, Inc.
# Copyright:: 2015, Juniper Network.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -30,13 +30,14 @@ class Resource::NetdevGroup < Resource
attr_accessor :exists
alias exists? exists

resource_name :netdev_group

default_action :create

def initialize(name, run_context = nil)
super

@resource_name = :netdev_group

# Set default actions and allowed actions
@action = :create
@allowed_actions.push(:create, :delete)

# Set the name attribute and default attributes
Expand Down Expand Up @@ -87,4 +88,5 @@ def template_path(arg = nil)
end
end
end

class Chef::Provider::NetdevGroup; end
Loading