You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/01/27 16:53:43 UTC

[22/36] incubator-trafficcontrol git commit: Perltidy on all files

Perltidy on all files


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/d665814e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/d665814e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/d665814e

Branch: refs/heads/master
Commit: d665814e939e482bcb665d076e64d9861c1804f8
Parents: ca4b10a
Author: peryder <pe...@cisco.com>
Authored: Wed Dec 7 10:18:49 2016 -0500
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Fri Jan 27 09:52:53 2017 -0700

----------------------------------------------------------------------
 traffic_ops/install/lib/BuildPerlDeps.pm  |  5 ++-
 traffic_ops/install/lib/GenerateCert.pm   |  1 -
 traffic_ops/install/lib/InstallUtils.pm   | 50 +++++++++++++-------------
 traffic_ops/install/lib/ProfileCleanup.pm | 16 +--------
 4 files changed, 28 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d665814e/traffic_ops/install/lib/BuildPerlDeps.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/install/lib/BuildPerlDeps.pm b/traffic_ops/install/lib/BuildPerlDeps.pm
index 7c20845..e127d07 100644
--- a/traffic_ops/install/lib/BuildPerlDeps.pm
+++ b/traffic_ops/install/lib/BuildPerlDeps.pm
@@ -1,5 +1,4 @@
 #!/usr/bin/perl
-
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -14,10 +13,10 @@
 # limitations under the License.
 #
 
-package BuildPerlDeps;
-
 use lib qw(/opt/traffic_ops/install/lib /opt/traffic_ops/lib/perl5 /opt/traffic_ops/app/lib);
 
+package BuildPerlDeps;
+
 use InstallUtils qw{ :all };
 
 use base qw{ Exporter };

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d665814e/traffic_ops/install/lib/GenerateCert.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/install/lib/GenerateCert.pm b/traffic_ops/install/lib/GenerateCert.pm
index 0d4a458..8fb1a11 100644
--- a/traffic_ops/install/lib/GenerateCert.pm
+++ b/traffic_ops/install/lib/GenerateCert.pm
@@ -54,7 +54,6 @@ sub writeCdn_conf {
         $cdnh->{hypnotoad}{listen} = [$listen_str];
     }
     else {
-
         # add the whole hypnotoad config without affecting anything else in the config
         $cdnh->{hypnotoad} = {
             listen   => [$listen_str],

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d665814e/traffic_ops/install/lib/InstallUtils.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/install/lib/InstallUtils.pm b/traffic_ops/install/lib/InstallUtils.pm
index c0ad9b5..a4f0266 100644
--- a/traffic_ops/install/lib/InstallUtils.pm
+++ b/traffic_ops/install/lib/InstallUtils.pm
@@ -42,42 +42,43 @@ our @EXPORT_OK = qw{ execCommand randomWord promptUser promptRequired promptPass
 our %EXPORT_TAGS = ( all => \@EXPORT_OK );
 
 sub execCommand {
-    my ( $command, @args ) = @_; 
+    my ( $command, @args ) = @_;
 
     my $pipe = IO::Pipe->new;
     my $pid;
-    my $result = 0;
+    my $result    = 0;
     my $customLog = "";
 
-    # find log file in args and remove if found 
+    # find log file in args and remove if found
     # if there is a string in the list of args which starts with 'pi_custom_log=' then remove it from the parameters and use
     #  it as the log file for the exec
     foreach my $var (@args) {
-        if ( index($var, "pi_custom_log=") != -1 ) {
-            $customLog = (split(/=/, $var))[1];
-            splice(@args, index($var, "pi_custom_log="), 1);
-            logger("Using custom log '$customLog'", "info");
+        if ( index( $var, "pi_custom_log=" ) != -1 ) {
+            $customLog = ( split( /=/, $var ) )[1];
+            splice( @args, index( $var, "pi_custom_log=" ), 1 );
+            logger( "Using custom log '$customLog'", "info" );
         }
     }
-    
+
     # create pipe between child and parent and redirect output from child to parent for logging
     my $child = open READER, '-|';
     defined $child or die "pipe/fork: $!\n";
-    if ($child) { #parent
+    if ($child) {    #parent
         while ( $line = <READER> ) {
+
             # log all output from child pipe
-            if ($customLog ne "") {
-                logger($line, "info", $customLog);
+            if ( $customLog ne "" ) {
+                logger( $line, "info", $customLog );
             }
             else {
-                logger($line, "info");
+                logger( $line, "info" );
             }
         }
     }
-    else { #child
-        # redirect stderr to stdout so parent can read
+    else {           #child
+                     # redirect stderr to stdout so parent can read
         open STDERR, '>&STDOUT';
-        exec($command, @args) or exit(1);
+        exec( $command, @args ) or exit(1);
     }
 }
 
@@ -91,27 +92,27 @@ sub errorOut {
 # This function is intended to keep log file sizes low and is called from postinstall
 sub rotateLog {
     my $logFileName = shift;
-    
+
     if ( !-f $logFileName ) {
-        logger("Log file '$logFileName' does not exist - not rotating log", "error");
+        logger( "Log file '$logFileName' does not exist - not rotating log", "error" );
         return;
     }
 
-    execCommand('/bin/mv', '-f', $logFileName, $logFileName . '.bkp');
-    logger("Rotated log $logFileName", "info");
+    execCommand( '/bin/mv', '-f', $logFileName, $logFileName . '.bkp' );
+    logger( "Rotated log $logFileName", "info" );
 }
 
 # outputs logging messages to terminal and log file
 sub logger {
     my $output = shift;
     my $type   = shift;
-   
+
     # optional custom log file to use instead of main log file used by postinstall
     # cpan uses a custom log file because of its size
     my $customLogFile = shift;
 
     my $message = $output;
-    if (index($message, "\n") == -1) {
+    if ( index( $message, "\n" ) == -1 ) {
         $message = $message . "\n";
     }
 
@@ -124,7 +125,7 @@ sub logger {
     my $fh;
     my $result = 0;
     if ( defined $customLogFile && $customLogFile ne "" ) {
-        open $fh, '>>', $customLogFile or die("Couldn't open log file '$::customLogFile'");     
+        open $fh, '>>', $customLogFile or die("Couldn't open log file '$::customLogFile'");
         $result = 1;
     }
     else {
@@ -133,8 +134,8 @@ sub logger {
             $result = 1;
         }
     }
-    
-    if ( $result ) {
+
+    if ($result) {
         print $fh localtime . ": " . uc($type) . ' ' . $message;
         close $fh;
     }
@@ -152,7 +153,6 @@ sub randomWord {
     return $secret;
 }
 
-# deprecated
 sub promptUser {
     my ( $promptString, $defaultValue, $noEcho ) = @_;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d665814e/traffic_ops/install/lib/ProfileCleanup.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/install/lib/ProfileCleanup.pm b/traffic_ops/install/lib/ProfileCleanup.pm
index eab10a1..3fe6220 100644
--- a/traffic_ops/install/lib/ProfileCleanup.pm
+++ b/traffic_ops/install/lib/ProfileCleanup.pm
@@ -1,17 +1,3 @@
-#!/usr/bin/perl
-#
-# 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.
-#
 
 package ProfileCleanup;
 
@@ -159,7 +145,7 @@ sub profiles_exist {
 
     $::parameters->{'tm.url'} = $tmurl;
 
-    logger("Checking profiles at $tmurl using username " . $config->{"username"}, "info");
+    logger( "Checking profiles at $tmurl using username " . $config->{"username"}, "info" );
 
     my $uri = $::parameters->{'tm.url'};
     my $toCookie = get_traffic_ops_cookie( $::parameters->{'tm.url'}, $config->{"username"}, $config->{"password"} );