mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
The last argoproj dependency. notifications-engine was 49 files / 920K and backed a subsystem with ZERO live workloads and ZERO Applications carrying notification annotations, while hanzoai/notify v1.7.2 is already embedded in cloud. Two ways to notify, one of them dead and pulling a dependency. Deleted: cmd/cd-notification, notification_controller/, server/notification/, util/notification/, the admin CLI command, hack/gen-catalog (generated the service catalog), the gen-docs notification pass, and the wiring in server.go and cmd/main.go. github.com/argoproj now appears ZERO times in go.mod. Both live argoproj dependencies are gone — pkg/v2 internalized in the previous commit, notifications-engine deleted here. go build ./... exit 0. Co-authored-by: Hanzo Dev <[email protected]>
85 lines
2.1 KiB
Go
85 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"os"
|
|
"sort"
|
|
"strings"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
|
|
)
|
|
|
|
func main() {
|
|
}
|
|
|
|
|
|
func updateMkDocsNav(parent string, child string, subchild string, files []string) error {
|
|
trimPrefixes(files, "docs/")
|
|
sort.Strings(files)
|
|
data, err := os.ReadFile("mkdocs.yml")
|
|
if err != nil {
|
|
return fmt.Errorf("error reading mkdocs.yml: %w", err)
|
|
}
|
|
var un unstructured.Unstructured
|
|
if e := yaml.Unmarshal(data, &un.Object); e != nil {
|
|
return e
|
|
}
|
|
nav := un.Object["nav"].([]any)
|
|
rootitem, _ := findNavItem(nav, parent)
|
|
if rootitem == nil {
|
|
return fmt.Errorf("can't find '%s' root item in mkdoc.yml", parent)
|
|
}
|
|
rootnavitemmap := rootitem.(map[any]any)
|
|
childnav, _ := findNavItem(rootnavitemmap[parent].([]any), child)
|
|
if childnav == nil {
|
|
return fmt.Errorf("can't find '%s' chile item under '%s' parent item in mkdoc.yml", child, parent)
|
|
}
|
|
|
|
childnavmap := childnav.(map[any]any)
|
|
childnavitems := childnavmap[child].([]any)
|
|
|
|
childnavitems = removeNavItem(childnavitems, subchild)
|
|
commands := make(map[string]any)
|
|
commands[subchild] = files
|
|
childnavmap[child] = append(childnavitems, commands)
|
|
newmkdocs, err := yaml.Marshal(un.Object)
|
|
if err != nil {
|
|
return fmt.Errorf("error in marshaling final configmap: %w", err)
|
|
}
|
|
|
|
// The marshaller drops custom tags, so re-add this one. Turns out this is much less invasive than trying to handle
|
|
// it at the YAML parser level.
|
|
newmkdocs = bytes.Replace(newmkdocs, []byte("site_url: READTHEDOCS_CANONICAL_URL"), []byte("site_url: !ENV READTHEDOCS_CANONICAL_URL"), 1)
|
|
|
|
return os.WriteFile("mkdocs.yml", newmkdocs, 0o644)
|
|
}
|
|
|
|
func trimPrefixes(files []string, prefix string) {
|
|
for i, f := range files {
|
|
files[i] = strings.TrimPrefix(f, prefix)
|
|
}
|
|
}
|
|
|
|
func findNavItem(nav []any, key string) (any, int) {
|
|
for i, item := range nav {
|
|
o, ismap := item.(map[any]any)
|
|
if ismap {
|
|
if _, ok := o[key]; ok {
|
|
return o, i
|
|
}
|
|
}
|
|
}
|
|
return nil, -1
|
|
}
|
|
|
|
func removeNavItem(nav []any, key string) []any {
|
|
_, i := findNavItem(nav, key)
|
|
if i != -1 {
|
|
nav = append(nav[:i], nav[i+1:]...)
|
|
}
|
|
return nav
|
|
}
|