comparison pkg/models/intservices.go @ 1327:cabf4789e02b

To make golint happier made context.Context to be the first argument of auth.RunAs.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 25 Nov 2018 15:56:07 +0100
parents 9f7dc950ffd2
children dfe9cde6a20c
comparison
equal deleted inserted replaced
1326:515815565bd0 1327:cabf4789e02b
57 57
58 var InternalServices = &IntServices{} 58 var InternalServices = &IntServices{}
59 59
60 func (e *IntEntry) LoadStyle() (string, error) { 60 func (e *IntEntry) LoadStyle() (string, error) {
61 var style string 61 var style string
62 err := auth.RunAs("sys_admin", context.Background(), 62 ctx := context.Background()
63 err := auth.RunAs(ctx, "sys_admin",
63 func(conn *sql.Conn) error { 64 func(conn *sql.Conn) error {
64 return conn.QueryRowContext( 65 return conn.QueryRowContext(
65 context.Background(), 66 ctx,
66 selectStyleSQL, 67 selectStyleSQL,
67 e.Name).Scan(&style) 68 e.Name).Scan(&style)
68 }) 69 })
69 return style, err 70 return style, err
70 } 71 }
117 } 118 }
118 119
119 func (ps *IntServices) load() error { 120 func (ps *IntServices) load() error {
120 // make empty slice to prevent retry if slice is empty. 121 // make empty slice to prevent retry if slice is empty.
121 ps.entries = []IntEntry{} 122 ps.entries = []IntEntry{}
122 return auth.RunAs("sys_admin", context.Background(), 123 ctx := context.Background()
124 return auth.RunAs(ctx, "sys_admin",
123 func(conn *sql.Conn) error { 125 func(conn *sql.Conn) error {
124 rows, err := conn.QueryContext( 126 rows, err := conn.QueryContext(
125 context.Background(), selectServicesSQL) 127 ctx, selectServicesSQL)
126 if err != nil { 128 if err != nil {
127 return err 129 return err
128 } 130 }
129 defer rows.Close() 131 defer rows.Close()
130 for rows.Next() { 132 for rows.Next() {