1- /*
2- This file contains definition for the following functions.
3-
4- terraformPreModifications is used to modify the container definitions passed to the cfn patcher such that it modifies casing issues in any ECS json content so that it can be processed by the kilt patcher.
5-
6- GetValueFromTemplate is used to obtain key, value information from JSON object
7- */
8-
91package sysdig
102
113import (
@@ -39,7 +31,7 @@ func capitalize(key string) string {
3931 return string (r )
4032}
4133
42- // updateKey recursively capitalizes the first letter of each key in the input object
34+ // updateKeys recursively capitalizes the first letter of each key in the input object
4335func updateKeys (inputMap gabs.Container ) error {
4436 // in this case, the object is probably an array, so update each child
4537 if len (inputMap .ChildrenMap ()) == 0 {
@@ -87,7 +79,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
8779 passthrough , _ := GetValueFromTemplate (container .S ("image" ))
8880 _ , err = container .Set (passthrough , "Image" )
8981 if err != nil {
90- return nil , fmt .Errorf ("Could not update Image field: %v" , err )
82+ return nil , fmt .Errorf ("could not update Image field: %v" , err )
9183 }
9284
9385 err = container .Delete ("image" )
@@ -100,7 +92,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
10092 passthrough , _ := GetValueFromTemplate (container .S ("name" ))
10193 _ , err = container .Set (passthrough , "Name" )
10294 if err != nil {
103- return nil , fmt .Errorf ("Could not update Name field: %v" , err )
95+ return nil , fmt .Errorf ("could not update Name field: %v" , err )
10496 }
10597
10698 err = container .Delete ("name" )
@@ -115,22 +107,22 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
115107 name , _ := env .S ("name" ).Data ().(string )
116108 err = env .Delete ("name" )
117109 if err != nil {
118- return nil , fmt .Errorf ("Could not delete \" name\" key in Environment: %v" , err )
110+ return nil , fmt .Errorf ("could not delete \" name\" key in Environment: %v" , err )
119111 }
120112 _ , err = env .Set (name , "Name" )
121113 if err != nil {
122- return nil , fmt .Errorf ("Could not assign \" Name\" key in Environment: %v" , err )
114+ return nil , fmt .Errorf ("could not assign \" Name\" key in Environment: %v" , err )
123115 }
124116 }
125117 if env .Exists ("value" ) {
126118 value , _ := env .S ("value" ).Data ().(string )
127119 err = env .Delete ("value" )
128120 if err != nil {
129- return nil , fmt .Errorf ("Could not delete \" value\" key in Environment: %v" , err )
121+ return nil , fmt .Errorf ("could not delete \" value\" key in Environment: %v" , err )
130122 }
131123 _ , err = env .Set (value , "Value" )
132124 if err != nil {
133- return nil , fmt .Errorf ("Could not assign \" Value\" key in Environment: %v" , err )
125+ return nil , fmt .Errorf ("could not assign \" Value\" key in Environment: %v" , err )
134126 }
135127 }
136128 }
@@ -139,7 +131,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
139131 parsedPassthrough , _ := gabs .ParseJSON ([]byte (passthrough ))
140132 _ , err = container .Set (parsedPassthrough , "Environment" )
141133 if err != nil {
142- return nil , fmt .Errorf ("Could not update Environment field: %v" , err )
134+ return nil , fmt .Errorf ("could not update Environment field: %v" , err )
143135 }
144136
145137 err = container .Delete ("environment" )
@@ -153,7 +145,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
153145 parsedPassthrough , _ := gabs .ParseJSON ([]byte (passthrough ))
154146 _ , err = container .Set (parsedPassthrough , "EntryPoint" )
155147 if err != nil {
156- return nil , fmt .Errorf ("Could not update EntryPoint field: %v" , err )
148+ return nil , fmt .Errorf ("could not update EntryPoint field: %v" , err )
157149 }
158150
159151 err = container .Delete ("entryPoint" )
@@ -167,7 +159,7 @@ func terraformPreModifications(ctx context.Context, patchedStack []byte) ([]byte
167159 parsedPassthrough , _ := gabs .ParseJSON ([]byte (passthrough ))
168160 _ , err = container .Set (parsedPassthrough , "Command" )
169161 if err != nil {
170- return nil , fmt .Errorf ("Could not update Command field: %v" , err )
162+ return nil , fmt .Errorf ("could not update Command field: %v" , err )
171163 }
172164
173165 err = container .Delete ("command" )
0 commit comments