blob: 3916fcf2987aaa5f805ceb58932ffc7eb289e1fd [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
version: "3"
env:
KUBECONFIG:
sh: |
if test -e $($OPS -opspath "$OPS_TMP/kubeconfig")
then echo $($OPS -opspath "$OPS_TMP/kubeconfig")
else echo ~/.kube/config
fi
APIHOST:
sh: |
if test -e ~/.wskprops
then source ~/.wskprops; echo $APIHOST
fi
AUTHB64:
sh: |
if test -e ~/.wskprops
then source ~/.wskprops; echo $(base64 -e $AUTH)
fi
tasks:
# read a value, empty is not accepted
readforce:
silent: true
cmds:
- test -n "{{.VAR}}" || die "specify variable VAR="
- test -n "{{.MSG}}" || die "specify message MSG="
- |
input="{{.VAL}}"
length=${#input}
while [ "$length" -eq "0" ]; do
echo "*** Please, specify {{.MSG}} and press enter."
test -n "{{.HINT}}" && echo "{{.HINT}}"
{{if eq OS "windows"}}
input=$(powershell "(Read-Host -Prompt '{{.MSG}}')")
input=${input%?} # For some reason, powershell adds a character (\n?) at the end
{{else}}
read -p "{{.MSG}}: " input
{{end}}
length=${#input}
echo $length
done
config {{.VAR}}="$input"
# the input command is encoded as base64 to avoid parsing issues with the nuv js wrapper
ls:
desc: get the list of user buckets
silent: true
cmds:
- bun minio.js ls {{.__format}}
lsb:
desc: get the content of the specified bucket
silent: true
cmds:
- bun minio.js lsb $($OPS -base64 -e "{{._bucket_}}") {{.__format}}
rm:
desc: remove a file from the specified bucket
silent: true
cmds:
- bun minio.js rm $($OPS -base64 -e "{{._bucket_}}") $($OPS -base64 -e "{{._file_}}")
mv:
desc: move a file between buckets renaming it
silent: true
cmds:
- bun minio.js mv $($OPS -base64 -e "{{._bucket_}}") $($OPS -base64 -e "{{._file_}}") $($OPS -base64 -e "{{._dest_bucket_}}") $($OPS -base64 -e "{{._dest_file_}}")
cp:
desc: copy a file between buckets renaming it
silent: true
cmds:
- bun minio.js cp $($OPS -base64 -e "{{._bucket_}}") $($OPS -base64 -e "{{._file_}}") $($OPS -base64 -e "{{._dest_bucket_}}") $($OPS -base64 -e "{{._dest_file_}}")
put:
desc: upload a local file
silent: true
cmds:
- bun minio.js put $($OPS -base64 -e "{{._localfile_}}") $($OPS -base64 -e "{{._bucket_}}") $($OPS -base64 -e "{{._file_}}")
get:
desc: download a local file
silent: true
cmds:
- bun minio.js get $($OPS -base64 -e "{{._bucket_}}") $($OPS -base64 -e "{{._file_}}")
clean:
desc: removes matching file from the specified patterns
silent: true
vars:
PATTERN:
sh: |
if [ -z "{{._regexp_}}" ]
then echo ".*"
else echo "{{._regexp_}}"
fi
DRY_RUN:
sh: |
if {{ .__dryrun }}
then echo "true"
else echo "false"
fi
cmds:
- bun minio.js clean $($OPS -base64 -e "{{._bucket_}}") $($OPS -base64 -e "{{.PATTERN}}") $($OPS -base64 -e "{{.DRY_RUN}}")