...

Text file src/k8s.io/kubernetes/test/e2e/testing-manifests/flexvolume/dummy

Documentation: k8s.io/kubernetes/test/e2e/testing-manifests/flexvolume

     1#!/bin/sh
     2
     3# Copyright 2017 The Kubernetes Authors.
     4#
     5# Licensed under the Apache License, Version 2.0 (the "License");
     6# you may not use this file except in compliance with the License.
     7# You may obtain a copy of the License at
     8#
     9#     http://www.apache.org/licenses/LICENSE-2.0
    10#
    11# Unless required by applicable law or agreed to in writing, software
    12# distributed under the License is distributed on an "AS IS" BASIS,
    13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14# See the License for the specific language governing permissions and
    15# limitations under the License.
    16
    17# This driver implements a tmpfs with a pre-populated file index.html.
    18
    19FLEX_DUMMY_LOG=${FLEX_DUMMY_LOG:-"/tmp/flex-dummy.log"}
    20
    21log() {
    22	printf "$*" >&1
    23}
    24
    25debug() {
    26	echo "$(date) $*" >> "${FLEX_DUMMY_LOG}"
    27}
    28
    29domount() {
    30	debug "domount $@"
    31	MNTPATH=$1
    32	mkdir -p ${MNTPATH} >/dev/null 2>&1
    33	mount -t tmpfs none ${MNTPATH} >/dev/null 2>&1
    34	echo "Hello from flexvolume!" >> "${MNTPATH}/index.html"
    35	log "{\"status\":\"Success\"}"
    36	exit 0
    37}
    38
    39unmount() {
    40	debug "unmount $@"
    41	MNTPATH=$1
    42	rm ${MNTPATH}/index.html >/dev/null 2>&1
    43	umount ${MNTPATH} >/dev/null 2>&1
    44	log "{\"status\":\"Success\"}"
    45	exit 0
    46}
    47
    48op=$1
    49
    50if [ "$op" = "init" ]; then
    51	debug "init $@"
    52	log "{\"status\":\"Success\",\"capabilities\":{\"attach\":false}}"
    53	exit 0
    54fi
    55
    56shift
    57
    58case "$op" in
    59	mount)
    60		domount $*
    61		;;
    62	unmount)
    63		unmount $*
    64		;;
    65	*)
    66		log "{\"status\":\"Not supported\"}"
    67		exit 0
    68esac
    69
    70exit 1

View as plain text