-
Notifications
You must be signed in to change notification settings - Fork 15
Draft: feat: Implement config endpoint #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@aaronbrethorst Can you please look at this and #42. |
|
Thanks for tackling the config endpoint! The overall approach here is solid—using That said, there are some issues that need addressing before this can merge. Let me walk through what needs to change and why. Critical Issues That Block Merging1. The Four TODO FieldsLines 50-54 in For now, just use empty strings instead of configData := models.NewConfigData(
git,
"", // id - bundle-specific, empty for now
"", // name - bundle-specific, empty for now
"", // serviceDateFrom - will implement later
"", // serviceDateTo - will implement later
)The service date fields ( 2. The Git Dirty Logic is BackwardsLines 21-25 in if git_dirty == "1" {
git_dirty = "true"
} else {
git_dirty = "false"
}The issue is that Fix it like this: if git_dirty == "0" { // exit code 0 = clean
git_dirty = "false"
} else {
git_dirty = "true"
}3. Shell Script Won't Work on macOSLine 3 of Replace it with a more portable version: date -u +"%d.%m.%Y @ %H:%M:%S UTC"This works identically across GNU and BSD 4. Fragile String ParsingLine 20 of git_branch, git_build_host, git_build_time, ... := lines[0], lines[1], lines[2], ...This is brittle. If the script changes, if a git command fails, if someone adds a line—everything breaks. Even worse, it'll panic at runtime if there aren't enough lines. A more robust approach is to use key-value pairs in the shell script output: echo "git.branch=$(git rev-parse --abbrev-ref HEAD)"
echo "git.build.host=$(hostname)"
echo "git.build.time=$(date -u +"%d.%m.%Y @ %H:%M:%S UTC")"
# ... and so onThen parse with props := make(map[string]string)
for _, line := range lines {
key, value, ok := strings.Cut(line, "=")
if ok {
props[key] = strings.TrimSpace(value)
}
}
git := models.NewGitProperties(
props["git.branch"],
props["git.build.host"],
props["git.build.time"],
// ...
)This handles missing values gracefully (they'll be empty strings) and makes the script easier to maintain. Major Issues That Should Be Fixed5. Incomplete Git MetadataLines 6-8, 11-12, and 24 of the shell script return Here's how to populate them: git describe --tags --always # git.build.version
git describe --tags --abbrev=0 # git.closest.tag.name
git rev-list $(git describe --tags --abbrev=0)..HEAD --count # git.closest.tag.commit.count
git describe --tags # git.commit.id.describe
git describe --tags --abbrev=0 # git.commit.id.describe.short
git tag -l --points-at HEAD | tr '\n' ',' | sed 's/,$//' # git.tagsEach of these can fail if no tags exist, so wrap them in conditionals: if git describe --tags >/dev/null 2>&1; then
echo "git.build.version=$(git describe --tags --always)"
else
echo "git.build.version=N/A"
fiThis way you get real version information when tags are available, but degrade gracefully when they're not. 6. Build User vs. Commit User ConfusionLines 4-5 use For build context, you probably want: echo "git.build.user.name=$(whoami)"
echo "git.build.user.email=${USER}@$(hostname)"Or in CI environments, read from environment variables like 7. Missing Directory CreationThe shell script writes to mkdir -p internal/restapi/gitOr handle it in the Makefile's Minor Issues and Style Notes8. Go Naming ConventionsThe This is mostly cosmetic, but it'll matter if other code ever needs to work with these fields directly. 9. The
|
|
Hey i fixed some issues, have not yet fixed all yet! due to time constraints at college. |
|
@aaronbrethorst
10,11,13 is something i am still working on! |
|
13-> |
|
The Java app is using |
|
Hi @vighnesh-sawant are there still more changes to do here? |
|
Tests and making the script handle failures is left, I will try to get it implemented soon. |
#42
Pending:- Add more tests for the .sh file
Need some inputs from maintainers/anyone. Please look at the comments on the issue.
Any suggestions , criticism are welcome