@@ -22,16 +22,22 @@ import (
22
22
23
23
var pingPollingFreq = 5 * time .Second
24
24
25
- //handlerSqlConnexion is a type of variable to help us manage our connexion to the SQL databases
26
- type handlerSqlConnexion struct {
25
+ // Important GOTCHA
26
+ // See https://stackoverflow.com/questions/24487943/invoking-struct-function-gives-cannot-refer-to-unexported-field-or-method
27
+ // An identifier may be exported to permit access to it from another package. An identifier is exported if both:
28
+ // - the first character of the identifier's name is a Unicode upper case letter (Unicode class "Lu"); and
29
+ // - the identifier is declared in the package block or it is a field name or method name.
30
+
31
+ //HandlerSqlConnexion is a type of variable to help us manage our connexion to the SQL databases
32
+ type HandlerSqlConnexion struct {
27
33
DSN string // aurora database connection string
28
34
APIAccessToken string
29
35
db * sql.DB
30
36
environmentId int
31
37
}
32
38
33
- // environment is a type of variable to help us manage our differing {dev,demo,prod} AWS accounts
34
- type environment struct {
39
+ // Environment is a type of variable to help us manage our differing {dev,demo,prod} AWS accounts
40
+ type Environment struct {
35
41
environmentId int
36
42
Cfg aws.Config
37
43
AccountID string
@@ -49,7 +55,7 @@ const (
49
55
// GetSecret is the Golang equivalent for
50
56
// aws --profile your-aws-cli-profile ssm get-parameters --names API_ACCESS_TOKEN --with-decryption --query Parameters[0].Value --output text
51
57
52
- func (thisEnvironment environment ) GetSecret (key string ) string {
58
+ func (thisEnvironment Environment ) GetSecret (key string ) string {
53
59
54
60
val , ok := os .LookupEnv (key )
55
61
if ok {
@@ -75,7 +81,7 @@ func (thisEnvironment environment) GetSecret(key string) string {
75
81
// NewConfig setups the configuration assuming various parameters have been setup in the AWS account
76
82
// - DEFAULT_REGION
77
83
// - STAGE
78
- func NewConfig (cfg aws.Config ) (thisEnvironment environment , err error ) {
84
+ func NewConfig (cfg aws.Config ) (thisEnvironment Environment , err error ) {
79
85
80
86
// Save for ssm
81
87
thisEnvironment .Cfg = cfg
@@ -144,7 +150,7 @@ func NewConfig(cfg aws.Config) (thisEnvironment environment, err error) {
144
150
}
145
151
}
146
152
147
- func (thisEnvironment environment ) BugzillaDSN () string {
153
+ func (thisEnvironment Environment ) BugzillaDSN () string {
148
154
149
155
// Get the value of the variable BUGZILLA_DB_USER
150
156
var bugzillaDbUser string
@@ -232,7 +238,7 @@ func (thisEnvironment environment) BugzillaDSN() string {
232
238
233
239
// NewDbConnexion setups what we need to access the DB assuming various parameters have been setup in the AWS account
234
240
235
- func NewDbConnexion () (bzDbConnexion handlerSqlConnexion , err error ) {
241
+ func NewDbConnexion () (bzDbConnexion HandlerSqlConnexion , err error ) {
236
242
237
243
// We get the AWS configuration information for the default profile
238
244
cfg , err := external .LoadDefaultAWSConfig ()
@@ -281,7 +287,7 @@ func NewDbConnexion() (bzDbConnexion handlerSqlConnexion, err error) {
281
287
}
282
288
283
289
// We have everything --> We create the database connexion string
284
- bzDbConnexion = handlerSqlConnexion {
290
+ bzDbConnexion = HandlerSqlConnexion {
285
291
DSN : thisEnvironment .BugzillaDSN (), // `BugzillaDSN` is a function that is defined in the uneet/env/main.go dependency.
286
292
APIAccessToken : apiAccessToken ,
287
293
environmentId : thisEnvironment .environmentId ,
@@ -375,7 +381,7 @@ func Towr(currentBzConnexion http.Handler) func(http.ResponseWriter, *http.Reque
375
381
}
376
382
}
377
383
378
- func (thisEnvironment environment ) Bucket (svc string ) string {
384
+ func (thisEnvironment Environment ) Bucket (svc string ) string {
379
385
380
386
// Most common bucket
381
387
if svc == "" {
@@ -402,7 +408,7 @@ func (thisEnvironment environment) Bucket(svc string) string {
402
408
}
403
409
}
404
410
405
- func (thisEnvironment environment ) SNS (name , region string ) string {
411
+ func (thisEnvironment Environment ) SNS (name , region string ) string {
406
412
// TODO: Check: if service name is empty, should this be a fatal error???
407
413
if name == "" {
408
414
log .Warn ("SNS Warning: Service string empty" )
@@ -411,7 +417,7 @@ func (thisEnvironment environment) SNS(name, region string) string {
411
417
return fmt .Sprintf ("arn:aws:sns:%s:%s:%s" , region , thisEnvironment .AccountID , name )
412
418
}
413
419
414
- func (thisEnvironment environment ) Udomain (service string ) string {
420
+ func (thisEnvironment Environment ) Udomain (service string ) string {
415
421
if service == "" {
416
422
log .Warn ("Udomain warning:Service string empty" )
417
423
return ""
0 commit comments