Sha256: 1253138863564c4486a4687781dd007f17401686c7be0e42853038b253d88925

Contents?: true

Size: 1.3 KB

Versions: 77

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'mkmf'

module Gitlab
  module QA
    module Service
      class KubernetesCluster
        include Support::Shellout

        attr_reader :provider

        def initialize(provider_class: QA::Service::ClusterProvider::K3d)
          @provider = provider_class.new
        end

        def create!
          validate_dependencies

          @provider.validate_dependencies
          @provider.setup

          self
        end

        def remove!
          @provider.teardown
        end

        def cluster_name
          @provider.cluster_name
        end

        def to_s
          cluster_name
        end

        def create_registry_mirror
          @provider.create_registry_mirror
        end

        def create_secret(secret, secret_name)
          shell("kubectl create secret generic #{secret_name} --from-literal=token='#{secret}'", mask_secrets: [secret])
        end

        def apply_manifest(manifest)
          shell('kubectl apply -f -', stdin_data: manifest)
        end

        private

        def admin_user
          @admin_user ||= "#{@provider.cluster_name}-admin"
        end

        def validate_dependencies
          find_executable('kubectl') || raise("You must first install `kubectl` executable to run these tests.")
        end
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
gitlab-qa-8.15.2 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.15.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.15.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.14.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.14.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.13.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.13.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.12.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.11.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.10.2 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.10.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.10.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.9.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.8.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.7.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.6.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-8.5.0 lib/gitlab/qa/service/kubernetes_cluster.rb