@@ -43,29 +43,29 @@ func init() {
4343
4444// initialize does common initialization actions between cluster operations
4545// and returns created objects to the caller for further use.
46- func initialize (ctxLogger * logrus.Entry ) (* terraform.Executor , platform.Platform , * config.Config , string ) {
46+ func initialize (contextLogger * logrus.Entry ) (* terraform.Executor , platform.Platform , * config.Config , string ) {
4747 lokoConfig , diags := getLokoConfig ()
4848 if len (diags ) > 0 {
49- ctxLogger .Fatal (diags )
49+ contextLogger .Fatal (diags )
5050 }
5151
5252 p , diags := getConfiguredPlatform (lokoConfig , true )
5353 if diags .HasErrors () {
5454 for _ , diagnostic := range diags {
55- ctxLogger .Error (diagnostic .Error ())
55+ contextLogger .Error (diagnostic .Error ())
5656 }
5757
58- ctxLogger .Fatal ("Errors found while loading cluster configuration" )
58+ contextLogger .Fatal ("Errors found while loading cluster configuration" )
5959 }
6060
6161 // Get the configured backend for the cluster. Backend types currently supported: local, s3.
6262 b , diags := getConfiguredBackend (lokoConfig )
6363 if diags .HasErrors () {
6464 for _ , diagnostic := range diags {
65- ctxLogger .Error (diagnostic .Error ())
65+ contextLogger .Error (diagnostic .Error ())
6666 }
6767
68- ctxLogger .Fatal ("Errors found while loading cluster configuration" )
68+ contextLogger .Fatal ("Errors found while loading cluster configuration" )
6969 }
7070
7171 // Use a local backend if no backend is configured.
@@ -75,36 +75,36 @@ func initialize(ctxLogger *logrus.Entry) (*terraform.Executor, platform.Platform
7575
7676 assetDir , err := homedir .Expand (p .Meta ().AssetDir )
7777 if err != nil {
78- ctxLogger .Fatalf ("Error expanding path: %v" , err )
78+ contextLogger .Fatalf ("Error expanding path: %v" , err )
7979 }
8080
8181 // Validate backend configuration.
8282 if err = b .Validate (); err != nil {
83- ctxLogger .Fatalf ("Failed to validate backend configuration: %v" , err )
83+ contextLogger .Fatalf ("Failed to validate backend configuration: %v" , err )
8484 }
8585
86- ex := initializeTerraform (ctxLogger , p , b )
86+ ex := initializeTerraform (contextLogger , p , b )
8787
8888 return ex , p , lokoConfig , assetDir
8989}
9090
9191// initializeTerraform initialized Terraform directory using given backend and platform
9292// and returns configured executor.
93- func initializeTerraform (ctxLogger * logrus.Entry , p platform.Platform , b backend.Backend ) * terraform.Executor {
93+ func initializeTerraform (contextLogger * logrus.Entry , p platform.Platform , b backend.Backend ) * terraform.Executor {
9494 assetDir , err := homedir .Expand (p .Meta ().AssetDir )
9595 if err != nil {
96- ctxLogger .Fatalf ("Error expanding path: %v" , err )
96+ contextLogger .Fatalf ("Error expanding path: %v" , err )
9797 }
9898
9999 // Render backend configuration.
100100 renderedBackend , err := b .Render ()
101101 if err != nil {
102- ctxLogger .Fatalf ("Failed to render backend configuration file: %v" , err )
102+ contextLogger .Fatalf ("Failed to render backend configuration file: %v" , err )
103103 }
104104
105105 // Configure Terraform directory, module and backend.
106106 if err := terraform .Configure (assetDir , renderedBackend ); err != nil {
107- ctxLogger .Fatalf ("Failed to configure Terraform : %v" , err )
107+ contextLogger .Fatalf ("Failed to configure Terraform : %v" , err )
108108 }
109109
110110 conf := terraform.Config {
@@ -114,15 +114,15 @@ func initializeTerraform(ctxLogger *logrus.Entry, p platform.Platform, b backend
114114
115115 ex , err := terraform .NewExecutor (conf )
116116 if err != nil {
117- ctxLogger .Fatalf ("Failed to create Terraform executor: %v" , err )
117+ contextLogger .Fatalf ("Failed to create Terraform executor: %v" , err )
118118 }
119119
120120 if err := p .Initialize (ex ); err != nil {
121- ctxLogger .Fatalf ("Failed to initialize Platform: %v" , err )
121+ contextLogger .Fatalf ("Failed to initialize Platform: %v" , err )
122122 }
123123
124124 if err := ex .Init (); err != nil {
125- ctxLogger .Fatalf ("Failed to initialize Terraform: %v" , err )
125+ contextLogger .Fatalf ("Failed to initialize Terraform: %v" , err )
126126 }
127127
128128 return ex
@@ -131,21 +131,21 @@ func initializeTerraform(ctxLogger *logrus.Entry, p platform.Platform, b backend
131131// clusterExists determines if cluster has already been created by getting all
132132// outputs from the Terraform. If there is any output defined, it means 'terraform apply'
133133// run at least once.
134- func clusterExists (ctxLogger * logrus.Entry , ex * terraform.Executor ) bool {
134+ func clusterExists (contextLogger * logrus.Entry , ex * terraform.Executor ) bool {
135135 o := map [string ]interface {}{}
136136
137137 if err := ex .Output ("" , & o ); err != nil {
138- ctxLogger .Fatalf ("Failed to check if cluster exists: %v" , err )
138+ contextLogger .Fatalf ("Failed to check if cluster exists: %v" , err )
139139 }
140140
141141 return len (o ) != 0
142142}
143143
144144type controlplaneUpdater struct {
145- kubeconfig []byte
146- assetDir string
147- ctxLogger logrus.Entry
148- ex terraform.Executor
145+ kubeconfig []byte
146+ assetDir string
147+ contextLogger logrus.Entry
148+ ex terraform.Executor
149149}
150150
151151func (c controlplaneUpdater ) getControlplaneChart (name string ) (* chart.Chart , error ) {
@@ -176,29 +176,29 @@ func (c controlplaneUpdater) getControlplaneValues(name string) (map[string]inte
176176}
177177
178178func (c controlplaneUpdater ) upgradeComponent (component , namespace string ) {
179- ctxLogger := c .ctxLogger .WithFields (logrus.Fields {
179+ contextLogger := c .contextLogger .WithFields (logrus.Fields {
180180 "action" : "controlplane-upgrade" ,
181181 "component" : component ,
182182 })
183183
184184 actionConfig , err := util .HelmActionConfig (namespace , c .kubeconfig )
185185 if err != nil {
186- ctxLogger .Fatalf ("Failed initializing helm: %v" , err )
186+ contextLogger .Fatalf ("Failed initializing helm: %v" , err )
187187 }
188188
189189 helmChart , err := c .getControlplaneChart (component )
190190 if err != nil {
191- ctxLogger .Fatalf ("Loading chart from assets failed: %v" , err )
191+ contextLogger .Fatalf ("Loading chart from assets failed: %v" , err )
192192 }
193193
194194 values , err := c .getControlplaneValues (component )
195195 if err != nil {
196- ctxLogger .Fatalf ("Failed to get kubernetes values.yaml from Terraform: %v" , err )
196+ contextLogger .Fatalf ("Failed to get kubernetes values.yaml from Terraform: %v" , err )
197197 }
198198
199199 exists , err := util .ReleaseExists (* actionConfig , component )
200200 if err != nil {
201- ctxLogger .Fatalf ("Failed checking if controlplane component is installed: %v" , err )
201+ contextLogger .Fatalf ("Failed checking if controlplane component is installed: %v" , err )
202202 }
203203
204204 if ! exists {
@@ -213,7 +213,7 @@ func (c controlplaneUpdater) upgradeComponent(component, namespace string) {
213213 if _ , err := install .Run (helmChart , values ); err != nil {
214214 fmt .Println ("Failed!" )
215215
216- ctxLogger .Fatalf ("Installing controlplane component failed: %v" , err )
216+ contextLogger .Fatalf ("Installing controlplane component failed: %v" , err )
217217 }
218218
219219 fmt .Println ("Done." )
@@ -228,7 +228,7 @@ func (c controlplaneUpdater) upgradeComponent(component, namespace string) {
228228 if _ , err := update .Run (component , helmChart , values ); err != nil {
229229 fmt .Println ("Failed!" )
230230
231- ctxLogger .Fatalf ("Updating chart failed: %v" , err )
231+ contextLogger .Fatalf ("Updating chart failed: %v" , err )
232232 }
233233
234234 fmt .Println ("Done." )
0 commit comments