DEV Community

Itachi Uchiha
Itachi Uchiha

Posted on

Netenv Project

Hi. I created a project called netenv.

It's a simple, network-based environment variable loader.

GitHub: https://github.com/aligoren/netenv

I'm looking for to new ideas or contributions. Actually, I'm still learning Golang. So, it would be nice if you give me feedback.

What does this project do?

This project allows you to share different environment files of a project you specify and the variables in these files from a single server to all connected networks. You can also create an exclude list, and restrict access to the network with the allowed IP.

This is not a web API. It works over TCP just like Redis.

It can be configured like that;

netenv.yml

global:
  addr: ":8080"
  auth:
    enabled: true # set this true if you want to use authentication
    username: admin
    password: admin
    iplist:
      - 0.0.0.0
      - 127.0.0.1

envfiles:
  project1:
    default: dev
    environments:
      dev:
        path: /home/ali/pyt/test.env
        excludes:
          - MYSQL_USERNAME
  project2:
    default: dev
    environments:
      dev:
        path: /home/YOUR_USER/pyt/project2_dev.env
      stage:
        path: /home/YOUR_USER/pyt/project2_stage.env
      prod:
        path: /home/YOUR_USER/pyt/project2_prod.env
Enter fullscreen mode Exit fullscreen mode

Let's say we have a python file to connect this server like that;

import socket

HOST = "127.0.0.1"  # The server's hostname or IP address
PORT = 8080  # The port used by the server

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    # s.sendall(b"echo\n")
    # s.sendall(b"auth:admin:admin:echo\n")
    # s.sendall(b"auth:admin:admin:file$project1:env$dev:var$name,TEST,MYSQL_USERNAME\n")
    s.sendall(b"auth:admin:admin:file$project1:env$dev:var$*\n")
    # s.sendall(b"auth:admin:admin:file$project1:env$dev:var$TEST\n")
    # s.sendall(b"auth:admin:admin:file$project2:env$prod:var$name\n")
    # s.sendall(b"file$project2:env$prod:var$name\n")
    #s.sendall(b"echo\n")
    data = s.recv(1024)

print(f"Received: {data.decode('utf-8')}")
Enter fullscreen mode Exit fullscreen mode

I don't know are there any projects like that. If there is a project like that, please let me know. I can stop to develop this project.

Have a nice day!

Top comments (0)