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

Overview

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.

You might also like...
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

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

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

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

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.

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

Bubbleboxer - compose bubbles into boxes

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

Template Compose - Continues Delivery

Template Compose - Continues Delivery

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

    bug enhancement 
    opened by E-RELevant 8
  • 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
    
    bug enhancement 
    opened by EngRajabi 5
Releases(v1.2.0)
Owner
Daniel Dias de Assumpção
Daniel Dias de Assumpção
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

Docker 131 Sep 25, 2022
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

Mutagen 69 Sep 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

Liri S 2 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.

Docker 857 Sep 22, 2022
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

Damjan Dimitrioski 3 May 3, 2021
Katenary - Convert docker-compose to a configurable helm chart

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

Patrice Ferlet 29 Sep 26, 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

sonatard 0 Feb 10, 2022
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

Aleksandr Baryshnikov 50 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

Sami Khan 3 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

Docker Samples 81 Sep 14, 2022