Comments (4)
Well you should instead make use of .env files which sampctl autoloads and use the pawn-env plugin https://github.com/dakyskye/pawn-env
Because pawn.json
files are generally uploaded to git repositories, we don't recommend storing sensitive information such as database information within them, this is why there exists a system like .env
files which are designed to not be uploaded to repositories and are generally excluded in git repos.
from sampctl.
@ADRFranklin Thanks for your reply, correct, in my real codebase I don't have these constants in the pawn.json file, but rather as docker env vars, in my pawn.json I just have:
{
"name": "main",
"includes": ["../../legacy"],
"args": ["-;+", "-(+", "-O1", "-Z+"],
"compiler": {},
"constants": {
"MYSQL_HOST": "$MYSQL_HOST",
"MYSQL_PORT": "$MYSQL_PORT",
"MYSQL_USER": "$MYSQL_USER",
"MYSQL_PASS": "$MYSQL_PASS",
"MYSQL_DB": "$MYSQL_DB"
}
},
The snippet I posted was just a reproducible example of the issue with sampctl constants. To be fair I couldn't make it work using pawn compiler directly passing the constants as compiler options.
Using env variables also doesn't work. I'll check out the library you provided, cheers.
Also about having database connection configuration versioned: It actually depends on the use case right? I assume you're talking about production environment which I obviously agree, but if I have an integration tests setup on my ci workflow where the database schema is short-lived (created/destroyed during the workflow run) and only accessible from the CI tool (i.e. Github Actions), I don't see any harm or potential security issues, I would end up having something like:
{
....
"builds": [
{
"name": "live",
"includes": ["../../legacy"],
"args": ["-;+", "-(+", "-O1", "-Z+"],
"compiler": {},
"constants": {
"MYSQL_HOST": "$MYSQL_HOST",
"MYSQL_PORT": "$MYSQL_PORT",
"MYSQL_USER": "$MYSQL_USER",
"MYSQL_PASS": "$MYSQL_PASS",
"MYSQL_DB": "$MYSQL_DB"
}
},
{
"name": "tests",
"includes": ["../../legacy"],
"args": ["-;+", "-(+", "-O1", "-Z+", "-d3"],
"compiler": {},
"constants": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "integration_tests",
"MYSQL_PASS": "integration_tests",
"MYSQL_DB": "integration_tests"
}
}
]
}
from sampctl.
The stuff in constants
are passed to the compiler using the symbol params. I use constants all the time specifically for passing the environment, so I only build specific code. Never had a problem doing this or detecting if one exists, so I am not sure what doesn't work for you?
from sampctl.
@ADRFranklin I have no issues when the constant value is a number, however when it's a string it's defined as empty.
"constants": {
"MY_CONSTANT_NUMBER": "300", // works
"MY_CONSTANT_STRING": "test" // will output an empty string when running printf("%s", MY_CONSTANT_STRING);
},
from sampctl.
Related Issues (20)
- Error -> Failed to compile package entry: exit status STATUS_ACCESS_VIOLATION HOT 1
- Sampctl don´t working with newer Git versions HOT 1
- failed to ensure dependency from cache: exec HOT 8
- Sampctl Error Regarding PawnStdlib HOT 1
- Error on command :sampctl ensure HOT 3
- Faild to compile package entry: exit status_access_violation HOT 1
- Few problem that makes sampctl feels incompatible with open.mp
- Error installing smapctl via Brew Mac: Formulae require at least a URL HOT 1
- failed to ensure dependency from cache: exec HOT 2
- failed to extract discord connector
- y_testing mode broken due to line format change HOT 1
- Help me with PlayAudioStreamForPlayer HOT 1
- I'm having a problem here. Please help me fix it HOT 1
- Load only .inc files HOT 1
- dont update HOT 1
- Issue with build
- failed to compile package entry: exit status STATUS_DLL_NOT_FOUND HOT 1
- Fails to load pugins HOT 1
- Add a parameter to specify the path for the complier that will use sampctl
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sampctl.