feat: introduce abra config file and load abra dir from it #419
Labels
Clear labels
bug
build
ci/cd
critical fix
design
documentation
duplicate
easy-first-issue
enhancement
help wanted
i10n
i18n
installer
invalid
question
release
release-candidate
security
tech-debt
test
wontfix
Something is not working
go build related issues
Building things with CI/CD
https://docs.coopcloud.tech/federation/resolutions/passed/010/
UI/UX
Documenting all the things
This issue or pull request already exists
Something for new people to get stuck into. We hope it's easy!
New feature
Need some help
Everything to do with localisation
Everything to do with internationalisation
Everything to do with the install script.
Something is wrong
More information is needed
Release management
Related to the new release candidate
Security related
Unit/integration testing
This won't be fixed
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Assignees
3wordchant
aadil (Aadil Ayub)
abra-bot (Abra Bot)
ammaratef45
amras (Sarma)
Apfelwurm
BornDeleuze
Brooke
carla
cas (Cassowary)
coopcloud
cyrnel
decentral1se (d1)
dede
devydave
fauno (fauno)
iexos
jade (Jade Ambrose)
jjsfunhouse
jmakdah2 (Jackie Makdah)
joe-irving (Joe Irving)
kawaiipunk (KawaiiPunk)
knoflook
kolaente
lambdabundesverband
linnealovespie (April)
moosemower
moritz
notplants
oxaliq (sorrel)
p4u1
pharaohgraphy (Andrew 🐦🔥❤️🔥✴️)
renovate-bot (Comrade Renovate Bot)
ripclap
simon
sixsmith (Sixsmith)
stevensting
trav (Trav Fryer)
val (val (he/him))
yksflip
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: toolshed/abra#419
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This is the first step to introduce a configuration file for abra. The config file must be named
abra.yamlor àbra.yml`. abra look for the config file in the current directory and when not found traverses the directory tree up until it is found or the home/root directory is reached.For now there is only one setting that is made configurable:
abraDir. The new logic for setting the abra dir is the following:$ABRA_DIRenv$HOME/.abraas fallbackSee coop-cloud/organising#303.
Todo:
Nice, love to see it! Ping me for a review when it's GTG 🎉
The only thing I'd mention at this point is that people do
.yaml/.ymlso you might want to do some sort of grep-enabled find for the file ending.... otherwise, we can 100% count on a bug report in the future 😆5eb285bf82to7789978582config: automatic base dir when abra.yaml was foundto feat: introduce abra config file and load abra dir from it7789978582tob8276f149eb8276f149eto5ecde18a3d@decentral1se Thanks for the feedback and linking to the issue! After reading the issue again I changed the logic to take the abra dir from a concrete value (
abraDir) in the config file instead of setting it to the directory of the config file.I also added some tests and added
abra.ymlas another valid config file name.Great stuff @p4u1! Minor comments, feel free to merge 💝
@@ -0,0 +11,4 @@// LoadAbraConfig returns the abra configuration. It tries to find a abra// configuration file (see findAbraConfig for lookup logic). When no// configuration was was found it returns the default config.%s/was was/was/@@ -0,0 +16,4 @@wd, _ := os.Getwd()configFile := findAbraConfig(wd)if configFile == "" {logrus.Info("no config file found")Perhaps
Warnfis best? No error and coloured output?Changed it to debug output for now, but can always change this later
@@ -0,0 +22,4 @@data, err := os.ReadFile(configFile)if err != nil {// Do nothing, when an error occurslogrus.Infof("error reading config file: %s", err)https://git.coopcloud.tech/coop-cloud/abra/pulls/419/files#issuecomment-20723
@@ -0,0 +30,4 @@err = yaml.Unmarshal(data, &config)if err != nil {// Do nothing, when an error occurslogrus.Infof("error loading config file: %s", err)https://git.coopcloud.tech/coop-cloud/abra/pulls/419/files#issuecomment-20723
@@ -0,0 +62,4 @@// Abra defines the configuration file for abra.type Abra struct {AbraDir string `yaml:"abraDir"`Abra.Dir? No strong feelings tho.I left it for now, but am open to changing it later :)
5ecde18a3dtod26645fbdfd26645fbdfto97ae6ac267@decentral1se can you have a look at the test failure? It works for me locally
@@ -0,0 +63,4 @@})t.Run("from config file", func(t *testing.T) {wd, err := os.Getwd()Maybe this is borking it? Not sure otherwise 🤔
wasn't borking it, but removed it anyways
@decentral1se there error was because the tests are run with an $ABRA_DIR set... this always overrides the config file. I unset it at the begging of the test now