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-14.3.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-14.2.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-14.2.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-14.1.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-14.0.2 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-14.0.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-14.0.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-13.2.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-13.2.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-13.1.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-13.0.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-12.5.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-12.5.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-12.4.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-12.4.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-12.3.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-10.3.0.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-12.2.1 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-12.2.0 lib/gitlab/qa/service/kubernetes_cluster.rb
gitlab-qa-12.1.0 lib/gitlab/qa/service/kubernetes_cluster.rb