Class: Kuby::GKE::Kubeconfig
- Inherits:
-
Object
- Object
- Kuby::GKE::Kubeconfig
- Defined in:
- lib/kuby/gke/kubeconfig.rb
Instance Attribute Summary collapse
-
#ca_cert ⇒ Object
readonly
Returns the value of attribute ca_cert.
-
#cluster_name ⇒ Object
readonly
Returns the value of attribute cluster_name.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(project_id:, cluster_name:, zone:, endpoint:, ca_cert:) ⇒ Kubeconfig
constructor
A new instance of Kubeconfig.
Constructor Details
#initialize(project_id:, cluster_name:, zone:, endpoint:, ca_cert:) ⇒ Kubeconfig
Returns a new instance of Kubeconfig.
18 19 20 21 22 23 24 |
# File 'lib/kuby/gke/kubeconfig.rb', line 18 def initialize(project_id:, cluster_name:, zone:, endpoint:, ca_cert:) @project_id = project_id @cluster_name = cluster_name @zone = zone @endpoint = endpoint @ca_cert = ca_cert end |
Instance Attribute Details
#ca_cert ⇒ Object (readonly)
Returns the value of attribute ca_cert.
6 7 8 |
# File 'lib/kuby/gke/kubeconfig.rb', line 6 def ca_cert @ca_cert end |
#cluster_name ⇒ Object (readonly)
Returns the value of attribute cluster_name.
6 7 8 |
# File 'lib/kuby/gke/kubeconfig.rb', line 6 def cluster_name @cluster_name end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/kuby/gke/kubeconfig.rb', line 6 def endpoint @endpoint end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
6 7 8 |
# File 'lib/kuby/gke/kubeconfig.rb', line 6 def project_id @project_id end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
6 7 8 |
# File 'lib/kuby/gke/kubeconfig.rb', line 6 def zone @zone end |
Class Method Details
.from(config:, cluster_def:) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/kuby/gke/kubeconfig.rb', line 8 def self.from(config:, cluster_def:) new( project_id: config.project_id, cluster_name: config.cluster_name, zone: config.zone, endpoint: cluster_def['endpoint'], ca_cert: cluster_def['master_auth']['cluster_ca_certificate'] ) end |
Instance Method Details
#generate ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kuby/gke/kubeconfig.rb', line 26 def generate { "apiVersion" => "v1", "kind" => "Config", "clusters" => clusters, "contexts" => contexts, "current-context" => id_triple, "preferences" => {}, "users" => users } end |