MCPcopy Index your code
hub / github.com/rilldata/rill / FindProjectVariables

Method FindProjectVariables

admin/database/postgres/postgres.go:3158–3193  ·  view source on GitHub ↗
(ctx context.Context, projectID string, environment *string)

Source from the content-addressed store, hash-verified

3156}
3157
3158func (c *connection) FindProjectVariables(ctx context.Context, projectID string, environment *string) ([]*database.ProjectVariable, error) {
3159 q := `SELECT * FROM project_variables p WHERE p.project_id = $1`
3160 args := []interface{}{projectID}
3161 if environment != nil {
3162 // Also include variables that are not environment specific and not set for the given environment
3163 q += `
3164 AND (
3165 p.environment = $2
3166 OR (
3167 p.environment = ''
3168 AND NOT EXISTS (
3169 SELECT 1
3170 FROM project_variables p2
3171 WHERE p2.project_id = p.project_id
3172 AND p2.environment = $2
3173 AND lower(p2.name) = lower(p.name)
3174 )
3175 )
3176 )
3177 `
3178 args = append(args, environment)
3179 }
3180 var res []*database.ProjectVariable
3181 err := c.getDB(ctx).SelectContext(ctx, &res, q, args...)
3182 if err != nil {
3183 return nil, parseErr("project variables", err)
3184 }
3185
3186 // Decrypt the variables
3187 err = c.decryptProjectVariables(res)
3188 if err != nil {
3189 return nil, err
3190 }
3191
3192 return res, nil
3193}
3194
3195func (c *connection) UpsertProjectVariable(ctx context.Context, projectID, environment string, vars map[string]string, userID string) ([]*database.ProjectVariable, error) {
3196 var userIDPtr *string

Callers

nothing calls this directly

Calls 4

getDBMethod · 0.95
parseErrFunction · 0.85
SelectContextMethod · 0.80

Tested by

no test coverage detected