Dotnet-appsettings-env - Convert .NET appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables

dotnet-appsettings-env

Convert .NET appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables.

Getting started

  1. Download a pre-compiled binary from the release page.
  2. Run dotnet-appsettings-env --help
$ dotnet-appsettings-env --help
dotnet-appsettings-env v1.0.0

Convert .NetCore appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables.

Daniel Dias de Assumpção <[email protected]>
https://github.com/dassump

Usage of dotnet-appsettings-env:
  -file string
        Path to file appsettings.json (default "./appsettings.json")
  -separator string
        Separator character (default "__")
  -type string
        Output to Kubernetes (k8s) / Docker (docker) / Docker Compose (compose) (default "k8s")

Examples

appsettings.json

{
    "ApiClientId": "*",
    "ApiClientSecret": "*",
    "ApiGateway": "*",
    "Scope": "*",
    "Middlewares": [
        {
            "Name": "api/Auth",
            "Url": "*"
        },
        {
            "Name": "api/Registration",
            "Url": "*"
        }
    ],
    "HttpManager": {
        "IgnoreCertificateValidation": true,
        "AllowAutoRedirect": true
    },
    "Logging": {
        "Enabled": true,
        "IncludeScopes": false,
        "Level": "Information",
        "Debug": {
            "LogLevel": {
                "Default": "Warning"
            }
        },
        "Console": {
            "LogLevel": {
                "Default": "Warning"
            }
        }
    },
    "Serilog": {
        "Using": [
            "Serilog.Sinks.File"
        ],
        "MinimumLevel": "Debug",
        "WriteTo": [
            {
                "Name": "Console"
            },
            {
                "Name": "File",
                "Args": {
                    "path": "Logs/Api.log",
                    "rollingInterval": "Day",
                    "fileSizeLimitBytes": "52428800",
                    "rollOnFileSizeLimit": "true",
                    "retainedFileCountLimit": "100",
                    "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
                }
            }
        ]
    }
}

Kubernetes

$ dotnet-appsettings-env -type k8s
- name: "ApiClientId"
  value: "*"
- name: "ApiClientSecret"
  value: "*"
- name: "ApiGateway"
  value: "*"
- name: "HttpManager__AllowAutoRedirect"
  value: "true"
- name: "HttpManager__IgnoreCertificateValidation"
  value: "true"
- name: "Logging__Console__LogLevel__Default"
  value: "Warning"
- name: "Logging__Debug__LogLevel__Default"
  value: "Warning"
- name: "Logging__Enabled"
  value: "true"
- name: "Logging__IncludeScopes"
  value: "false"
- name: "Logging__Level"
  value: "Information"
- name: "Middlewares__0__Name"
  value: "api/Auth"
- name: "Middlewares__0__Url"
  value: "*"
- name: "Middlewares__1__Name"
  value: "api/Registration"
- name: "Middlewares__1__Url"
  value: "*"
- name: "Scope"
  value: "*"
- name: "Serilog__MinimumLevel"
  value: "Debug"
- name: "Serilog__Using__0"
  value: "Serilog.Sinks.File"
- name: "Serilog__WriteTo__0__Name"
  value: "Console"
- name: "Serilog__WriteTo__1__Args__fileSizeLimitBytes"
  value: "52428800"
- name: "Serilog__WriteTo__1__Args__outputTemplate"
  value: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
- name: "Serilog__WriteTo__1__Args__path"
  value: "Logs/Api.log"
- name: "Serilog__WriteTo__1__Args__retainedFileCountLimit"
  value: "100"
- name: "Serilog__WriteTo__1__Args__rollOnFileSizeLimit"
  value: "true"
- name: "Serilog__WriteTo__1__Args__rollingInterval"
  value: "Day"
- name: "Serilog__WriteTo__1__Name"
  value: "File"

Docker

$ dotnet-appsettings-env -type docker
ApiClientId=*
ApiClientSecret=*
ApiGateway=*
HttpManager__AllowAutoRedirect=true
HttpManager__IgnoreCertificateValidation=true
Logging__Console__LogLevel__Default=Warning
Logging__Debug__LogLevel__Default=Warning
Logging__Enabled=true
Logging__IncludeScopes=false
Logging__Level=Information
Middlewares__0__Name=api/Auth
Middlewares__0__Url=*
Middlewares__1__Name=api/Registration
Middlewares__1__Url=*
Scope=*
Serilog__MinimumLevel=Debug
Serilog__Using__0=Serilog.Sinks.File
Serilog__WriteTo__0__Name=Console
Serilog__WriteTo__1__Args__fileSizeLimitBytes=52428800
Serilog__WriteTo__1__Args__outputTemplate={Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}
Serilog__WriteTo__1__Args__path=Logs/Api.log
Serilog__WriteTo__1__Args__retainedFileCountLimit=100
Serilog__WriteTo__1__Args__rollOnFileSizeLimit=true
Serilog__WriteTo__1__Args__rollingInterval=Day
Serilog__WriteTo__1__Name=File

Docker Compose

$ dotnet-appsettings-env -type compose
"ApiClientId": "*"
"ApiClientSecret": "*"
"ApiGateway": "*"
"HttpManager__AllowAutoRedirect": "true"
"HttpManager__IgnoreCertificateValidation": "true"
"Logging__Console__LogLevel__Default": "Warning"
"Logging__Debug__LogLevel__Default": "Warning"
"Logging__Enabled": "true"
"Logging__IncludeScopes": "false"
"Logging__Level": "Information"
"Middlewares__0__Name": "api/Auth"
"Middlewares__0__Url": "*"
"Middlewares__1__Name": "api/Registration"
"Middlewares__1__Url": "*"
"Scope": "*"
"Serilog__MinimumLevel": "Debug"
"Serilog__Using__0": "Serilog.Sinks.File"
"Serilog__WriteTo__0__Name": "Console"
"Serilog__WriteTo__1__Args__fileSizeLimitBytes": "52428800"
"Serilog__WriteTo__1__Args__outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
"Serilog__WriteTo__1__Args__path": "Logs/Api.log"
"Serilog__WriteTo__1__Args__retainedFileCountLimit": "100"
"Serilog__WriteTo__1__Args__rollOnFileSizeLimit": "true"
"Serilog__WriteTo__1__Args__rollingInterval": "Day"
"Serilog__WriteTo__1__Name": "File"

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dassump/dotnet-appsettings-env.

Owner
Similar Resources

Mesos Framework to use docker-compose files.

Mesos Framework to use docker-compose files.

mesos-compose Mesos Framework to use docker-compose files. Requirements Apache Mesos min 1.6.0 Mesos with SSL and Authentication is optional Redis Dat

Dec 14, 2022

Execute multiple shell commands like Docker-Compose

parx parx is a simple tool to run multiple commands in parallel while having the output structured like Docker Compose does that. This is useful when

Aug 15, 2022

Docker-compose files for running full Storj network locally

docker-compose based Storj environment storj-up is a swiss-army tool to create / customize Storj clusters with the help of docker-compose (not just st

Nov 16, 2022

GitHub Action: Compose multiple (conditional) checks into a single check based on file paths in a pull request

GitHub Action: Compose multiple (conditional) checks into a single check based on file paths in a pull request

GitHub Action: Composite Example Usage --- name: All Checks on: pull_request: branches: - main jobs: meta: runs-on: - ubuntu-20.

Dec 29, 2022

Frep - Generate file using template from environment, arguments, json/yaml/toml config files

frep Generate file using template from environment, arguments, json/yaml/toml config files. NAME: frep - Generate file using template USAGE: fr

Nov 30, 2022

The OCI Service Operator for Kubernetes (OSOK) makes it easy to connect and manage OCI services from a cloud native application running in a Kubernetes environment.

OCI Service Operator for Kubernetes Introduction The OCI Service Operator for Kubernetes (OSOK) makes it easy to create, manage, and connect to Oracle

Sep 27, 2022

Kubectl-over-env - Created for github actions or any other CI/CD-Pipelining tool which cannot push to a custom local kubernetes cluster

kubectl-over-env This repository was created for github actions or any other CI/

Jan 4, 2022

Bubbleboxer - compose bubbles into boxes

bubbleboxer 🥊 - compose bubbles into boxes 📦 A way to compose multiple bubbles

Dec 20, 2022

Template Compose - Continues Delivery

Template Compose - Continues Delivery

Feb 4, 2022
Comments
  • Ignoring comments: invalid character '/' looking for beginning of object key string

    Ignoring comments: invalid character '/' looking for beginning of object key string

    dotnet-appsettings-env version

    v1.0.0

    Debug Output

    https://gist.github.com/E-RELevant/a35ab0d13832329fdbc529af674225ab

    Expected Behavior

    Know how to ignore comments, as .NET allow comments in appsettings.json files. I would also find it very helpful if I knew where the problem occurred.

    Actual Behavior

    invalid character '/' looking for beginning of object key string

    sometimes, while using a file from Azure DevOps Source Control, I get the following error (same exact file):

    invalid character 'ï' looking for beginning of value

  • not working

    not working

    Hello . I wanted to use it in Windows, but it gives an error every time. I put the example in the repo and I have this error

    Error: invalid character 'ï' looking for beginning of value in ./appsettings.json
    
  • WARNING: Python-dotenv could not parse statement starting at line X

    WARNING: Python-dotenv could not parse statement starting at line X

    Let's say I have an env file like this: docker.env

    App__PathToFiles="C:\\Program Files\\SOMEPATH\\"
    App__SomeOtherKey="Value"
    

    and then passing it as an envfile in docker compose docker-compose.yaml

    version: '3.3'
    services:
      app:
        image: alpine
        container_name: app
        tty: true
        env_file:
          - ./docker.env
    

    Running docker-compose up with that config produces this error:

    WARNING: Python-dotenv could not parse statement starting at line 1
    

    This is because bashlash telling env to ignore the double quote which will break the structure of the config.

Compose Switch is a replacement to the Compose V1 docker-compose (python) executable

Compose Switch Compose Switch is a replacement to the Compose V1 docker-compose (python) executable. It translates the command line into Compose V2 do

Jan 8, 2023
Mutagen Compose is a modified version of Docker Compose that offers automated integration with Mutagen.

Mutagen Compose Mutagen Compose is a (minimally) modified version of Docker Compose that offers automated integration with Mutagen. This allows you to

Dec 22, 2022
Tool to convert docker-compose files to set of simple docker commands

docker-decompose Tool to convert docker-compose files to set of simple docker commands. Install Use go get to install the latest version of the librar

Apr 12, 2022
Easily run your Compose application to the cloud with compose-cli

This CLI tool makes it easy to run Docker containers and Docker Compose applications in the cloud using either Amazon Elastic Container Service (ECS) or Microsoft Azure Container Instances (ACI) using the Docker commands you already know.

Jan 8, 2023
Sample multi docker compose environment setup

Instructions This is a demonstration of a Multi Docker Compose. The purpose of this repositoy is ongoing research on "Docker compose" architecture des

Oct 21, 2022
Katenary - Convert docker-compose to a configurable helm chart
Katenary - Convert docker-compose to a configurable helm chart

Katenary is a tool to help transforming docker-compose files to a working Helm C

Dec 23, 2022
`runenv` create gcloud run deploy `--set-env-vars=` option and export shell environment from yaml file.

runenv runenv create gcloud run deploy --set-env-vars= option and export shell environment from yaml file. Motivation I want to manage Cloud Run envir

Feb 10, 2022
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.

GIT-PIPE Hassle-free minimal CI/CD for git repos for docker-based projects. Features: zero configuration for repos by default automatic encrypted back

Sep 23, 2022
K8s-dotenv - Kubernetes Secrets and Configmaps to dot env file

k8s-dotenv A commandline tool to fetch, merge and convert secrets and config map

Apr 22, 2022
Example used to try a compose application with Docker Dev Environments

compose-dev-env Example used to try a Compose application with Docker Dev Environments. This example is based on the nginx-golang-mysql sample of awes

Dec 29, 2022