Skip to content

Commit

Permalink
reuse ctapi from collection to project
Browse files Browse the repository at this point in the history
  • Loading branch information
wr0ngway committed Mar 29, 2023
1 parent 00155db commit 410d1a7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions lib/kubetruth/project.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
module Kubetruth
Project = Struct.new(:name, :spec, :collection, keyword_init: true) do
Project = Struct.new(:name, :spec, :collection, :ctapi, keyword_init: true) do

include GemLogger::LoggerSupport

def ctapi
@ctapi ||= Kubetruth::CtApi.new(environment: spec.environment, tag: spec.tag)
end

def parameters
@parameters ||= begin
params = ctapi.parameters(project: name)
Expand Down
2 changes: 1 addition & 1 deletion lib/kubetruth/project_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def names
end

def create_project(*args, **kwargs)
project = Project.new(*args, **kwargs, collection: self)
project = Project.new(*args, **kwargs, collection: self, ctapi: ctapi)
projects[project.name] = project
project
end
Expand Down
2 changes: 1 addition & 1 deletion spec/kubetruth/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Kubetruth
describe "#initialize" do

it "creates from kwargs" do
data = {name: "name1", spec: Kubetruth::Config::ProjectSpec.new, collection: collection}
data = {name: "name1", spec: Kubetruth::Config::ProjectSpec.new, collection: collection, ctapi: double()}
proj = described_class.new(**data)
expect(proj.to_h).to eq(data)
end
Expand Down

0 comments on commit 410d1a7

Please sign in to comment.