Sha256: 9c0bcd202971f11e533aac430f804c447c7616a81db6d5421fc0d03fc082fd46

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require_relative 'ionoscloud_base'

class Chef
  class Knife
    class IonoscloudKubeconfigGet < Knife
      include Knife::IonoscloudBase

      banner 'knife ionoscloud kubeconfig get (options)'

      option :cluster_id,
              short: '-C CLUSTER_ID',
              long: '--cluster-id CLUSTER_ID',
              description: 'The ID of the Kubernetes cluster.'

      def initialize(args = [])
        super(args)
        @description =
        'Retrieve the kubeconfig file for a given Kubernetes cluster.'
        @directory = 'kubernetes'
        @required_options = [:cluster_id, :ionoscloud_username, :ionoscloud_password]
      end

      def run
        $stdout.sync = true
        handle_extra_config
        validate_required_params(@required_options, config)

        begin
          puts Ionoscloud::KubernetesApi.new(api_client).k8s_kubeconfig_get(config[:cluster_id])
        rescue Ionoscloud::ApiError => err
          raise err unless err.code == 404
          ui.error("K8s Cluster ID #{config[:cluster_id]} not found.")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
knife-ionoscloud-6.1.1 lib/chef/knife/ionoscloud_kubeconfig_get.rb
knife-ionoscloud-6.1.0 lib/chef/knife/ionoscloud_kubeconfig_get.rb