mirror of
https://github.com/lukaszraczylo/jobs-manager-operator.git
synced 2026-06-11 23:09:15 +00:00
Multiple fixes (#29)
* Multiple fixes - add goreleaser to the build / release process - add kubectl plugin for job graphs visualization - add installation scripts - update dependencies * Update the release & CRD content. * Next set of improvements. Code Quality - Label constants: Added LabelWorkflowName, LabelGroupName, LabelJobName, LabelJobID in controllers/definitions.go - Removed commented debug code: Cleaned up dead code from multiple files - Removed unused dependencyTree field: Cleaned connPackage struct - Fixed snake_case variables: Changed to camelCase (runGroup, groupDep, runJob, jobDep, k8sJob) Kubernetes Best Practices - Finalizers: Implemented handleDeletion() and deleteChildJobs() for proper cleanup - Status enum validation: Added +kubebuilder:validation:Enum=pending;running;succeeded;failed;aborted - ImagePullPolicy default: Created getImagePullPolicy() helper that defaults to IfNotPresent - Resource limits support: Added Resources *corev1.ResourceRequirements to ManagedJobParameters Observability - Prometheus metrics: Created controllers/metrics.go with counters (jobs created/succeeded/failed), histogram (reconciliation duration), and gauge (active jobs) - Structured logging: Added logger field to connPackage, used context-based logging throughout Configuration - Leader election ID: Made configurable via --leader-election-id flag - Development mode: Made configurable via --dev-mode flag and LOG_LEVEL env var Performance - Dependency lookup optimization: Changed from O(n*m) to O(1) using lookup maps (jobDepMap, groupDepMap) - Reconciliation backoff: Added RequeueAfter: 30*time.Second when workflow is running Documentation & Testing - Godoc documentation: Added comprehensive comments to API types and controller - Unit tests: Added helpers_test.go with tests for all helper functions - Integration tests: Added managedjob_controller_test.go with Ginkgo/Gomega tests * Add the helm chart release. * Add reasonable test coverage.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package visualization
|
||||
|
||||
// StatusTree represents a tree node with text and execution status
|
||||
type StatusTree struct {
|
||||
text string
|
||||
status string
|
||||
items []*StatusTree
|
||||
}
|
||||
|
||||
// NewStatusTree creates a new StatusTree node
|
||||
func NewStatusTree(text string) *StatusTree {
|
||||
return &StatusTree{
|
||||
text: text,
|
||||
items: make([]*StatusTree, 0),
|
||||
}
|
||||
}
|
||||
|
||||
// NewStatusTreeWithStatus creates a new StatusTree node with a status
|
||||
func NewStatusTreeWithStatus(text, status string) *StatusTree {
|
||||
return &StatusTree{
|
||||
text: text,
|
||||
status: status,
|
||||
items: make([]*StatusTree, 0),
|
||||
}
|
||||
}
|
||||
|
||||
// Add creates and appends a child node, returning it for chaining
|
||||
func (t *StatusTree) Add(text string) *StatusTree {
|
||||
child := NewStatusTree(text)
|
||||
t.items = append(t.items, child)
|
||||
return child
|
||||
}
|
||||
|
||||
// AddWithStatus creates and appends a child node with status
|
||||
func (t *StatusTree) AddWithStatus(text, status string) *StatusTree {
|
||||
child := NewStatusTreeWithStatus(text, status)
|
||||
t.items = append(t.items, child)
|
||||
return child
|
||||
}
|
||||
|
||||
// Items returns all child nodes
|
||||
func (t *StatusTree) Items() []*StatusTree {
|
||||
return t.items
|
||||
}
|
||||
|
||||
// Text returns the node's text value
|
||||
func (t *StatusTree) Text() string {
|
||||
return t.text
|
||||
}
|
||||
|
||||
// Status returns the node's status value
|
||||
func (t *StatusTree) Status() string {
|
||||
return t.status
|
||||
}
|
||||
Reference in New Issue
Block a user