[Bps-public-commit] app-aws-cloudwatch-monitor branch update-shell-commands-in-cloudwatchclient created. 0ed1df4ea5aa6cde7bf54335b6b4904188d77d75

BPS Git Server git at git.bestpractical.com
Fri Jul 29 23:28:42 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "app-aws-cloudwatch-monitor".

The branch, update-shell-commands-in-cloudwatchclient has been created
        at  0ed1df4ea5aa6cde7bf54335b6b4904188d77d75 (commit)

- Log -----------------------------------------------------------------
commit 0ed1df4ea5aa6cde7bf54335b6b4904188d77d75
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Fri Jul 29 18:23:52 2022 -0500

    Update shell commands in CloudWatchClient
    
    This commit updates the shell and system commands in
    CloudWatchClient to instead use Perl's builtin opendir and
    File::Path::make_path.

diff --git a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
index e078f3d..a926d0d 100644
--- a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
@@ -35,6 +35,7 @@ use warnings;
 use base 'Exporter';
 our @EXPORT = qw();
 use File::Basename;
+use File::Path;
 use App::AWS::CloudWatch::Monitor::AwsSignatureV4;
 use Time::Piece;
 use Digest::SHA qw(hmac_sha256_base64);
@@ -181,7 +182,13 @@ sub read_meta_data {
     if ($location) {
         my $filename = $location . $resource;
         if ( -d $filename ) {
-            $data_value = `/bin/ls $filename`;
+            my $ret = opendir( my $dh, $filename );
+            unless ($ret) {
+                warn "open: unable to read meta data from filesystem: $!\n";
+                return;
+            }
+            $data_value = join ' ', grep { !/^\./ } readdir($dh);
+            closedir $dh;
         }
         elsif ( -e $filename ) {
             my $ret = open( my $file_fh, '<', $filename );
@@ -225,7 +232,13 @@ sub write_meta_data {
         if ($location) {
             my $filename  = $location . $resource;
             my $directory = File::Basename::dirname($filename);
-            system( qw{ /bin/mkdir -p }, $directory ) unless -d $directory;
+            unless ( -d $directory ) {
+                my $ret = File::Path::make_path($directory);
+                unless ($ret) {
+                    warn "make_path: unable to create directory for writing meta data: $!\n";
+                    return;
+                }
+            }
 
             open( my $file_fh, '>', $filename )
                 or warn "open: unable to write meta data from filesystem: $!\n";
-----------------------------------------------------------------------


hooks/post-receive
-- 
app-aws-cloudwatch-monitor


More information about the Bps-public-commit mailing list