Skip to content

Commit

Permalink
Avoids altering KubernetesResource#initialize method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Mar 4, 2019
1 parent 55afa20 commit aef5ae3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
3 changes: 1 addition & 2 deletions lib/kubernetes-deploy/ejson_secret_provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ def generate_secret_resource(secret_name, secret_type, data)

KubernetesDeploy::Secret.build(
namespace: @namespace, context: @context, logger: @logger, definition: secret, statsd_tags: @statsd_tags,
source: "ejson",
)
).tap { |r| r.source = "ejson" }
end

def load_ejson_from_file
Expand Down
9 changes: 4 additions & 5 deletions lib/kubernetes-deploy/kubernetes_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module KubernetesDeploy
class KubernetesResource
attr_reader :name, :namespace, :context
attr_writer :type, :deploy_started_at
attr_writer :type, :deploy_started_at, :source

GLOBAL = false
TIMEOUT = 5.minutes
Expand All @@ -32,9 +32,9 @@ class KubernetesResource
KUBECTL_OUTPUT_IS_SENSITIVE = false

class << self
def build(namespace:, context:, definition:, logger:, statsd_tags:, crd: nil, source: nil)
def build(namespace:, context:, definition:, logger:, statsd_tags:, crd: nil)
opts = { namespace: namespace, context: context, definition: definition, logger: logger,
statsd_tags: statsd_tags, source: source }
statsd_tags: statsd_tags }
if definition["kind"].blank?
raise InvalidTemplateError.new("Template missing 'Kind'", content: definition.to_yaml)
end
Expand Down Expand Up @@ -83,7 +83,7 @@ def pretty_timeout_type
"timeout: #{timeout}s"
end

def initialize(namespace:, context:, definition:, logger:, statsd_tags: [], source: nil)
def initialize(namespace:, context:, definition:, logger:, statsd_tags: [])
# subclasses must also set these if they define their own initializer
@name = definition.dig("metadata", "name")
unless @name.present?
Expand All @@ -100,7 +100,6 @@ def initialize(namespace:, context:, definition:, logger:, statsd_tags: [], sour
@disappeared = false
@validation_errors = []
@instance_data = {}
@source = source
end

def to_kubeclient_resource
Expand Down
4 changes: 2 additions & 2 deletions lib/kubernetes-deploy/kubernetes_resource/custom_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class CustomResource < KubernetesResource
(.metadata.generation != .status.observedGeneration).
MSG

def initialize(namespace:, context:, definition:, logger:, statsd_tags: [], crd:, source: nil)
def initialize(namespace:, context:, definition:, logger:, statsd_tags: [], crd:)
super(namespace: namespace, context: context, definition: definition,
logger: logger, statsd_tags: statsd_tags, source: source)
logger: logger, statsd_tags: statsd_tags)
@crd = crd
end

Expand Down
4 changes: 2 additions & 2 deletions lib/kubernetes-deploy/kubernetes_resource/pod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Pod < KubernetesResource
)

def initialize(namespace:, context:, definition:, logger:,
statsd_tags: nil, parent: nil, deploy_started_at: nil, stream_logs: false, source: nil)
statsd_tags: nil, parent: nil, deploy_started_at: nil, stream_logs: false)
@parent = parent
@deploy_started_at = deploy_started_at

Expand All @@ -22,7 +22,7 @@ def initialize(namespace:, context:, definition:, logger:,
@containers += definition["spec"].fetch("initContainers", []).map { |c| Container.new(c, init_container: true) }
@stream_logs = stream_logs
super(namespace: namespace, context: context, definition: definition,
logger: logger, statsd_tags: statsd_tags, source: source)
logger: logger, statsd_tags: statsd_tags)
end

def sync(_cache)
Expand Down
4 changes: 2 additions & 2 deletions lib/kubernetes-deploy/kubernetes_resource/replica_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class ReplicaSet < PodSetBase
attr_reader :pods

def initialize(namespace:, context:, definition:, logger:, statsd_tags: nil,
parent: nil, deploy_started_at: nil, source: nil)
parent: nil, deploy_started_at: nil)
@parent = parent
@deploy_started_at = deploy_started_at
@pods = []
super(namespace: namespace, context: context, definition: definition,
logger: logger, statsd_tags: statsd_tags, source: source)
logger: logger, statsd_tags: statsd_tags)
end

def sync(cache)
Expand Down

0 comments on commit aef5ae3

Please sign in to comment.