Comments (13)
@machi1990 walk me through it. Why would these be CLI flags? Why not be a mandatory config file deployed alongside the binary. It will be a build time artifact.
If I rephrase my proposal, let's externalize build time strings that vary from one fleet manager to another into a configuration file that is a build time artifact used and integrated in the fleet manager image.
from ffm-project.
Maybe we could explore leveraging the use of Go embed (available since Go 1.16 https://blog.jetbrains.com/go/2021/06/09/how-to-use-go-embed-in-go-1-16/) or go-bindata (https://github.com/go-bindata/go-bindata) for that.
Definitely something potentially worth exploring for some of those cases
from ffm-project.
from ffm-project.
also ccing @machi1990
from ffm-project.
I can see benefits in doing it for some things e.g API path, routes etc but I'll be cautious in doing it for all the TODO comments for a static string as some of those are not really meant to be configurable. I am saying that because we already have a lot of CLI flags, adding more for things that are only meant to be changed once is likely going to make it harder for the user on that aspect.
from ffm-project.
I agree with manyanda's comment
from ffm-project.
@machi1990 walk me through it. Why would these be CLI flags?
Because that's the way configuration are exposed at the moment in the template.
Why not be a mandatory config file deployed alongside the binary. It will be a build time artifact.
kas-fleet-manager did not have the classification of build time / runtime configuration as most configuration were more runtime in nature.
If I rephrase my proposal, let's externalize build time strings that vary from one fleet manager to another into a configuration file that is a build time artifact used and integrated in the fleet manager image.
Thanks for the clarification. @miguelsorianod comment #8 (comment) above could be something to explore. That might reduce the number of "TODO" in relation to static strings to possibly "just one" in this file.
from ffm-project.
I'd look at this to see what can be done.
from ffm-project.
Maybe we could explore leveraging the use of Go embed (available since Go 1.16 https://blog.jetbrains.com/go/2021/06/09/how-to-use-go-embed-in-go-1-16/) or go-bindata (https://github.com/go-bindata/go-bindata) for that. Definitely something potentially worth exploring for some of those cases
I've looking at this and what it means is:
- Define a configuration file where those constants will live
- Define a way to load the file during compilation time. The output of the loading will either be a string, bytes or special embedded data structure, this output will then need to be parsed into a struct (a container of these constants) that we can use in the code.
- Finally, pass the final struct throughout the codebase and use the needed constants.
The advantage is:
- The constants will be modified only in this configuration file
The disadvantage are:
- added complexity (see the workflow above) for constants that are only made to modified once (after the template has been cloned)
- Since the loaded file content will be parsed during runtime, the constants are not compilation time only, their value will be seen/evaluated during runtime
- Now we'll have two ways of defining configuration (via flags and this embed mechanism)
I am not convinced that this is the way we should go.
But still, having a TODO
comment on top of the hardcoded and not-commented constants is something we should look into addressing to make the template more approachable. For that, I was thinking of moving some of the constants ("the only ones that we expect that the use will need to change") in the constants directory, which just contains a bunch of golang files. Make sure that the usage of these values are documented/commented.
In the end, we could have something like: https://github.com/bf2fc6cc711aee1a0c2a/ffm-fleet-manager-go-template/blob/9026405f2185ec2f7fc22d8853114367eb67f9ef/internal/dinosaur/constants/dinosaur.go#L13-L48
@emmanuelbernard Let me know what you think about that proposal.
/cc @miguelsorianod
from ffm-project.
I've opened bf2fc6cc711aee1a0c2a/ffm-fleet-manager-go-template#23 to expose the API base path as a config.
from ffm-project.
I don't intuitively think go embed or go bin data is the way to go. @pmuir mgiht have some alternative ideas.
The proposal I had was, assuming one could read properties from a file at runtime, to have:
- a config file that holds all these "build time" or rather non SRE time properties
- have that config file be embedded into the fleet manager container image
- have this file be read at startup time of the fleet manager (from the container image) to parameterize the TODO properties.
from ffm-project.
I don't intuitively think go embed or go bin data is the way to go. @pmuir mgiht have some alternative ideas.
The proposal I had was, assuming one could read properties from a file at runtime, to have:
* a config file that holds all these "build time" or rather non SRE time properties * have that config file be embedded into the fleet manager container image * have this file be read at startup time of the fleet manager (from the container image) to parameterize the TODO properties.
What is the advantage of this approach over the embed or go-bindata approach?
If I understood correctly your comment, with both approaches the data is configured at build time. The difference is that the build time artifact where you attach that configuration file to. In the embed approach it is included in the binary, In the container approach it is included in the container image.
Additionally, with the container approach as you said the file would be read at runtime, whereas with go embed that wouldn't necessarily be the case, so on the performance side the embed approach would be more desirable.
Aside from that, is it really worth doing? The number of TODO constants does not seem very high, and an easier approach would just be centralize them in a .go file. What is the big advantage that we would get?
from ffm-project.
What is the advantage of this approach over the embed or go-bindata approach? If I understood correctly your comment, with both approaches the data is configured at build time. The difference is that the build time artifact where you attach that configuration file to. In the embed approach it is included in the binary, In the container approach it is included in the container image. Additionally, with the container approach as you said the file would be read at runtime, whereas with go embed that wouldn't necessarily be the case, so on the performance side the embed approach would be more desirable.
Aside from that, is it really worth doing? The number of TODO constants does not seem very high, and an easier approach would just be centralize them in a .go file. What is the big advantage that we would get?
Your description is correct.
One of the drawback of the embed / go-bindata approach is the more convoluted workflow @machi1990 described in his analysis, that is what I was mainly reacting to.
We can go for a centralized Go struct which would work great for a one off template. And it might not be too extra complicated to reapply the new version of the template due to the centralization.
Would this analysis be different in a future library model? It would not if you were to pass a Config
struct of sort in and use duck typing to accept that Config
object defined in the fleet manager to be accepted by the Config
structure defined in the library.
from ffm-project.
Related Issues (20)
- Create ADR with proposal for Authorization for factorized fleet Manager HOT 1
- Create the roadmap view documentation HOT 1
- Cluster Registration Service HOT 2
- Investigate and Document FleetShard Operator Patterns HOT 3
- User Facing Metrics Service HOT 7
- DNS Management Service HOT 2
- Publish the v0 of the template that's using SyncSet to deploy the service HOT 1
- Zullip link on communication page is incorrect HOT 1
- Skip all integration tests that are failing for now and add a note in the automated test guide HOT 1
- Add keycloak container setup for CI and local development
- Revise the keycloak service HOT 2
- Update the golang template automated tests documentation
- Backport some changes from kas-fleet-manager to the golang fleet manager template
- Document/Show a pattern on how to store sensitive data in the database
- Dynamic scaling
- backport makefile and cleanup changes from kas-fleet-manager
- Allow CORS option configurability
- API Definition for new Terraforming/Infrastructure/Fleet Management service
- Authorization for Fleet Managers
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 ffm-project.