@@ -39,7 +39,7 @@ def initialize
3939
4040 def self . create
4141 instance = self . new
42-
42+
4343 instance . supporting_services . each do |svc |
4444 instance . create_supporting_manifests ( svc )
4545 end
@@ -48,7 +48,7 @@ def self.create
4848 instance . create_flux_manifest if $opts[ :flux ]
4949
5050 return instance . dry_run if $opts[ :dry_run ]
51-
51+
5252 instance . commit_overlay_to_github
5353 puts 'Done!'
5454 end
@@ -59,15 +59,15 @@ def supporting_services
5959
6060 def create_namespace_manifest
6161 return puts "Using existing namespace '#{ namespace } '" unless include_namespace?
62-
62+
6363 puts "Creating namespace '#{ namespace } '..."
6464 $templates << Templates ::Namespace . new ( service : service , namespace : namespace )
6565 end
6666
6767 def create_primary_manifests
6868 puts "Creating #{ service } manifests with #{ $opts[ :target_image ] } :#{ $opts[ :tag ] } ..."
6969 # check each type of file for the service we're updating, and create an overlay
70-
70+
7171 $templates << Templates ::Ingress . new ( service : service , namespace : namespace , hosts : base_ingress_hosts ( service ) ) if include_ingress? ( service )
7272 $templates << Templates ::Kustomization . new ( service : service , namespace : namespace , img : true )
7373 end
@@ -77,15 +77,15 @@ def create_flux_manifest
7777 services . each do |svc |
7878 generators << { 'command' => "kustomize build ./#{ svc } /overlays/#{ namespace } " }
7979 end
80- generators . uniq
81- $templates << Templates ::Flux . new ( service : service , namespace : namespace , generators : generators )
80+
81+ $templates << Templates ::Flux . new ( service : service , namespace : namespace , generators : generators . uniq )
8282 end
8383
84- def create_supporting_manifests ( svc )
84+ def create_supporting_manifests ( svc )
8585 return puts "Using existing manifests for #{ svc } " unless create_overlay? ( svc )
8686
8787 puts "Creating #{ svc } manifests pointing to #{ svc } .default.svc.cluster.local..."
88-
88+
8989 $templates << Templates ::Ingress . new ( service : svc , namespace : namespace , hosts : base_ingress_hosts ( svc ) ) if include_ingress? ( svc )
9090 $templates << Templates ::Service . new ( service : svc , namespace : namespace ) if include_service? ( svc )
9191 $templates << Templates ::Kustomization . new ( service : svc , namespace : namespace , svc : true )
@@ -95,11 +95,11 @@ def commit_overlay_to_github
9595 puts "Creating overlays for '#{ namespace } ' in GitHub repository #{ repo } ..."
9696 ref = 'heads/master'
9797 sha_latest_commit = client . ref ( repo , ref ) . object . sha
98-
98+
9999 sha_base_tree = client . commit ( repo , sha_latest_commit ) . commit . tree . sha
100-
100+
101101 sha_new_tree = client . create_tree ( repo , new_blobs , { base_tree : sha_base_tree } ) . sha
102-
102+
103103 commit_message = "Create #{ service } in namespace '#{ namespace } ' with image #{ $opts[ :target_image ] } :#{ $opts[ :tag ] } "
104104 sha_new_commit = client . create_commit ( repo , commit_message , sha_new_tree , sha_latest_commit ) . sha
105105 updated_ref = client . update_ref ( repo , ref , sha_new_commit )
@@ -120,7 +120,7 @@ def fetch_services
120120 puts "Found services #{ services } "
121121 services
122122 else
123- exit_code ( "Unknown service. Please choose one of #{ services } " , 2 )
123+ exit_code ( "Unknown service. Please choose one of #{ services } " , 2 )
124124 end
125125 end
126126
@@ -181,11 +181,11 @@ def base_ingress_hosts(svc)
181181
182182 def new_blobs
183183 $templates. map do |t |
184- {
185- path : t . path ,
186- mode : '100644' ,
187- type : 'blob' ,
188- sha : client . create_blob ( repo , Base64 . encode64 ( t . manifest . to_yaml ) , 'base64' )
184+ {
185+ path : t . path ,
186+ mode : '100644' ,
187+ type : 'blob' ,
188+ sha : client . create_blob ( repo , Base64 . encode64 ( t . manifest . to_yaml ) , 'base64' )
189189 }
190190 end
191191 end
@@ -198,7 +198,7 @@ def print_templates
198198 end
199199
200200 def print_manifests
201- services . each do |svc |
201+ services . each do |svc |
202202 base_manifests ( svc ) . each do |m |
203203 FileUtils . mkdir_p "/tmp/#{ svc } /base"
204204 File . write "/tmp/#{ m . path } " , Base64 . decode64 ( client . contents ( repo , path : m . path ) . content )
0 commit comments