---
- name: Check binaries for cilium
  command: |
    artifact_name={{ .artifact.artifact_url.cilium | splitList "/" | last }}
    artifact_path={{ .work_dir }}/kubekey/cni
    if [ ! -f $artifact_path/$artifact_name ]; then
      mkdir -p $artifact_path
      # download online
      cd $artifact_path && helm pull {{ .artifact.artifact_url.cilium }}
    fi
  when: and .cilium_version (ne .cilium_version "")

- name: Check binaries for kubeovn
  command: |
    artifact_name={{ .artifact.artifact_url.kubeovn | splitList "/" | last }}
    artifact_path={{ .work_dir }}/kubekey/cni
    if [ ! -f $artifact_path/$artifact_name ]; then
      mkdir -p $artifact_path
      # download online
      cd $artifact_path && helm pull {{ .artifact.artifact_url.kubeovn }}
    fi
  when: and .kubeovn_version (ne .kubeovn_version "")

- name: Check binaries for hybridnet
  command: |
    artifact_name={{ .artifact.artifact_url.hybridnet | splitList "/" | last }}
    artifact_path={{ .work_dir }}/kubekey/cni
    if [ ! -f $artifact_path/$artifact_name ]; then
      mkdir -p $artifact_path
      # download online
      cd $artifact_path && helm pull {{ .artifact.artifact_url.hybridnet }}
    fi
  when: and .hybridnet_version (ne .hybridnet_version "")

- name: Check binaries for nfs_provisioner
  command: |
    artifact_name={{ .artifact.artifact_url.nfs_provisioner |splitList "/" | last }}
    artifact_path={{ .work_dir }}/kubekey/sc
    if [ ! -f $artifact_path/$artifact_name ]; then
      mkdir -p $artifact_path
      # download online
      cd $artifact_path && helm pull {{ .artifact.artifact_url.nfs_provisioner }}
    fi
  when: and .nfs_provisioner_version (ne .nfs_provisioner_version "")
