ironcore-dev / controller-utils Goto Github PK
View Code? Open in Web Editor NEWUtility library for writing Kubernetes controllers
License: Apache License 2.0
Utility library for writing Kubernetes controllers
License: Apache License 2.0
A violation against the OSS Rules of Play has been detected.
Rule ID: rl-reuse_tool-3
Explanation: Is it registered in REUSE? No
Find more information at: https://sap.github.io/fosstars-rating-core/oss_rules_of_play_rating.html
A violation against the OSS Rules of Play has been detected.
Rule ID: rl-vulnerability_alerts-1
Explanation: Are vulnerability alerts enabled? No
Find more information at: https://sap.github.io/fosstars-rating-core/oss_rules_of_play_rating.html
A violation against the OSS Rules of Play has been detected.
Rule ID: rl-reuse_tool-4
Explanation: Is it compliant with REUSE rules? No
Find more information at: https://sap.github.io/fosstars-rating-core/oss_rules_of_play_rating.html
When writing controller managers and webhooks, often you want to run the binary but enable and / or disable some of the
controllers or webhooks.
Kubernetes provides a nice-to use flag style to achieve exactly this (example can be found for kube-controller-manager
in
the --controllers
flag: https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/ ):
Their flag provides a set of entities that is enabled by default and it is possible to enable an entity by mentioning it in the flags
and to disable an entity by prefixing it with a dash (e.g. --controllers=*,-attachdetach
).
We should have an implementation of flag.Value
that, upon creation, allows passing in a list of names + a subset of that list as disabled-by-default names. After flag.Parse
(or whatever command line flag framework you're using), the value should have a method to check whether a name is enabled or not. If it doesn't know about a name, it should just return false
.
The using code (in the example using go's flag
package) should look something like this:
import (
...
"github.com/onmetal/controller-utils/cmdutils/switches"
)
controllers := switches.New([]string{"controller-a", "controller-b", "controller-c", switches.DisabledByDefault("controller-c"))
flag.Var(controllers, "controllers", fmt.Sprintf("Controllers to enable. All controllers: %v. Disabled-by-default controllers: %v", controllers.All(), controllers.DisabledByDefault())
flag.Parse()
if controllers.Enabled("controller-a") {
// setup controller-a with manager
}
cmdutils/switches
switches.Switches
entity that allows managing entitities to enable/disable like described aboveA violation against the OSS Rules of Play has been detected.
Rule ID: rl-assigned_teams-1
Explanation: Does it have enough teams on GitHub? No
Find more information at: https://sap.github.io/fosstars-rating-core/oss_rules_of_play_rating.html
A violation against the OSS Rules of Play has been detected.
Rule ID: rl-reuse_tool-2
Explanation: Does it have LICENSES directory with licenses? No
Find more information at: https://sap.github.io/fosstars-rating-core/oss_rules_of_play_rating.html
Would be nice o have a separate ReadFiles
function to be able read files from the specified folder including subfolders and having match function for filtering by file type/extension
type FileMatchFunc func(d fs.DirEntry) bool
func ReadFiles(root string, matchFun FileMatchFunc) ([]unstructured.Unstructured, error)
For tests it would be better to store multiple objects in separate files (for large objects it's a preferred way) and load them in one command without specify a separate files
A violation against the OSS Rules of Play has been detected.
Rule ID: rl-reuse_tool-1
Explanation: Does README mention REUSE? No
Find more information at: https://sap.github.io/fosstars-rating-core/oss_rules_of_play_rating.html
A violation against the OSS Rules of Play has been detected.
Rule ID: rl-vulnerability_alerts-1
Explanation: Are vulnerability alerts enabled? No
Find more information at: https://sap.github.io/fosstars-rating-core/oss_rules_of_play_rating.html
When working with Switches
, I discovered multiple issues we should resolve:
Type()
of Switches
should be strings
.String()
method of Switches
is not nice: It currently prints the map like map[string]bool{foo: true, bar: true}
. This should be formatted better.NewSwitches
should be renamed to New
. Additionally, there should be a method called Make
that does the same but returns Switches
instead of *Switches
. This improves ease of use in literals.kube-controller-manager
's controllers
.sets.String
of the currently enabled items (EnabledByDefault
?).Switches.All
does not return all switches, but only the ones that were enabled (?)
Switches.All
should return all available switch names.
There should also probably be a new method like Switches.Active
that returns all active switch names (probably that's what Switches.All
is doing but the name is currently misleading).
Switches.All
is fixed as mentioned aboveSwitches.All
works properlyA declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.