The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Inverting The Order Of Environmental Variables In Configs

TODO: Pull subtitle into page object

Playing with the idea of switching the heierarchy of environments and their variables in config files. For example, I'm doing this:

code_start_default_section code_end_default_section

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Inverting The Order Of Environmental Variables In Configs

-- p

Playing with the idea of switching the heierarchy of environments and their variables in config files. For example, I'm doing this:

-- code/
-- json

{
  "envars": {
    "database_host": {
      "dev": "freeside.cloud",
      "prod": "encom.cloud"
    },
    "database_name": {
      "dev": "gibson",
      "prod": "mcp"
    },
    "database_password": {
      "dev": "wintermute",
      "prod": "chess"
    },
    "database_username": {
      "dev": "william",
      "prod": "alan1"
    },
    "debug": {
      "dev": true,
      "prod": false
    },
    "log_level": {
      "dev": "INFO",
      "prod": "ERROR"
    }
  }
}

-- /code

-- p

Instead of this:

-- code/
-- json

{
  "envs": {
    "dev": {
      "database_host": "freeside.cloud",
      "database_name": "gibson",
      "database_password": "wintermute",
      "database_username": "william",
      "debug": true,
      "log_level": "INFO"
    },
    "prod": {
      "database_host": "encom.cloud",
      "database_name": "mcp",
      "database_password": "chess",
      "database_username": "alan1",
      "debug": false,
      "log_level": "ERROR"
    }
  }
}

-- /code

-- p

It's an interesting experiment. It makes things more verbose though. First, there's a lot more lines in the config itself for the same info. Then, in the code, you can't simply do `config_data = config['dev']` to get an environment loaded. Each call has to have the env defined in it. For example:

-- code/
-- python3

config = # Load the data
env = 'dev'

print(config.database_name[env])

-- /code

-- p

instead of just being able to hit it with:

-- code/
-- python3

config = # Load the data for just 'dev'

print(config.database_name)

-- /code


-- categories
-- Development

-- metadata
-- date: 2021-09-28 20:48:58
-- id: 20eouvdi
-- status: scratch
-- type: post
-- SCRUBBED_NEO: false
-- site: aws