@@ -39,7 +39,7 @@ def initialize
39
39
40
40
def self . create
41
41
instance = self . new
42
-
42
+
43
43
instance . supporting_services . each do |svc |
44
44
instance . create_supporting_manifests ( svc )
45
45
end
@@ -48,7 +48,7 @@ def self.create
48
48
instance . create_flux_manifest if $opts[ :flux ]
49
49
50
50
return instance . dry_run if $opts[ :dry_run ]
51
-
51
+
52
52
instance . commit_overlay_to_github
53
53
puts 'Done!'
54
54
end
@@ -59,15 +59,15 @@ def supporting_services
59
59
60
60
def create_namespace_manifest
61
61
return puts "Using existing namespace '#{ namespace } '" unless include_namespace?
62
-
62
+
63
63
puts "Creating namespace '#{ namespace } '..."
64
64
$templates << Templates ::Namespace . new ( service : service , namespace : namespace )
65
65
end
66
66
67
67
def create_primary_manifests
68
68
puts "Creating #{ service } manifests with #{ $opts[ :target_image ] } :#{ $opts[ :tag ] } ..."
69
69
# check each type of file for the service we're updating, and create an overlay
70
-
70
+
71
71
$templates << Templates ::Ingress . new ( service : service , namespace : namespace , hosts : base_ingress_hosts ( service ) ) if include_ingress? ( service )
72
72
$templates << Templates ::Kustomization . new ( service : service , namespace : namespace , img : true )
73
73
end
@@ -77,15 +77,15 @@ def create_flux_manifest
77
77
services . each do |svc |
78
78
generators << { 'command' => "kustomize build ./#{ svc } /overlays/#{ namespace } " }
79
79
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 )
82
82
end
83
83
84
- def create_supporting_manifests ( svc )
84
+ def create_supporting_manifests ( svc )
85
85
return puts "Using existing manifests for #{ svc } " unless create_overlay? ( svc )
86
86
87
87
puts "Creating #{ svc } manifests pointing to #{ svc } .default.svc.cluster.local..."
88
-
88
+
89
89
$templates << Templates ::Ingress . new ( service : svc , namespace : namespace , hosts : base_ingress_hosts ( svc ) ) if include_ingress? ( svc )
90
90
$templates << Templates ::Service . new ( service : svc , namespace : namespace ) if include_service? ( svc )
91
91
$templates << Templates ::Kustomization . new ( service : svc , namespace : namespace , svc : true )
@@ -95,11 +95,11 @@ def commit_overlay_to_github
95
95
puts "Creating overlays for '#{ namespace } ' in GitHub repository #{ repo } ..."
96
96
ref = 'heads/master'
97
97
sha_latest_commit = client . ref ( repo , ref ) . object . sha
98
-
98
+
99
99
sha_base_tree = client . commit ( repo , sha_latest_commit ) . commit . tree . sha
100
-
100
+
101
101
sha_new_tree = client . create_tree ( repo , new_blobs , { base_tree : sha_base_tree } ) . sha
102
-
102
+
103
103
commit_message = "Create #{ service } in namespace '#{ namespace } ' with image #{ $opts[ :target_image ] } :#{ $opts[ :tag ] } "
104
104
sha_new_commit = client . create_commit ( repo , commit_message , sha_new_tree , sha_latest_commit ) . sha
105
105
updated_ref = client . update_ref ( repo , ref , sha_new_commit )
@@ -120,7 +120,7 @@ def fetch_services
120
120
puts "Found services #{ services } "
121
121
services
122
122
else
123
- exit_code ( "Unknown service. Please choose one of #{ services } " , 2 )
123
+ exit_code ( "Unknown service. Please choose one of #{ services } " , 2 )
124
124
end
125
125
end
126
126
@@ -181,11 +181,11 @@ def base_ingress_hosts(svc)
181
181
182
182
def new_blobs
183
183
$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' )
189
189
}
190
190
end
191
191
end
@@ -198,7 +198,7 @@ def print_templates
198
198
end
199
199
200
200
def print_manifests
201
- services . each do |svc |
201
+ services . each do |svc |
202
202
base_manifests ( svc ) . each do |m |
203
203
FileUtils . mkdir_p "/tmp/#{ svc } /base"
204
204
File . write "/tmp/#{ m . path } " , Base64 . decode64 ( client . contents ( repo , path : m . path ) . content )
0 commit comments