#!/bin/bash completion for oci-cluster-upgrade-openstack-release

_oci_cluster_upgrade_openstack_release() {
	local cur prev cmd_name
	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"

	case ${COMP_CWORD} in
	1)
		local cluster_list=$(ocicli -csv cluster-list | grep -v "id,name,domain" | cut -d, -f2 | tr \\n " ")
		COMPREPLY=( $(compgen -W "${cluster_list}" -- ${cur}) )
		return 0
	;;
	2)
		COMPREPLY=( $(compgen -W "victoria wallaby xena yoga zed antelope bobcat caracal dalmatian epoxy flamingo gazpacho" -- ${cur}) )
		return 0
	;;
	3)
		case ${prev} in
		"victoria")
			COMPREPLY=( $(compgen -W "wallaby" -- ${cur}) )
		;;
		"wallaby")
			COMPREPLY=( $(compgen -W "xena" -- ${cur}) )
		;;
		"xena")
			COMPREPLY=( $(compgen -W "yoga" -- ${cur}) )
		;;
		"yoga")
			COMPREPLY=( $(compgen -W "zed" -- ${cur}) )
		;;
		"zed")
			COMPREPLY=( $(compgen -W "antelope" -- ${cur}) )
		;;
		"antelope")
			COMPREPLY=( $(compgen -W "bobcat caracal" -- ${cur}) )
		;;
		"bobcat")
			COMPREPLY=( $(compgen -W "caracal" -- ${cur}) )
		;;
		"caracal")
			COMPREPLY=( $(compgen -W "dalmatian epoxy" -- ${cur}) )
		;;
		"epoxy")
			COMPREPLY=( $(compgen -W "flamingo gazpacho" -- ${cur}) )
		;;
		"flamingo")
			COMPREPLY=( $(compgen -W "gazpacho" -- ${cur}) )
		;;
		*)
			return 0
		;;
		esac
	;;
	*)
		return 0
	;;
	esac
	
}

complete -F _oci_cluster_upgrade_openstack_release oci-cluster-upgrade-openstack-release
