Skip to content

Commit e14b445

Browse files
[Refactor] - refactor function names
1 parent cdaee33 commit e14b445

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

services/s3.sh

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/bash
22

3-
aws_s3_ls() {
3+
function aws_s3_ls() {
44
aws_run_commandline "aws s3 ls"
55

66
}
7-
aws_s3_list() {
7+
function aws_s3_list() {
88
aws_run_commandline 'aws s3api list-buckets --query "Buckets[].Name"'
99
}
1010

11-
aws_s3_get_bucket() {
11+
function aws_s3_get_bucket() {
1212
aws_s3_bucket_name=$1
1313
aws_run_commandline \
1414
"
@@ -17,23 +17,23 @@ aws_s3_get_bucket() {
1717

1818
}
1919

20-
aws_s3_get_bucket_recursived() {
20+
function aws_s3_get_bucket_recursived() {
2121
aws_s3_bucket_name=$1
2222
aws_run_commandline \
2323
"
2424
aws s3 ls s3://${aws_s3_bucket_name:?'aws_s3_bucket_name is unset or empty'} --recursive
2525
"
2626
}
2727

28-
aws_s3_get_bucket_with_hint() {
28+
function aws_s3_get_bucket_with_hint() {
2929
aws_s3_get_bucket $(peco_create_menu 'peco_aws_s3_list')
3030
}
3131

32-
aws_s3_get_bucket_recursived_with_hint() {
32+
function aws_s3_get_bucket_recursived_with_hint() {
3333
aws_s3_get_bucket_recursived $(peco_create_menu 'peco_aws_s3_list')
3434
}
3535

36-
aws_s3_get_object_metadata() {
36+
function aws_s3_get_object_metadata() {
3737
aws_s3_bucket_name=$1
3838
object_key=$2
3939

@@ -44,16 +44,16 @@ aws_s3_get_object_metadata() {
4444

4545
}
4646

47-
aws_s3_get_bucket_arn() {
47+
function aws_s3_get_bucket_arn() {
4848
aws_s3_bucket_name=$1
4949
echo "arn:aws:s3:::${aws_s3_bucket_name:?'aws_s3_bucket_name is unset or empty'}"
5050
}
5151

52-
aws_s3_get_bucket_arn_with_hint() {
52+
function aws_s3_get_bucket_arn_with_hint() {
5353
aws_s3_get_bucket_arn $(peco_create_menu 'peco_aws_s3_list')
5454
}
5555

56-
# aws_s3_get_object_metadata_with_hint() {
56+
# function aws_s3_get_object_metadata_with_hint() {
5757
# bucket_name=$(peco_create_menu 'peco_aws_s3_list')
5858
# object_key=$2
5959

@@ -64,7 +64,7 @@ aws_s3_get_bucket_arn_with_hint() {
6464

6565
# }
6666

67-
aws_s3_create() {
67+
function aws_s3_create() {
6868
local aws_s3_bucket_name=$1
6969
# Don't have to specific bucket configuration if it is region us-east-1
7070
local aws_s3_cmd_created="aws s3api create-bucket --bucket ${aws_s3_bucket_name:?'aws_s3_bucket_name is unset or empty'}"
@@ -76,7 +76,7 @@ aws_s3_create() {
7676

7777
}
7878

79-
aws_s3_rm_instruction() {
79+
function aws_s3_rm_instruction() {
8080
aws_s3_bucket_name=$1
8181
echo "We didn't run the commandline, we just suggest the commandline"
8282
echo "If you want ot process it please run the commandline \
@@ -96,12 +96,12 @@ aws_s3_rm_instruction() {
9696
# Delete all object versioning enabled
9797
aws s3api put-bucket-lifecycle-configuration \
9898
--lifecycle-configuration '{"Rules":[{
99-
"ID":"empty-bucket",
100-
"Status":"Enabled",
101-
"Prefix":"",
102-
"Expiration":{"Days":1},
103-
"NoncurrentVersionExpiration":{"NoncurrentDays":1}
104-
}]}' \
99+
"ID":"empty-bucket",
100+
"Status":"Enabled",
101+
"Prefix":"",
102+
"Expiration":{"Days":1},
103+
"NoncurrentVersionExpiration":{"NoncurrentDays":1}
104+
}]}' \
105105
--bucket ${aws_s3_bucket_name}
106106
107107
# Then you just have to wait 1 day and the bucket can be deleted with
@@ -110,7 +110,7 @@ aws_s3_rm_instruction() {
110110
__EOF__
111111
}
112112

113-
aws_s3_rm_with_hint() {
113+
function aws_s3_rm_with_hint() {
114114
aws_s3_rm_instruction $(peco_create_menu 'peco_aws_s3_list')
115115
}
116116

@@ -119,18 +119,18 @@ aws_s3_rm_with_hint() {
119119
# @param TODO The first parameter is the bucket name.
120120
# @return Buckets in Region us-east-1 have a LocationConstraint of null .
121121
#
122-
aws_s3_get_location() {
122+
function aws_s3_get_location() {
123123
aws_run_commandline "\
124124
aws s3api get-bucket-location --bucket ${1}
125125
"
126126
}
127127

128-
aws_s3_get_location_with_hint() {
128+
function aws_s3_get_location_with_hint() {
129129
#
130130
aws_s3_get_location $(peco_create_menu 'peco_aws_s3_list')
131131
}
132132

133-
aws_s3_get_bucket_policy() {
133+
function aws_s3_get_bucket_policy() {
134134
aws_s3_bucket_name=$1
135135
aws_run_commandline \
136136
"
@@ -140,27 +140,18 @@ aws_s3_get_bucket_policy() {
140140
"
141141
}
142142

143-
aws_s3_get_bucket_policy_with_hint() {
143+
function aws_s3_get_bucket_policy_with_hint() {
144144
aws_s3_get_bucket_policy $(peco_create_menu 'peco_aws_s3_list')
145145
}
146146

147-
#
148-
# TODO to get presign url for s3 object.
149-
# @param The first parameter is the full path of object including s3 bucket name
150-
# For ex: s3://DOC-EXAMPLE-BUCKET/test2.txt
151-
# The second parameter is the expires-in (integer) Number of seconds until the pre-signed URL expires.
152-
# Default is 3600 seconds.
153-
# @return
154-
#
155-
156-
aws_s3_get_presigned_url() {
147+
function aws_s3_get_presigned_url_for_viewer() {
157148
aws_run_commandline "\
158149
aws s3 presign $1 --expires-in ${2:-3600}
159150
"
160151

161152
}
162153

163-
aws_s3_cp_folder_instruction() {
154+
function aws_s3_cp_folder_instruction() {
164155
echo "\
165156
aws s3 cp s3://BUCKET_NAME/cf/cf-domain.com/cf-domain.com-2022-12 \
166157
s3://NEW_BUCKET_NAME/cf-domain.com-2022-12/00-10 --recursive --exclude \"*\" --include \"CF_ID.2022-12-0*\"

0 commit comments

Comments
 (0)