### Quick Start: File Provider Configuration Source: https://github.com/crazy-max/diun/blob/master/docs/providers/file.md This example demonstrates a minimal setup for the file provider, including the main Diun configuration and the content of the image list YAML file. ```yaml db: path: diun.db watch: workers: 20 schedule: "0 */6 * * *" regopts: - name: "docker.bintray.io" selector: image username: foo password: bar providers: file: filename: /path/to/config.yml ``` ```yaml # /path/to/config.yml - name: crazymax/cloudflared watch_repo: true - name: docker.bintray.io/jfrog/xray-mongo:3.2.6 ``` -------------------------------- ### Install Profile Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/pkg/profile/README.md Use 'go get' to install the profile package. ```bash go get github.com/pkg/profile ``` -------------------------------- ### Install doublestar Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/bmatcuk/doublestar/v3/README.md Install the doublestar package using go get. Ensure you are using the correct version (v2 in this example). ```bash go get github.com/bmatcuk/doublestar/v2 ``` -------------------------------- ### Install goquery Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/PuerkitoBio/goquery/README.md Use go get to install the goquery library. This command fetches and installs the package and its dependencies. ```bash go get github.com/PuerkitoBio/goquery ``` -------------------------------- ### Install Mimetype Library Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/gabriel-vasile/mimetype/README.md Use 'go get' to install the mimetype library. ```bash go get github.com/gabriel-vasile/mimetype ``` -------------------------------- ### Install Zerolog Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/rs/zerolog/README.md Use 'go get' to install the zerolog logger package. ```bash go get -u github.com/rs/zerolog/log ``` -------------------------------- ### Install Match Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/tidwall/match/README.md Use 'go get' to install the Match package. This command fetches and installs the latest version. ```bash go get -u github.com/tidwall/match ``` -------------------------------- ### Install go-urn Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/leodido/go-urn/README.md Use 'go get' to install the go-urn library. This command fetches and installs the package and its dependencies. ```go go get github.com/leodido/go-urn ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/mattn/go-isatty/README.md Install the go-isatty package using the go get command. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Install go-playground/locales Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/go-playground/locales/README.md Use 'go get' to install the locales package. ```shell go get github.com/go-playground/locales ``` -------------------------------- ### Install go.yaml.in/yaml/v3 Source: https://github.com/crazy-max/diun/blob/master/vendor/go.yaml.in/yaml/v3/README.md Use 'go get' to install the package. The import path is go.yaml.in/yaml/v3. ```bash go get go.yaml.in/yaml/v3 ``` -------------------------------- ### Install sigs.k8s.io/yaml Source: https://github.com/crazy-max/diun/blob/master/vendor/sigs.k8s.io/yaml/README.md Use 'go get' to install the package. Import it using the provided import path. ```bash $ go get sigs.k8s.io/yaml ``` -------------------------------- ### Install bom package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/ssor/bom/README.md Use 'go get' to install the bom package. ```sh go get github.com/ssor/bom ``` -------------------------------- ### Install GJSON Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/tidwall/gjson/README.md Install the GJSON library using the Go get command. ```sh go get -u github.com/tidwall/gjson ``` -------------------------------- ### Install MQTT Go Client using GOPATH Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/eclipse/paho.mqtt.golang/README.md Use this command to install the MQTT Go client if you are not using modules. ```bash go get github.com/eclipse/paho.mqtt.golang ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/crazy-max/diun/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs and runs a local Go Doc site for previewing documentation. Ensure you have the latest version installed. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install uniseg Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/rivo/uniseg/README.md Use 'go get' to install the uniseg package. This command fetches and installs the package and its dependencies. ```bash go get github.com/rivo/uniseg ``` -------------------------------- ### Get the Project with Go Get Source: https://github.com/crazy-max/diun/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md This command fetches the project and places it in your GOPATH. Ignore any warnings about build constraints. ```go go get -d go.opentelemetry.io/otel ``` -------------------------------- ### Install mapstructure Go Library Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/mitchellh/mapstructure/README.md Use standard go get to install the mapstructure library. ```bash go get github.com/mitchellh/mapstructure ``` -------------------------------- ### Install xstrings Go Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/huandu/xstrings/README.md Use the go get command to install the xstrings library. This command fetches and installs the package, making it available for use in your Go projects. ```go go get github.com/huandu/xstrings ``` -------------------------------- ### Install Go Validator Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/go-playground/validator/v10/README.md Use 'go get' to install the validator package. Then import it into your Go code. ```go go get github.com/go-playground/validator/v10 ``` ```go import "github.com/go-playground/validator/v10" ``` -------------------------------- ### Install Pretty Go Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/tidwall/pretty/README.md Use 'go get' to install the Pretty package. This command retrieves the library for use in your Go projects. ```sh go get -u github.com/tidwall/pretty ``` -------------------------------- ### Install HashiCorp Cron Expression Parser Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/hashicorp/cronexpr/README.md Install the library using the go get command. ```bash go get github.com/gorhill/cronexpr ``` -------------------------------- ### Install Gonfig Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/crazy-max/gonfig/README.md Use 'go get' to add the gonfig library to your Go project. ```go go get github.com/crazy-max/gonfig ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/crazy-max/diun/blob/master/docs/contributing.md Run this command to download and install the necessary project dependencies using Go modules. ```shell go mod download ``` -------------------------------- ### Install ansi Go Library Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/mgutz/ansi/README.md Use 'go get' to install the ansi library. This command fetches and installs the latest version of the package. ```sh go get -u github.com/mgutz/ansi ``` -------------------------------- ### Install blackfriday-tool Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/russross/blackfriday/v2/README.md Download and install the blackfriday-tool command-line utility using go get. This tool provides a standalone way to process markdown files. ```bash go get github.com/russross/blackfriday-tool ``` -------------------------------- ### Install jsonreference Library Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/go-openapi/jsonreference/README.md Use this command to get the jsonreference library for your Go project. ```cmd go get github.com/go-openapi/jsonreference ``` -------------------------------- ### Install go-colorable Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/mattn/go-colorable/README.md Install the go-colorable package using the go get command. This is a prerequisite for using the package in your Go projects. ```bash go get github.com/mattn/go-colorable ``` -------------------------------- ### Install Gorilla Mux Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/gorilla/mux/README.md Install the gorilla/mux package using the go get command. Ensure your Go toolchain is correctly configured. ```sh go get -u github.com/gorilla/mux ``` -------------------------------- ### Install yaml.v3 Package Source: https://github.com/crazy-max/diun/blob/master/vendor/gopkg.in/yaml.v3/README.md Use 'go get' to install the yaml.v3 package for use in your Go projects. ```bash go get gopkg.in/yaml.v3 ``` -------------------------------- ### Install tablewriter Go Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/olekukonko/tablewriter/README.md Use 'go get' to install the tablewriter package. This is the standard way to add Go packages to your project. ```go go get github.com/olekukonko/tablewriter ``` -------------------------------- ### Input Prompt Example Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/AlecAivazis/survey/v2/README.md A basic example of using the Input prompt to get a single string value from the user. The answer is stored in the provided variable. ```go name := "" prompt := &survey.Input{ Message: "ping", } survey.AskOne(prompt, &name) ``` -------------------------------- ### Install Blackfriday v2 Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/russross/blackfriday/v2/README.md Install the Blackfriday v2 package using go get. This command resolves and adds the package to your module and builds it. ```bash go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### Install Mergo Source: https://github.com/crazy-max/diun/blob/master/vendor/dario.cat/mergo/README.md Use this command to get the Mergo library. Import it in your Go code. ```go go get dario.cat/mergo // use in your .go code import ( "dario.cat/mergo" ) ``` -------------------------------- ### Install html2text Go Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/jaytaylor/html2text/README.md Use 'go get' to download and install the html2text package. Requires Go 1.x or newer. ```bash go get jaytaylor.com/html2text ``` -------------------------------- ### Watch Configuration Example Source: https://github.com/crazy-max/diun/blob/master/docs/config/watch.md This is a comprehensive example of the watch configuration block in a YAML file. ```yaml watch: workers: 10 schedule: "0 */6 * * *" jitter: 30s firstCheckNotif: false runOnStartup: true compareDigest: true healthchecks: baseURL: https://hc-ping.com/ uuid: 5bf66975-d4c7-4bf5-bcc8-b8d8a82ea278 ``` -------------------------------- ### Install Mergo Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/imdario/mergo/README.md Use this command to get the Mergo library for your Go project. ```go go get github.com/imdario/mergo ``` -------------------------------- ### Install Dependencies using GOPATH Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/eclipse/paho.mqtt.golang/README.md Install the necessary proxy and websockets packages if you are using GOPATH. ```bash go get github.com/gorilla/websocket go get golang.org/x/net/proxy ``` -------------------------------- ### Start Diun CLI in v4.17 Source: https://github.com/crazy-max/diun/blob/master/docs/migration/v4.0-to-v4.17.md From v4.17 onwards, the 'serve' command is introduced to start Diun, requiring the configuration file path. ```shell diun serve --config diun.yml ``` -------------------------------- ### Start Diun CLI in v4.0 Source: https://github.com/crazy-max/diun/blob/master/docs/migration/v4.0-to-v4.17.md In v4.0, Diun was started by directly invoking the binary with the configuration file path. ```shell diun --config diun.yml ``` -------------------------------- ### Start Diun Server Source: https://github.com/crazy-max/diun/blob/master/docs/usage/command-line.md Starts the Diun server with specified configuration and log level. ```shell diun serve --config diun.yml --log-level debug ``` -------------------------------- ### Install Hermes Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/matcornic/hermes/v2/README.md Install the Hermes package using go get. Starting from v2.0.0, Hermes uses Go modules and requires Go 1.11+. ```bash go get -u github.com/matcornic/hermes/v2 ``` -------------------------------- ### Example Dockerfile with Image Instructions Source: https://github.com/crazy-max/diun/blob/master/docs/providers/dockerfile.md This Dockerfile demonstrates how to use FROM, COPY --from, and RUN --mount=type=bind,from instructions to specify images that Diun should analyze. Metadata comments like `# diun.platform` can also be used to control analysis. ```Dockerfile # syntax=docker/dockerfile:1.2 # diun.platform=linux/amd64 # diun.metadata.foo=bar FROM alpine:latest # diun.watch_repo=true # diun.max_tags=10 # diun.platform=linux/amd64 COPY --from=crazymax/yasu / / # diun.watch_repo=true # diun.include_tags=^\d+\.\d+\.\d+$ # diun.platform=linux/amd64 RUN --mount=type=bind,target=.,rw \ --mount=type=bind,from=crazymax/docker:20.10.6,source=/usr/local/bin/docker,target=/usr/bin/docker \ yasu --version ``` -------------------------------- ### Install bbolt Command Line Utility Source: https://github.com/crazy-max/diun/blob/master/vendor/go.etcd.io/bbolt/README.md Install the bbolt command line utility. The utility will be placed in your $GOBIN path. ```sh go run go.etcd.io/bbolt/cmd/bbolt@latest ``` ```sh go install go.etcd.io/bbolt/cmd/bbolt@latest ``` -------------------------------- ### Full Example of a Mux Server Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/gorilla/mux/README.md A complete, runnable example of a basic HTTP server using Gorilla Mux. This demonstrates setting up a router and defining a simple handler for the root path. ```go package main import ( "net/http" "log" "github.com/gorilla/mux" ) func YourHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Gorilla!\n")) } func main() { r := mux.NewRouter() // Routes consist of a path and a handler function. r.HandleFunc("/", YourHandler) // Bind to a port and pass our router in log.Fatal(http.ListenAndServe(":8000", r)) } ``` -------------------------------- ### Install GoHealthchecks Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/crazy-max/gohealthchecks/README.md Install the GoHealthchecks library using go get. ```bash go get github.com/crazy-max/gohealthchecks ``` -------------------------------- ### Diun Configuration File Example (diun.yml) Source: https://github.com/crazy-max/diun/blob/master/docs/config/index.md This example demonstrates a comprehensive `diun.yml` configuration file, covering database settings, watch parameters, notification preferences, registry options, and provider-specific configurations. ```yaml db: path: diun.db watch: workers: 10 schedule: "0 */6 * * *" jitter: 30s firstCheckNotif: false runOnStartup: true defaults: watchRepo: false notifyOn: - new - update sortTags: reverse notif: amqp: host: localhost port: 5672 username: guest password: guest queue: queue gotify: endpoint: http://gotify.foo.com token: Token123456 priority: 1 timeout: 10s mail: host: localhost port: 25 ssl: false insecureSkipVerify: false from: diun@example.com to: - webmaster@example.com - me@example.com ntfy: endpoint: https://ntfy.sh topic: diun-acce65a0-b777-46f9-9a11-58c67d1579c4 priority: 3 timeout: 5s rocketchat: endpoint: http://rocket.foo.com:3000 channel: "#general" userID: abcdEFGH012345678 token: Token123456 timeout: 10s script: cmd: "myprogram" args: - "--anarg" - "another" slack: webhookURL: https://hooks.slack.com/services/ABCD12EFG/HIJK34LMN/01234567890abcdefghij teams: webhookURL: https://outlook.office.com/webhook/ABCD12EFG/HIJK34LMN/01234567890abcdefghij telegram: token: aabbccdd:11223344 chatIDs: - 123456789 - 987654321 webhook: endpoint: http://webhook.foo.com/sd54qad89azd5a method: GET headers: content-type: application/json authorization: Token123456 timeout: 10s regopts: - name: "myregistry" username: foo password: bar timeout: 20s insecureTLS: true - name: "docker.io" selector: image username: foo2 password: bar2 providers: docker: watchStopped: true swarm: watchByDefault: true kubernetes: namespaces: - default - production file: directory: ./imagesdir nomad: watchByDefault: true ``` -------------------------------- ### List All Docker Containers using Go Client Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/docker/docker/client/README.md This example demonstrates how to list all containers on a Docker host, including stopped ones, using the Go Docker client library. It requires setting up the client from environment variables and handles potential errors during client initialization and container listing. ```go package main import ( "context" "fmt" "github.com/docker/docker/api/types/container" "github.com/docker/docker/client" ) func main() { apiClient, err := client.NewClientWithOpts(client.FromEnv) if err != nil { panic(err) } defer apiClient.Close() containers, err := apiClient.ContainerList(context.Background(), container.ListOptions{All: true}) if err != nil { panic(err) } for _, ctr := range containers { fmt.Printf("%s %s (status: %s)\n", ctr.ID, ctr.Image, ctr.Status) } } ``` -------------------------------- ### Install go-openapi/jsonpointer Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/go-openapi/jsonpointer/README.md Use this command to add the library to your Go project. ```cmd go get github.com/go-openapi/jsonpointer ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/json-iterator/go/README.md Use go get to install the json-iterator/go package for your project. ```bash go get github.com/json-iterator/go ``` -------------------------------- ### Basic Table Rendering in Go Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/jedib0t/go-pretty/v6/table/EXAMPLES.md Demonstrates the fundamental steps to create and render a table with headers, rows, separators, and a footer. The output is mirrored to standard output. ```go package main import ( "os" "github.com/jedib0t/go-pretty/v6/table" ) func main() { t := table.NewWriter() t.SetOutputMirror(os.Stdout) t.AppendHeader(table.Row{"#", "First Name", "Last Name", "Salary"}) t.AppendRows([]table.Row{ {1, "Arya", "Stark", 3000}, {20, "Jon", "Snow", 2000, "You know nothing, Jon Snow!"}, }) t.AppendSeparator() t.AppendRow([]interface{}{300, "Tyrion", "Lannister", 5000}) t.AppendFooter(table.Row{"", "", "Total", 10000}) t.Render() } ``` -------------------------------- ### Install Universal Translator Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/go-playground/universal-translator/README.md Use 'go get' to install the Universal Translator package. ```shell go get github.com/go-playground/universal-translator ``` -------------------------------- ### Create Root Logger Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/go-logr/logr/README.md Demonstrates how to create the root logger early in an application's lifecycle, choosing a specific logging implementation. ```go func main() { // ... other setup code ... // Create the "root" logger. We have chosen the "logimpl" implementation, // which takes some initial parameters and returns a logr.Logger. logger := logimpl.New(param1, param2) // ... other setup code ... } ``` -------------------------------- ### Coexist klog/v1 and klog/v2 Source: https://github.com/crazy-max/diun/blob/master/vendor/k8s.io/klog/v2/README.md Example demonstrating how to use both klog/v1 and klog/v2 simultaneously within the same project. ```go import ( "k8s.io/klog/v1" "k8s.io/klog/v2" ) func main() { klogv1.InitFlags(nil) klogv2.InitFlags(nil) klogv1.Info("message from klog/v1") klogv2.Info("message from klog/v2") } ``` -------------------------------- ### Install uuid Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/google/uuid/README.md Use this command to install the uuid package using go get. ```sh go get github.com/google/uuid ``` -------------------------------- ### Simple Logging Example Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/rs/zerolog/README.md Demonstrates basic logging with zerolog, setting the time field format to Unix time. Log messages are written to os.Stderr by default. ```go package main import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) func main() { // UNIX Time is faster and smaller than most timestamps zerolog.TimeFieldFormat = zerolog.TimeFormatUnix log.Print("hello world") } // Output: {"time":1516134303,"level":"debug","message":"hello world"} ``` -------------------------------- ### Configure Run on Startup Source: https://github.com/crazy-max/diun/blob/master/docs/config/watch.md Set to `true` to check for updates when Diun starts. The default is `true`. ```yaml watch: runOnStartup: true ``` -------------------------------- ### Install bbolt Source: https://github.com/crazy-max/diun/blob/master/vendor/go.etcd.io/bbolt/README.md Install the bbolt library using go get. This command updates your go.mod and go.sum files. ```sh go get go.etcd.io/bbolt@latest ``` -------------------------------- ### Basic Survey Example Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/AlecAivazis/survey/v2/README.md Demonstrates how to ask a series of questions and store the answers in a struct. Supports required fields, transformations, and type conversions. ```go package main import ( "fmt" "github.com/AlecAivazis/survey/v2" ) // the questions to ask var qs = []*survey.Question{ { Name: "name", Prompt: &survey.Input{Message: "What is your name?"}, Validate: survey.Required, Transform: survey.Title, }, { Name: "color", Prompt: &survey.Select{ Message: "Choose a color:", Options: []string{"red", "blue", "green"}, Default: "red", }, }, { Name: "age", Prompt: &survey.Input{Message: "How old are you?"}, }, } func main() { // the answers will be written to this struct answers := struct { Name string // survey will match the question and field names FavoriteColor string `survey:"color"` // or you can tag fields to match a specific name Age int // if the types don't match, survey will convert it }{} // perform the questions err := survey.Ask(qs, &answers) if err != nil { fmt.Println(err.Error()) return } fmt.Printf("%s chose %s.", answers.Name, answers.FavoriteColor) } ``` -------------------------------- ### Running Diun with File Provider Source: https://github.com/crazy-max/diun/blob/master/docs/providers/file.md This shows the command to start the Diun service with a specified configuration file and the expected log output indicating image analysis. ```bash $ diun serve --config diun.yml Sat, 14 Dec 2019 15:32:23 UTC INF Starting Diun 2.0.0 Sat, 14 Dec 2019 15:32:23 UTC INF Found 2 image(s) to analyze... provider=file Sat, 14 Dec 2019 15:32:25 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:latest provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.11.3 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.11.0 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.10.1 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.9.0 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.9.2 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.10.2 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.11.2 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.9.1 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=crazymax/cloudflared image=docker.io/crazymax/cloudflared:2019.10.4 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF New image found id=docker.bintray.io/jfrog/xray-mongo:3.2.6 image=docker.bintray.io/jfrog/xray-mongo:3.2.6 provider=file Sat, 14 Dec 2019 15:32:28 UTC INF Cron initialized with schedule 0 */6 * * * Sat, 14 Dec 2019 15:32:28 UTC INF Next run in 31 seconds (2019-12-14 15:33:00 +0000 UTC) ``` -------------------------------- ### Install Carbon v2 via GitCode Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/dromara/carbon/v2/README.md Install the Carbon v2 package using go get from GitCode. Ensure your Go version is 1.18 or higher. ```go go get -u gitcode.com/dromara/carbon/v2 import "gitcode.com/dromara/gitcode/v2" ``` -------------------------------- ### Install Carbon v2 via Gitee Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/dromara/carbon/v2/README.md Install the Carbon v2 package using go get from Gitee. Ensure your Go version is 1.18 or higher. ```go go get -u gitee.com/dromara/carbon/v2 import "gitee.com/dromara/carbon/v2" ``` -------------------------------- ### Install Carbon v2 via GitHub Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/dromara/carbon/v2/README.md Install the Carbon v2 package using go get from GitHub. Ensure your Go version is 1.18 or higher. ```go go get -u github.com/dromara/carbon/v2 import "github.com/dromara/carbon/v2" ``` -------------------------------- ### Basic HTTP Server Setup for Profiling Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/felixge/fgprof/README.md Set up a basic HTTP server to expose the standard Go profiling endpoint. This is often used in conjunction with other profiling tools. ```go import _ "net/http/pprof" func main() { go func() { log.Println(http.ListenAndServe(":6060", nil)) }() // } ``` -------------------------------- ### Install Cron v3 Package Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/crazy-max/cron/v3/README.md Use this command to install the Cron v3 package using go get. This is the standard way to add Go packages to your project. ```bash go get github.com/crazy-max/cron/v3 ``` -------------------------------- ### DIUN Configuration Example (Environment Variables) Source: https://github.com/crazy-max/diun/blob/master/docs/config/index.md This shows the equivalent environment variables for the DIUN YAML configuration. Each setting in the YAML file has a corresponding environment variable. ```shell DIUN_DB_PATH=diun.db DIUN_WATCH_WORKERS=10 DIUN_WATCH_SCHEDULE=0 */6 * * * DIUN_WATCH_JITTER=30s DIUN_WATCH_FIRSTCHECKNOTIF=false DIUN_WATCH_RUNONSTARTUP=true DIUN_DEFAULTS_WATCHREPO=false DIUN_DEFAULTS_NOTIFYON=new,update DIUN_DEFAULTS_SORTTAGS=reverse DIUN_NOTIF_GOTIFY_ENDPOINT=http://gotify.foo.com DIUN_NOTIF_GOTIFY_TOKEN=Token123456 DIUN_NOTIF_GOTIFY_PRIORITY=1 DIUN_NOTIF_GOTIFY_TIMEOUT=10s DIUN_NOTIF_NTFY_ENDPOINT=https://ntfy.sh DIUN_NOTIF_NTFY_TOPIC=diun-acce65a0-b777-46f9-9a11-58c67d1579c4 DIUN_NOTIF_NTFY_TAGS=whale DIUN_NOTIF_NTFY_TIMEOUT=10s DIUN_NOTIF_TELEGRAM_TOKEN=aabbccdd:11223344 DIUN_NOTIF_TELEGRAM_CHATIDS=123456789,987654321 DIUN_NOTIF_WEBHOOK_ENDPOINT=http://webhook.foo.com/sd54qad89azd5a DIUN_NOTIF_WEBHOOK_METHOD=GET DIUN_NOTIF_WEBHOOK_HEADERS_CONTENT-TYPE=application/json DIUN_NOTIF_WEBHOOK_HEADERS_AUTHORIZATION=Token123456 DIUN_NOTIF_WEBHOOK_TIMEOUT=10s DIUN_REGOPTS_0_NAME=docker.io DIUN_REGOPTS_0_SELECTOR=image DIUN_REGOPTS_0_USERNAME=foo DIUN_REGOPTS_0_PASSWORD=bar DIUN_REGOPTS_1_NAME=registry.gitlab.com DIUN_REGOPTS_1_SELECTOR=image DIUN_REGOPTS_1_USERNAME=fii DIUN_REGOPTS_1_PASSWORD=bor DIUN_REGOPTS_1_TIMEOUT=20s DIUN_PROVIDERS_KUBERNETES_TLSINSECURE=false DIUN_PROVIDERS_KUBERNETES_NAMESPACES=default,production ``` -------------------------------- ### Install Latest JSON-Patch v5 Source: https://github.com/crazy-max/diun/blob/master/vendor/gopkg.in/evanphx/json-patch.v4/README.md Use this command to get the latest version of the json-patch library. ```bash go get -u github.com/evanphx/json-patch/v5 ``` -------------------------------- ### View Diun Logs Source: https://github.com/crazy-max/diun/blob/master/docs/providers/docker.md Command to follow the logs of the Diun container after starting the Docker Compose setup. This helps in observing the image analysis process. ```bash $ docker compose logs -f Attaching to bin_diun_1, cloudflared cloudflared | time="2019-12-14T15:30:07+01:00" level=info msg="Adding DNS upstream" url="https://1.1.1.1/dns-query" cloudflared | time="2019-12-14T15:30:07+01:00" level=info msg="Adding DNS upstream" url="https://1.0.0.1/dns-query" cloudflared | time="2019-12-14T15:30:07+01:00" level=info msg="Starting metrics server" addr="[::]:49312" cloudflared | time="2019-12-14T15:30:07+01:00" level=info msg="Starting DNS over HTTPS proxy server" addr="dns://0.0.0.0:5053" diun_1 | Sat, 14 Dec 2019 15:30:07 CET INF Starting Diun v2.0.0 diun_1 | Sat, 14 Dec 2019 15:30:07 CET INF Found 1 image(s) to analyze provider=docker diun_1 | Sat, 14 Dec 2019 15:30:10 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:latest provider=docker diun_1 | Sat, 14 Dec 2019 15:30:12 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.9.0 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:12 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.9.1 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:12 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.9.2 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:12 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.10.1 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:12 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.10.4 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:12 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.10.2 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:12 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.11.0 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:12 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.11.3 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:13 CET INF New image found id=mydocker image=docker.io/crazymax/cloudflared:2019.11.2 provider=docker diun_1 | Sat, 14 Dec 2019 15:30:13 CET INF Cron initialized with schedule 0 */6 * * * diun_1 | Sat, 14 Dec 2019 15:30:13 CET INF Next run in 2 hours 29 minutes (2019-12-14 16:00:00 +0100 CET) ``` -------------------------------- ### Get Nested Array Values in Go Source: https://github.com/crazy-max/diun/blob/master/vendor/github.com/tidwall/gjson/README.md Access values within nested arrays using the '#.key' path syntax. This example demonstrates retrieving all last names from a list of programmers. ```Go result := gjson.Get(json, "programmers.#.lastName") for _, name := range result.Array() { println(name.String()) } ``` ```Go name := gjson.Get(json, `programmers.#(lastName="Hunter").firstName`) println(name.String()) // prints "Elliotte" ```