k8s.io/kubernetes@v1.29.3/test/e2e/testing-manifests/flexvolume/dummy (about)

     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  
    19  FLEX_DUMMY_LOG=${FLEX_DUMMY_LOG:-"/tmp/flex-dummy.log"}
    20  
    21  log() {
    22  	printf "$*" >&1
    23  }
    24  
    25  debug() {
    26  	echo "$(date) $*" >> "${FLEX_DUMMY_LOG}"
    27  }
    28  
    29  domount() {
    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  
    39  unmount() {
    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  
    48  op=$1
    49  
    50  if [ "$op" = "init" ]; then
    51  	debug "init $@"
    52  	log "{\"status\":\"Success\",\"capabilities\":{\"attach\":false}}"
    53  	exit 0
    54  fi
    55  
    56  shift
    57  
    58  case "$op" in
    59  	mount)
    60  		domount $*
    61  		;;
    62  	unmount)
    63  		unmount $*
    64  		;;
    65  	*)
    66  		log "{\"status\":\"Not supported\"}"
    67  		exit 0
    68  esac
    69  
    70  exit 1