Class: CDK8sPlus25::Secret

Inherits:
Resource
  • Object
show all
Includes:
ISecret
Defined in:
secret.rb

Overview

Kubernetes Secrets let you store and manage sensitive information, such as passwords, OAuth tokens, and ssh keys.

Storing confidential information in a Secret is safer and more flexible than putting it verbatim in a Pod definition or in a container image.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props = nil, &jsii_block) ⇒ Secret

Returns a new instance of Secret.

Parameters:



18
19
20
21
22
23
24
# File 'secret.rb', line 18

def initialize(scope, id, props = nil, &jsii_block)
  props = props.is_a?(Hash) ? ::CDK8sPlus25::SecretProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(scope, "eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9", "scope")
  Jsii::Type.check_type(id, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "id")
  Jsii::Type.check_type(props, "eyJmcW4iOiJjZGs4cy1wbHVzLTI1LlNlY3JldFByb3BzIn0=", "props") unless props.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props, &jsii_block)
end

Class Method Details

.from_secret_name(scope, id, name) ⇒ CDK8sPlus25::ISecret

Imports a secret from the cluster as a reference.

Parameters:

Returns:



55
56
57
58
59
60
# File 'secret.rb', line 55

def self.from_secret_name(scope, id, name)
  Jsii::Type.check_type(scope, "eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9", "scope")
  Jsii::Type.check_type(id, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "id")
  Jsii::Type.check_type(name, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "name")
  Jsii::Kernel.instance.call_static("cdk8s-plus-25.Secret", "fromSecretName", [scope, id, name])
end

.jsii_overridable_methodsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'secret.rb', line 26

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :api_group => { kind: :property, name: "apiGroup", is_optional: false },
    :api_object => { kind: :property, name: "apiObject", is_optional: false },
    :api_version => { kind: :property, name: "apiVersion", is_optional: false },
    :kind => { kind: :property, name: "kind", is_optional: false },
    :metadata => { kind: :property, name: "metadata", is_optional: false },
    :name => { kind: :property, name: "name", is_optional: false },
    :permissions => { kind: :property, name: "permissions", is_optional: false },
    :resource_type => { kind: :property, name: "resourceType", is_optional: false },
    :resource_name => { kind: :property, name: "resourceName", is_optional: true },
    :immutable => { kind: :property, name: "immutable", is_optional: false },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :as_api_resource => { kind: :method, name: "asApiResource", is_optional: false },
    :as_non_api_resource => { kind: :method, name: "asNonApiResource", is_optional: false },
    :add_string_data => { kind: :method, name: "addStringData", is_optional: false },
    :env_value => { kind: :method, name: "envValue", is_optional: false },
    :get_string_data => { kind: :method, name: "getStringData", is_optional: false },
  }
end

Instance Method Details

#add_string_data(key, value) ⇒ void

This method returns an undefined value.

Adds a string data field to the secert.

Parameters:

  • key (String)

    Key.

  • value (String)

    Value.



180
181
182
183
184
# File 'secret.rb', line 180

def add_string_data(key, value)
  Jsii::Type.check_type(key, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "key")
  Jsii::Type.check_type(value, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "value")
  jsii_call_method("addStringData", [key, value])
end

#api_groupString

The group portion of the API version (e.g. "authorization.k8s.io").

Returns:

  • (String)


72
73
74
# File 'secret.rb', line 72

def api_group()
  jsii_get_property("apiGroup")
end

#api_objectCDK8s::APIObject

The underlying cdk8s API object.

Returns:

See Also:

  • CDK8sPlus25::Secret.basebase.Resourcebase.Resource.apiObject


80
81
82
# File 'secret.rb', line 80

def api_object()
  jsii_get_property("apiObject")
end

#api_versionString

The object's API version (e.g. "authorization.k8s.io/v1").

Returns:

  • (String)


87
88
89
# File 'secret.rb', line 87

def api_version()
  jsii_get_property("apiVersion")
end

#as_api_resourceCDK8sPlus25::IAPIResource?

Return the IApiResource this object represents.

Returns:



164
165
166
# File 'secret.rb', line 164

def as_api_resource()
  jsii_call_method("asApiResource", [])
end

#as_non_api_resourceString?

Return the non resource url this object represents.

Returns:

  • (String, nil)


171
172
173
# File 'secret.rb', line 171

def as_non_api_resource()
  jsii_call_method("asNonApiResource", [])
end

#env_value(key, options = nil) ⇒ CDK8sPlus25::EnvValue

Returns EnvValue object from a secret's key.

Parameters:

Returns:



191
192
193
194
195
196
# File 'secret.rb', line 191

def env_value(key, options = nil)
  Jsii::Type.check_type(key, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "key")
  options = options.is_a?(Hash) ? ::CDK8sPlus25::EnvValueFromSecretOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, "eyJmcW4iOiJjZGs4cy1wbHVzLTI1LkVudlZhbHVlRnJvbVNlY3JldE9wdGlvbnMifQ==", "options") unless options.nil?
  jsii_call_method("envValue", [key, options])
end

#get_string_data(key) ⇒ String?

Gets a string data by key or undefined.

Parameters:

  • key (String)

    Key.

Returns:

  • (String, nil)


202
203
204
205
# File 'secret.rb', line 202

def get_string_data(key)
  Jsii::Type.check_type(key, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "key")
  jsii_call_method("getStringData", [key])
end

#immutableBoolean

Whether or not the secret is immutable.

Returns:

  • (Boolean)


134
135
136
# File 'secret.rb', line 134

def immutable()
  jsii_get_property("immutable")
end

#kindString

The object kind (e.g. "Deployment").

Returns:

  • (String)


94
95
96
# File 'secret.rb', line 94

def kind()
  jsii_get_property("kind")
end

#metadataCDK8s::APIObjectMetadataDefinition



99
100
101
# File 'secret.rb', line 99

def ()
  jsii_get_property("metadata")
end

#nameString

The name of this API object.

Returns:

  • (String)


106
107
108
# File 'secret.rb', line 106

def name()
  jsii_get_property("name")
end

#nodeConstructs::Node

The tree node.

Returns:



65
66
67
# File 'secret.rb', line 65

def node()
  jsii_get_property("node")
end

#permissionsCDK8sPlus25::ResourcePermissions



111
112
113
# File 'secret.rb', line 111

def permissions()
  jsii_get_property("permissions")
end

#resource_nameString?

The unique, namespace-global, name of an object inside the Kubernetes cluster.

If this is omitted, the ApiResource should represent all objects of the given type.

Returns:

  • (String, nil)


127
128
129
# File 'secret.rb', line 127

def resource_name()
  jsii_get_property("resourceName")
end

#resource_typeString

The name of a resource type as it appears in the relevant API endpoint.

Returns:

  • (String)


118
119
120
# File 'secret.rb', line 118

def resource_type()
  jsii_get_property("resourceType")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


141
142
143
# File 'secret.rb', line 141

def to_string()
  jsii_call_method("toString", [])
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

Returns:



154
155
156
157
158
159
# File 'secret.rb', line 154

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, "eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9", "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end