work on refactor for version 2

Details in final merge
This commit is contained in:
Victor Lacasse-Beaudoin 2024-10-03 17:18:01 -04:00
parent 17810d9001
commit 1e0ce9ee80
20 changed files with 814 additions and 91 deletions

118
LICENSE Normal file
View file

@ -0,0 +1,118 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice

View file

@ -1,12 +1,69 @@
package main package main
//serverCmd import (
//serverAPICmd "context"
"log"
"os"
"git.agecem.com/bottin/bottinagenda/pkg/bottinagenda"
"github.com/spf13/cobra"
)
// serverCmd
// TODO
var serverCmd = &cobra.Command{
Use: "server",
Short: "Server commands",
}
// serverAPICmd
var serverAPICmd = &cobra.Command{
Use: "api",
Short: "Start API server",
Run: func(cmd *cobra.Command, args []string) {
ctx := context.TODO()
cfg, err := bottinagenda.ParseConfig()
if err != nil {
log.Fatal("parse config:", err)
}
//TODO dbg
/*
buf, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
log.Fatal(err)
}
fmt.Println(string(buf))
*/
if err := bottinagenda.RunAPIServer(ctx, cfg, os.Stdout); err != nil {
log.Fatal(err)
}
},
}
// TODO
//serverUICmd //serverUICmd
//init: // TODO
// - rootCmd < serverCmd
// - serverCmd < serverAPICmd func init() {
// - serverCmd < serverUICmd // init: rootCmd <- serverCmd
//bindServerFlags (if any) on serverCmd rootCmd.AddCommand(serverCmd)
// init: serverCmd <- serverAPICmd
serverCmd.AddCommand(serverAPICmd)
if err := bottinagenda.BindAPIServerFlags(serverAPICmd.PersistentFlags()); err != nil {
log.Fatal(err)
}
// init: serverCmd <- serverUICmd
// TODO
}
//bindServerAPIFlags on serverAPICmd //bindServerAPIFlags on serverAPICmd
// TODO
//bindServerUIFlags on serverUICmd //bindServerUIFlags on serverUICmd
// TODO

View file

@ -14,12 +14,11 @@ services:
context: '../../../external/bottin/' context: '../../../external/bottin/'
dockerfile: './deployments/docker/bottin/Dockerfile' dockerfile: './deployments/docker/bottin/Dockerfile'
environment: environment:
BOTTIN_SERVER_DB_USER: 'bottin' BOTTIN_SERVER_API_POSTGRES_USER: 'bottin'
BOTTIN_SERVER_DB_PASSWORD: 'bottin' BOTTIN_SERVER_API_POSTGRES_PASSWORD: 'bottin'
BOTTIN_SERVER_DB_HOST: 'bottin_db' BOTTIN_SERVER_API_POSTGRES_HOST: 'bottin_db'
restart: 'unless-stopped' restart: 'unless-stopped'
#command: ['bottin', 'server', 'api'] command: ['bottin', 'server', 'api']
command: ['cat', '/msg']
bottinagenda_db: bottinagenda_db:
image: 'postgres:16' image: 'postgres:16'
@ -37,12 +36,17 @@ services:
context: '../../../' context: '../../../'
dockerfile: './deployments/docker/bottinagenda/Dockerfile' dockerfile: './deployments/docker/bottinagenda/Dockerfile'
environment: environment:
BOTTINAGENDA_SERVER_DB_USER: 'bottinagenda' BOTTINAGENDA_SERVER_API_POSTGRES_USER: 'bottinagenda'
BOTTINAGENDA_SERVER_DB_PASSWORD: 'bottinagenda' BOTTINAGENDA_SERVER_API_POSTGRES_PASSWORD: 'bottinagenda'
BOTTINAGENDA_SERVER_DB_HOST: 'bottinagenda_db' BOTTINAGENDA_SERVER_API_POSTGRES_HOST: 'bottinagenda_db'
BOTTINAGENDA_BOTTIN_HOST: 'bottin_api' BOTTINAGENDA_BOTTIN_API_HOST: 'bottin_api'
restart: 'unless-stopped' command: ['bottinagenda', 'server', 'api']
#command: ['bottinagenda', 'server', 'api']
command: ['cat', '/msg']
#TODO bottinagenda_test: test:
depends_on:
- 'bottinagenda_api'
image: 'git.agecem.com/bottin/bottinagenda:src'
build:
context: '../../../'
dockerfile: './deployments/docker/src/Dockerfile'
command: ['go', 'test', '-v', './pkg/bottinagenda/']

View file

@ -0,0 +1,15 @@
FROM golang:1.23
ARG bottinagenda_version
LABEL author="vlbeaudoin"
WORKDIR /go/src/app
COPY go.mod go.sum LICENSE ./
ADD cmd/ cmd/
#ADD examples/ examples/
ADD pkg/ pkg/
ADD queries/ queries/
ADD ui/ ui/

41
go.mod
View file

@ -3,27 +3,48 @@ module git.agecem.com/bottin/bottinagenda
go 1.23.1 go 1.23.1
require ( require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
)
require (
codeberg.org/vlbeaudoin/voki/v3 v3.0.1 // indirect
git.agecem.com/bottin/bottin v0.2.0 // indirect git.agecem.com/bottin/bottin v0.2.0 // indirect
git.agecem.com/bottin/bottin/v10 v10.4.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/labstack/echo/v4 v4.12.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/magiconair/properties v1.8.7 // indirect github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect
go.uber.org/multierr v1.9.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect go.uber.org/atomic v1.11.0 // indirect
golang.org/x/sys v0.18.0 // indirect go.uber.org/multierr v1.11.0 // indirect
golang.org/x/text v0.14.0 // indirect golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.5.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

56
go.sum
View file

@ -1,24 +1,53 @@
codeberg.org/vlbeaudoin/voki/v3 v3.0.1 h1:pFjd/ZKsu4eOzRJYViE9F1S3RglSkAuIiqCo9IH9tUI=
codeberg.org/vlbeaudoin/voki/v3 v3.0.1/go.mod h1:+6LMXosAu2ijNKV04sMwkeujpH+cghZU1fydqj2y95g=
git.agecem.com/bottin/bottin v0.2.0 h1:zzRsk8u5fwNIak9hZxp//uLyLjhEPZGikIQLsK9x9gc= git.agecem.com/bottin/bottin v0.2.0 h1:zzRsk8u5fwNIak9hZxp//uLyLjhEPZGikIQLsK9x9gc=
git.agecem.com/bottin/bottin v0.2.0/go.mod h1:XMf3meOkXc93sE8tgGDRaUqOGcRWy6rtwB+O8eIxvGE= git.agecem.com/bottin/bottin v0.2.0/go.mod h1:XMf3meOkXc93sE8tgGDRaUqOGcRWy6rtwB+O8eIxvGE=
git.agecem.com/bottin/bottin/v10 v10.4.0 h1:lNqvPtQl2cLElF939pYww1uhQccXt09/IW5CgrK4Gzw=
git.agecem.com/bottin/bottin/v10 v10.4.0/go.mod h1:KTwlqY5XdVi9F7cpwy3hxYN1DQm+74tBv7Wc9rfKXuM=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 h1:FWNFq4fM1wPfcK40yHE5UO3RUdSNPaBC+j3PokzA6OQ=
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
@ -27,6 +56,8 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@ -38,22 +69,47 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,54 @@
package bottinagenda
import (
"context"
"encoding/json"
"fmt"
"net/http"
"codeberg.org/vlbeaudoin/voki/v3"
)
type APIClient struct {
Caller *voki.Voki
}
func (c APIClient) Message() (string, error) {
return "Hello, world", nil
}
func (c APIClient) ReadHealth(ctx context.Context) (ReadHealthResponse, error) {
select {
case <-ctx.Done():
return ReadHealthResponse{}, ctx.Err()
default:
if c.Caller == nil {
return ReadHealthResponse{}, fmt.Errorf("Cannot read health from bottinagenda API server with nil Caller")
}
code, body, err := c.Caller.CallAndParse(
http.MethodGet,
"/v2/health/",
nil,
true,
)
if err != nil {
return ReadHealthResponse{}, err
}
switch {
case code >= 400:
var response ErrorResponse
if err := json.Unmarshal(body, &response); err != nil {
return ReadHealthResponse{}, fmt.Errorf("error: %s. Full body: %s", err, string(body))
}
return ReadHealthResponse{}, fmt.Errorf("code: %d. error: %s", code, response.Error)
default:
var response ReadHealthResponse
if err := json.Unmarshal(body, &response); err != nil {
return ReadHealthResponse{}, fmt.Errorf("error: %s. Full body: %s", err, string(body))
}
return response, nil
}
}
}

View file

@ -0,0 +1,62 @@
package bottinagenda
import (
"context"
"crypto/tls"
"net/http"
"testing"
"codeberg.org/vlbeaudoin/voki/v3"
"github.com/spf13/pflag"
)
func TestClient(t *testing.T) {
ctx := context.TODO()
set := pflag.NewFlagSet("test-client", pflag.ExitOnError)
if err := BindClientFlags(set); err != nil {
t.Fatal("bind client flags:", err)
}
cfg, err := ParseConfig()
if err != nil {
t.Fatal("parse config:", err)
}
//ctx := context.TODO()
var httpClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: cfg.Client.API.TLS.SkipVerify,
},
},
}
client := &APIClient{Caller: voki.New(
httpClient,
"bottin_api",
defaultServerAPIKey,
defaultServerAPIPort,
"http",
)}
defer client.Caller.CloseIdleConnections()
t.Run("message", func(t *testing.T) {
msg, err := client.Message()
if err != nil {
t.Error(err)
}
t.Log("msg:", msg)
})
// test bottinagenda health, which tests bottin health
t.Run("health", func(t *testing.T) {
healthResponse, err := client.ReadHealth(ctx)
if err != nil {
t.Error(err)
}
t.Logf("healthResponse: %v", healthResponse)
})
}

View file

@ -1,11 +1,38 @@
package bottinagenda package bottinagenda
import "github.com/spf13/viper" import (
"git.agecem.com/bottin/bottin/v10/pkg/bottin"
"github.com/spf13/viper"
)
func ParseConfig() (cfg Config, err error) { func ParseConfig() (cfg Config, err error) {
return cfg, viper.Unmarshal(&cfg) return cfg, viper.Unmarshal(&cfg)
} }
type Config struct {
Client struct {
API APIClientConfig
OutputStyle string
}
Server struct {
API struct {
Bottin bottin.APIClientConfig
Host string
Key string
Port int
Postgres PostgresConfig
TLS TLSServerConfig
}
UI struct {
API APIClientConfig
Host string
Password string
Port int
Username string
}
}
}
type APIClientConfig struct { type APIClientConfig struct {
Host string Host string
Key string Key string
@ -13,42 +40,13 @@ type APIClientConfig struct {
TLS TLSClientConfig TLS TLSClientConfig
} }
type APIServerConfig struct {
Host string
Key string
Port int
Postgres PostgresConfig
TLS TLSServerConfig
}
type ClientConfig struct {
API APIClientConfig
OutputStyle string
}
type Config struct {
Client ClientConfig
Server ServerConfig
}
type PostgresConfig struct { type PostgresConfig struct {
Database string Database string
Host string Host string
Password string Password string
Port int Port int
User string
SSLMode string SSLMode string
} User string
type ServerConfig struct {
API APIServerConfig
UI struct {
Host string
Password string
Port int
Username string
API APIClientConfig
}
} }
type TLSClientConfig struct { type TLSClientConfig struct {
@ -57,7 +55,7 @@ type TLSClientConfig struct {
} }
type TLSServerConfig struct { type TLSServerConfig struct {
Enabled bool
CertFile string CertFile string
Enabled bool
KeyFile string KeyFile string
} }

7
pkg/bottinagenda/db.go Normal file
View file

@ -0,0 +1,7 @@
package bottinagenda
import "github.com/jackc/pgx/v5/pgxpool"
type PostgresClient struct {
DB *pgxpool.Pool
}

View file

@ -7,40 +7,213 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
const (
defaultClientAPIHost = "localhost"
defaultClientAPIKey = ""
defaultClientAPIPort = 1313
defaultClientAPITLSEnabled = false
defaultClientAPITLSSkipVerify = false
defaultClientOutputstyle = "json"
defaultServerAPIBottinHost = "bottin_api"
defaultServerAPIBottinKey = "bottin"
defaultServerAPIBottinPort = 1312
defaultServerAPIBottinTLSEnabled = false
defaultServerAPIBottinTLSSkipVerify = false
defaultServerAPIHost = "api"
defaultServerAPIKey = "bottinagenda"
defaultServerAPIPort = 1313
defaultServerAPIPostgresDatabase = "bottinagenda"
defaultServerAPIPostgresHost = "db"
defaultServerAPIPostgresPassword = "bottinagenda"
defaultServerAPIPostgresPort = 5432
defaultServerAPIPostgresSSLMode = "prefer"
defaultServerAPIPostgresUser = "bottinagenda"
defaultServerAPITLSCertFile = "/etc/bottinagenda/cert.pem"
defaultServerAPITLSEnabled = false
defaultServerAPITLSKeyFile = "/etc/bottinagenda/key.pem"
defaultServerUIPort = 2313
)
func BindClientFlags(set *pflag.FlagSet) error { func BindClientFlags(set *pflag.FlagSet) error {
if set == nil { if set == nil {
return fmt.Errorf("cannot bind client flags on nil flagSet") return fmt.Errorf("cannot bind client flags on nil flagSet")
} }
set.StringP("client-outputstyle", "o", "json", "CLI output style") set.String("client-api-host", defaultClientAPIHost, "Remote API server host")
if err := viper.BindPFlag("Client.OutputStyle", set.Lookup("client-outputstyle")); err != nil {
return err
}
set.String("client-api-host", "localhost", "Remote API server host")
if err := viper.BindPFlag("Client.API.Host", set.Lookup("client-api-host")); err != nil { if err := viper.BindPFlag("Client.API.Host", set.Lookup("client-api-host")); err != nil {
return err return err
} }
set.String("client-api-key", "", "Remote API server key") set.String("client-api-key", defaultClientAPIKey, "Remote API server key")
if err := viper.BindPFlag("Client.API.Key", set.Lookup("client-api-key")); err != nil { if err := viper.BindPFlag("Client.API.Key", set.Lookup("client-api-key")); err != nil {
return err return err
} }
set.Int("client-api-port", 1313, "Remote API server port") set.Int("client-api-port", defaultClientAPIPort, "Remote API server port")
if err := viper.BindPFlag("Client.API.Port", set.Lookup("client-api-port")); err != nil { if err := viper.BindPFlag("Client.API.Port", set.Lookup("client-api-port")); err != nil {
return err return err
} }
set.Bool("client-api-tls-enabled", false, "Remote API server TLS state") set.StringP("client-outputstyle", "o", defaultClientOutputstyle, "CLI output style")
if err := viper.BindPFlag("Client.OutputStyle", set.Lookup("client-outputstyle")); err != nil {
return err
}
set.Bool("client-api-tls-enabled", defaultClientAPITLSEnabled, "Remote API server TLS state")
if err := viper.BindPFlag("Client.API.TLS.Enabled", set.Lookup("client-api-tls-enabled")); err != nil { if err := viper.BindPFlag("Client.API.TLS.Enabled", set.Lookup("client-api-tls-enabled")); err != nil {
return err return err
} }
set.Bool("client-api-tls-skipverify", false, "Do not verify remote API server TLS certificate") set.Bool("client-api-tls-skipverify", defaultClientAPITLSSkipVerify, "Do not verify remote API server TLS certificate")
if err := viper.BindPFlag("Client.API.TLS.SkipVerify", set.Lookup("client-api-tls-skipverify")); err != nil { if err := viper.BindPFlag("Client.API.TLS.SkipVerify", set.Lookup("client-api-tls-skipverify")); err != nil {
return err return err
} }
return nil return nil
} }
func BindAPIServerFlags(set *pflag.FlagSet) error {
if set == nil {
return fmt.Errorf("cannot bind api server flags on nil flagSet")
}
// Server.API.Bottin.Host
set.String("server-api-bottin-host", defaultServerAPIBottinHost, "Bottin API server host")
if err := viper.BindPFlag("Server.API.Bottin.Host", set.Lookup("server-api-bottin-host")); err != nil {
return err
}
// Server.API.Bottin.Key
set.String("server-api-bottin-key", defaultServerAPIBottinKey, "Bottin API server key")
if err := viper.BindPFlag("Server.API.Bottin.Key", set.Lookup("server-api-bottin-key")); err != nil {
return err
}
// Server.API.Bottin.Port
set.Int("server-api-bottin-port", defaultServerAPIBottinPort, "Bottin API server port")
if err := viper.BindPFlag("Server.API.Bottin.Port", set.Lookup("server-api-bottin-port")); err != nil {
return err
}
// Server.API.Bottin.TLS.Enabled
set.Bool("server-api-bottin-tls-enabled", defaultServerAPIBottinTLSEnabled, "Bottin API server TLS state")
if err := viper.BindPFlag("Server.API.Bottin.TLS.Enabled", set.Lookup("server-api-bottin-tls-enabled")); err != nil {
return err
}
// Server.API.Bottin.TLS.SkipVerify
set.Bool("server-api-bottin-tls-skipverify", defaultServerAPIBottinTLSSkipVerify, "Do not verify bottin API server TLS certificate")
if err := viper.BindPFlag("Server.API.Bottin.TLS.SkipVerify", set.Lookup("server-api-bottin-tls-skipverify")); err != nil {
return err
}
// Server.API.Host
set.String("server-api-host", defaultServerAPIHost, "API server host")
if err := viper.BindPFlag("Server.API.Host", set.Lookup("server-api-host")); err != nil {
return err
}
// Server.API.Key
set.String("server-api-key", defaultServerAPIKey, "API server key")
if err := viper.BindPFlag("Server.API.Key", set.Lookup("server-api-key")); err != nil {
return err
}
// Server.API.Port
set.Int("server-api-port", defaultServerAPIPort, "API server port")
if err := viper.BindPFlag("Server.API.Port", set.Lookup("server-api-port")); err != nil {
return err
}
// Server.API.Postgres.Database
set.String("server-api-postgres-database", defaultServerAPIPostgresDatabase, "API server postgres database")
if err := viper.BindPFlag("Server.API.Postgres.Database", set.Lookup("server-api-postgres-database")); err != nil {
return err
}
// Server.API.Postgres.Host
set.String("server-api-postgres-host", defaultServerAPIPostgresHost, "API server postgres host")
if err := viper.BindPFlag("Server.API.Postgres.Host", set.Lookup("server-api-postgres-host")); err != nil {
return err
}
// Server.API.Postgres.Password
set.String("server-api-postgres-password", defaultServerAPIPostgresPassword, "API server postgres password")
if err := viper.BindPFlag("Server.API.Postgres.Password", set.Lookup("server-api-postgres-password")); err != nil {
return err
}
// Server.API.Postgres.Port
set.Int("server-api-postgres-port", defaultServerAPIPostgresPort, "API server postgres port")
if err := viper.BindPFlag("Server.API.Postgres.Port", set.Lookup("server-api-postgres-port")); err != nil {
return err
}
// Server.API.Postgres.SSLMode
set.String("server-api-postgres-sslmode", defaultServerAPIPostgresSSLMode, "API server postgres SSL mode")
if err := viper.BindPFlag("Server.API.Postgres.SSLMode", set.Lookup("server-api-postgres-sslmode")); err != nil {
return err
}
// Server.API.Postgres.User
set.String("server-api-postgres-user", defaultServerAPIPostgresUser, "API server postgres user")
if err := viper.BindPFlag("Server.API.Postgres.User", set.Lookup("server-api-postgres-user")); err != nil {
return err
}
// Server.API.TLS.CertFile
set.String("server-api-tls-certfile", defaultServerAPITLSCertFile, "API server TLS certificate file")
if err := viper.BindPFlag("Server.API.TLS.CertFile", set.Lookup("server-api-tls-certfile")); err != nil {
return err
}
// Server.API.TLS.Enabled
set.Bool("server-api-tls-enabled", defaultServerAPITLSEnabled, "API server TLS state")
if err := viper.BindPFlag("Server.API.TLS.Enabled", set.Lookup("server-api-tls-enabled")); err != nil {
return err
}
// Server.API.TLS.KeyFile
set.String("server-api-tls-keyfile", defaultServerAPITLSKeyFile, "API server TLS private key file")
if err := viper.BindPFlag("Server.API.TLS.KeyFile", set.Lookup("server-api-tls-keyfile")); err != nil {
return err
}
return nil
}
func BindUIServerFlags(set *pflag.FlagSet) error {
// Server.UI.API.Host
// TODO
// Server.UI.API.Key
// TODO
// Server.UI.API.Port
// TODO
// Server.UI.API.TLS.Enabled
// TODO
// Server.UI.API.TLS.SkipVerify
// TODO
// Server.UI.Host
// TODO
// Server.UI.Password
// TODO
// Server.UI.Port
set.Int("server-ui-port", defaultServerUIPort, "UI server port")
if err := viper.BindPFlag("Server.UI.Port", set.Lookup("server-ui-port")); err != nil {
return err
}
// Server.UI.Username
// TODO
return fmt.Errorf("BindUIServerFlags not implemented")
}

View file

@ -0,0 +1,45 @@
package bottinagenda
import (
"context"
"log"
"net/http"
"git.agecem.com/bottin/bottin/v10/pkg/bottin"
"github.com/labstack/echo/v4"
)
func ReadHealthHandler(ctx context.Context, db *PostgresClient, bottinClient *bottin.APIClient) echo.HandlerFunc {
return func(c echo.Context) error {
select {
case <-ctx.Done():
//log.Fatal(ctx.Err())
return c.JSON(http.StatusInternalServerError, ErrorResponse{ctx.Err().Error()})
default:
var response ReadHealthResponse
response.Data.BottinAgenda.APIState = true
if db != nil {
if err := db.DB.Ping(ctx); err != nil {
log.Println("db:", err)
} else {
response.Data.BottinAgenda.DBState = true
}
}
if bottinClient != nil {
bottinHealthResponse, err := bottinClient.ReadHealth(ctx)
if err != nil {
log.Println("bottin health:", err)
} else {
response.Data.Bottin.APIState = true
response.Data.Bottin.DBState = bottinHealthResponse.Data.PostgresPing
}
}
return c.JSON(http.StatusOK, response)
}
}
}

View file

@ -0,0 +1,18 @@
package bottinagenda
type ErrorResponse struct {
Error string
}
type ReadHealthResponse struct {
Data struct {
Bottin struct {
APIState bool
DBState bool
}
BottinAgenda struct {
APIState bool
DBState bool
}
}
}

28
pkg/bottinagenda/route.go Normal file
View file

@ -0,0 +1,28 @@
package bottinagenda
import (
"context"
"fmt"
"git.agecem.com/bottin/bottin/v10/pkg/bottin"
"github.com/labstack/echo/v4"
)
func RegisterAPIRoutes(ctx context.Context, e *echo.Echo, db *PostgresClient, bottinClient *bottin.APIClient) error {
select {
case <-ctx.Done():
return fmt.Errorf("register api routes: %s", ctx.Err())
default:
if e == nil {
return fmt.Errorf("cannot register routes with nil *echo.Echo")
}
if db == nil {
return fmt.Errorf("cannot register routes with nil *PostgresClient")
}
e.GET("/v2/health/", ReadHealthHandler(ctx, db, bottinClient))
return nil
}
}

View file

@ -0,0 +1,86 @@
package bottinagenda
import (
"context"
"crypto/subtle"
"crypto/tls"
"fmt"
"io"
"net"
"net/http"
"strconv"
"codeberg.org/vlbeaudoin/voki/v3"
"git.agecem.com/bottin/bottin/v10/pkg/bottin"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func RunAPIServer(ctx context.Context, cfg Config, stdout io.Writer) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
e := echo.New()
e.Pre(middleware.AddTrailingSlash())
// middleware.KeyAuth
e.Use(middleware.KeyAuth(
func(key string, c echo.Context) (bool, error) {
return subtle.ConstantTimeCompare([]byte(key), []byte(cfg.Server.API.Key)) == 1, nil
}),
)
// bottin client
var httpClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: cfg.Server.API.Bottin.TLS.SkipVerify,
},
},
}
protocol := "http"
if cfg.Server.API.Bottin.TLS.Enabled {
protocol = "https"
}
bottinClient := &bottin.APIClient{Caller: voki.New(
httpClient,
cfg.Server.API.Bottin.Host,
cfg.Server.API.Bottin.Key,
cfg.Server.API.Bottin.Port,
protocol,
)}
defer bottinClient.Caller.CloseIdleConnections()
// db
pool, err := pgxpool.New(ctx, fmt.Sprintf("postgres://%s:%s@%s:%d/%s?sslmode=%s",
cfg.Server.API.Postgres.User,
cfg.Server.API.Postgres.Password,
cfg.Server.API.Postgres.Host,
cfg.Server.API.Postgres.Port,
cfg.Server.API.Postgres.Database,
cfg.Server.API.Postgres.SSLMode,
))
if err != nil {
return fmt.Errorf("db connect: %s", err)
}
db := &PostgresClient{pool}
//db.Init
//TODO
if err := RegisterAPIRoutes(ctx, e, db, bottinClient); err != nil {
return fmt.Errorf("register api routes: %s", err)
}
if cfg.Server.API.TLS.Enabled {
return e.StartTLS(net.JoinHostPort(cfg.Server.API.Host, strconv.Itoa(cfg.Server.API.Port)), cfg.Server.API.TLS.CertFile, cfg.Server.API.TLS.KeyFile)
}
return e.Start(net.JoinHostPort(cfg.Server.API.Host, strconv.Itoa(cfg.Server.API.Port)))
}
}

View file

@ -1,19 +0,0 @@
package bottinagenda
import (
"testing"
"git.agecem.com/bottin/bottin/pkg/bottin"
)
func TestBottinAPIClient(t *testing.T) {
var bottinClient bottin.APIClient
t.Run("message", func(t *testing.T) {
t.Log(bottinClient.Message())
})
}
func TestServer(t *testing.T) {
//go RunAPIServer
}