detached 506e858

Better error handling through stdout for the docker client package

commit
506e8587e7f02f53597e1ab77b22d92eebfc07a3
author
bnema · · 2023-09-22 16:48 UTC
parent
90e1dbf
signature
unsigned
3 files · +24 -82
M cmd/srv/main.go +2 -2
@@ -27,7 +27,7 @@ func main() {
2727 // Initialize database
2828 memDb, err := app.InitializeDB(a)
2929 if err != nil {
30- log.Fatal(err)
30+ log.Fatal("Failed to initialize database:", err)
3131 }
3232 // Pass memDb to the app with the rest of the configs
3333 a.DB = memDb
@@ -35,7 +35,7 @@ func main() {
3535 dockerClient := &docker.DockerClient{}
3636 err = dockerClient.InitializeClient(a.Config.NewDockerConfig())
3737 if err != nil {
38- log.Printf("Error from DockerClient: %s", err)
38+ log.Printf("Error: %s", err)
3939 }
4040 // Setup a channel to capture termination signals
4141 sigs := make(chan os.Signal, 1)
@@ -27,7 +27,7 @@ func main() {
27 // Initialize database27 // Initialize database
28 memDb, err := app.InitializeDB(a)28 memDb, err := app.InitializeDB(a)
29 if err != nil {29 if err != nil {
30- log.Fatal(err)30+ log.Fatal("Failed to initialize database:", err)
31 }31 }
32 // Pass memDb to the app with the rest of the configs32 // Pass memDb to the app with the rest of the configs
33 a.DB = memDb33 a.DB = memDb
@@ -35,7 +35,7 @@ func main() {
35 dockerClient := &docker.DockerClient{}35 dockerClient := &docker.DockerClient{}
36 err = dockerClient.InitializeClient(a.Config.NewDockerConfig())36 err = dockerClient.InitializeClient(a.Config.NewDockerConfig())
37 if err != nil {37 if err != nil {
38- log.Printf("Error from DockerClient: %s", err)38+ log.Printf("Error: %s", err)
39 }39 }
40 // Setup a channel to capture termination signals40 // Setup a channel to capture termination signals
41 sigs := make(chan os.Signal, 1)41 sigs := make(chan os.Signal, 1)
M internal/webui/public/assets/css/tailwind.css +16 -80
@@ -575,10 +575,6 @@ video {
575575 }
576576 }
577577
578-.relative {
579- position: relative;
580-}
581-
582578 .my-2 {
583579 margin-top: 0.5rem;
584580 margin-bottom: 0.5rem;
@@ -596,14 +592,14 @@ video {
596592 margin-right: 0.5rem;
597593 }
598594
599-.mt-4 {
600- margin-top: 1rem;
601-}
602-
603595 .mt-2 {
604596 margin-top: 0.5rem;
605597 }
606598
599+.mt-4 {
600+ margin-top: 1rem;
601+}
602+
607603 .flex {
608604 display: flex;
609605 }
@@ -656,18 +652,6 @@ video {
656652 width: 100%;
657653 }
658654
659-.w-1\/4 {
660- width: 25%;
661-}
662-
663-.w-1\/6 {
664- width: 16.666667%;
665-}
666-
667-.w-2\/4 {
668- width: 50%;
669-}
670-
671655 .min-w-fit {
672656 min-width: -moz-fit-content;
673657 min-width: fit-content;
@@ -737,10 +721,6 @@ video {
737721 border-radius: 0.125rem;
738722 }
739723
740-.rounded {
741- border-radius: 0.25rem;
742-}
743-
744724 .border {
745725 border-width: 1px;
746726 }
@@ -754,11 +734,6 @@ video {
754734 border-color: rgb(209 213 219 / var(--tw-border-opacity));
755735 }
756736
757-.border-red-400 {
758- --tw-border-opacity: 1;
759- border-color: rgb(248 113 113 / var(--tw-border-opacity));
760-}
761-
762737 .bg-gordonmascot-hblue {
763738 --tw-bg-opacity: 1;
764739 background-color: rgb(1 30 92 / var(--tw-bg-opacity));
@@ -788,21 +763,6 @@ video {
788763 background-color: rgb(228 228 231 / var(--tw-bg-opacity));
789764 }
790765
791-.bg-green-500 {
792- --tw-bg-opacity: 1;
793- background-color: rgb(34 197 94 / var(--tw-bg-opacity));
794-}
795-
796-.bg-red-500 {
797- --tw-bg-opacity: 1;
798- background-color: rgb(239 68 68 / var(--tw-bg-opacity));
799-}
800-
801-.bg-red-100 {
802- --tw-bg-opacity: 1;
803- background-color: rgb(254 226 226 / var(--tw-bg-opacity));
804-}
805-
806766 .p-0 {
807767 padding: 0px;
808768 }
@@ -830,20 +790,6 @@ video {
830790 padding-bottom: 0.5rem;
831791 }
832792
833-.py-1 {
834- padding-top: 0.25rem;
835- padding-bottom: 0.25rem;
836-}
837-
838-.py-3 {
839- padding-top: 0.75rem;
840- padding-bottom: 0.75rem;
841-}
842-
843-.align-baseline {
844- vertical-align: baseline;
845-}
846-
847793 .text-2xl {
848794 font-size: 1.5rem;
849795 line-height: 2rem;
@@ -874,14 +820,14 @@ video {
874820 line-height: 1.75rem;
875821 }
876822
877-.font-semibold {
878- font-weight: 600;
879-}
880-
881823 .font-bold {
882824 font-weight: 700;
883825 }
884826
827+.font-semibold {
828+ font-weight: 600;
829+}
830+
885831 .tracking-tighter {
886832 letter-spacing: -0.05em;
887833 }
@@ -906,34 +852,24 @@ video {
906852 color: rgb(31 41 55 / var(--tw-text-opacity));
907853 }
908854
909-.text-slate-100 {
910- --tw-text-opacity: 1;
911- color: rgb(241 245 249 / var(--tw-text-opacity));
912-}
913-
914-.text-white {
915- --tw-text-opacity: 1;
916- color: rgb(255 255 255 / var(--tw-text-opacity));
917-}
918-
919-.text-red-800 {
855+.text-red-500 {
920856 --tw-text-opacity: 1;
921- color: rgb(153 27 27 / var(--tw-text-opacity));
857+ color: rgb(239 68 68 / var(--tw-text-opacity));
922858 }
923859
924-.text-red-700 {
860+.text-red-600 {
925861 --tw-text-opacity: 1;
926- color: rgb(185 28 28 / var(--tw-text-opacity));
862+ color: rgb(220 38 38 / var(--tw-text-opacity));
927863 }
928864
929-.text-red-500 {
865+.text-slate-100 {
930866 --tw-text-opacity: 1;
931- color: rgb(239 68 68 / var(--tw-text-opacity));
867+ color: rgb(241 245 249 / var(--tw-text-opacity));
932868 }
933869
934-.text-red-600 {
870+.text-white {
935871 --tw-text-opacity: 1;
936- color: rgb(220 38 38 / var(--tw-text-opacity));
872+ color: rgb(255 255 255 / var(--tw-text-opacity));
937873 }
938874
939875 .underline {
@@ -575,10 +575,6 @@ video {
575 }575 }
576 }576 }
577 577
578-.relative {
579- position: relative;
580-}
581-
582 .my-2 {578 .my-2 {
583 margin-top: 0.5rem;579 margin-top: 0.5rem;
584 margin-bottom: 0.5rem;580 margin-bottom: 0.5rem;
@@ -596,14 +592,14 @@ video {
596 margin-right: 0.5rem;592 margin-right: 0.5rem;
597 }593 }
598 594
599-.mt-4 {
600- margin-top: 1rem;
601-}
602-
603 .mt-2 {595 .mt-2 {
604 margin-top: 0.5rem;596 margin-top: 0.5rem;
605 }597 }
606 598
599+.mt-4 {
600+ margin-top: 1rem;
601+}
602+
607 .flex {603 .flex {
608 display: flex;604 display: flex;
609 }605 }
@@ -656,18 +652,6 @@ video {
656 width: 100%;652 width: 100%;
657 }653 }
658 654
659-.w-1\/4 {
660- width: 25%;
661-}
662-
663-.w-1\/6 {
664- width: 16.666667%;
665-}
666-
667-.w-2\/4 {
668- width: 50%;
669-}
670-
671 .min-w-fit {655 .min-w-fit {
672 min-width: -moz-fit-content;656 min-width: -moz-fit-content;
673 min-width: fit-content;657 min-width: fit-content;
@@ -737,10 +721,6 @@ video {
737 border-radius: 0.125rem;721 border-radius: 0.125rem;
738 }722 }
739 723
740-.rounded {
741- border-radius: 0.25rem;
742-}
743-
744 .border {724 .border {
745 border-width: 1px;725 border-width: 1px;
746 }726 }
@@ -754,11 +734,6 @@ video {
754 border-color: rgb(209 213 219 / var(--tw-border-opacity));734 border-color: rgb(209 213 219 / var(--tw-border-opacity));
755 }735 }
756 736
757-.border-red-400 {
758- --tw-border-opacity: 1;
759- border-color: rgb(248 113 113 / var(--tw-border-opacity));
760-}
761-
762 .bg-gordonmascot-hblue {737 .bg-gordonmascot-hblue {
763 --tw-bg-opacity: 1;738 --tw-bg-opacity: 1;
764 background-color: rgb(1 30 92 / var(--tw-bg-opacity));739 background-color: rgb(1 30 92 / var(--tw-bg-opacity));
@@ -788,21 +763,6 @@ video {
788 background-color: rgb(228 228 231 / var(--tw-bg-opacity));763 background-color: rgb(228 228 231 / var(--tw-bg-opacity));
789 }764 }
790 765
791-.bg-green-500 {
792- --tw-bg-opacity: 1;
793- background-color: rgb(34 197 94 / var(--tw-bg-opacity));
794-}
795-
796-.bg-red-500 {
797- --tw-bg-opacity: 1;
798- background-color: rgb(239 68 68 / var(--tw-bg-opacity));
799-}
800-
801-.bg-red-100 {
802- --tw-bg-opacity: 1;
803- background-color: rgb(254 226 226 / var(--tw-bg-opacity));
804-}
805-
806 .p-0 {766 .p-0 {
807 padding: 0px;767 padding: 0px;
808 }768 }
@@ -830,20 +790,6 @@ video {
830 padding-bottom: 0.5rem;790 padding-bottom: 0.5rem;
831 }791 }
832 792
833-.py-1 {
834- padding-top: 0.25rem;
835- padding-bottom: 0.25rem;
836-}
837-
838-.py-3 {
839- padding-top: 0.75rem;
840- padding-bottom: 0.75rem;
841-}
842-
843-.align-baseline {
844- vertical-align: baseline;
845-}
846-
847 .text-2xl {793 .text-2xl {
848 font-size: 1.5rem;794 font-size: 1.5rem;
849 line-height: 2rem;795 line-height: 2rem;
@@ -874,14 +820,14 @@ video {
874 line-height: 1.75rem;820 line-height: 1.75rem;
875 }821 }
876 822
877-.font-semibold {
878- font-weight: 600;
879-}
880-
881 .font-bold {823 .font-bold {
882 font-weight: 700;824 font-weight: 700;
883 }825 }
884 826
827+.font-semibold {
828+ font-weight: 600;
829+}
830+
885 .tracking-tighter {831 .tracking-tighter {
886 letter-spacing: -0.05em;832 letter-spacing: -0.05em;
887 }833 }
@@ -906,34 +852,24 @@ video {
906 color: rgb(31 41 55 / var(--tw-text-opacity));852 color: rgb(31 41 55 / var(--tw-text-opacity));
907 }853 }
908 854
909-.text-slate-100 {855+.text-red-500 {
910- --tw-text-opacity: 1;
911- color: rgb(241 245 249 / var(--tw-text-opacity));
912-}
913-
914-.text-white {
915- --tw-text-opacity: 1;
916- color: rgb(255 255 255 / var(--tw-text-opacity));
917-}
918-
919-.text-red-800 {
920 --tw-text-opacity: 1;856 --tw-text-opacity: 1;
921- color: rgb(153 27 27 / var(--tw-text-opacity));857+ color: rgb(239 68 68 / var(--tw-text-opacity));
922 }858 }
923 859
924-.text-red-700 {860+.text-red-600 {
925 --tw-text-opacity: 1;861 --tw-text-opacity: 1;
926- color: rgb(185 28 28 / var(--tw-text-opacity));862+ color: rgb(220 38 38 / var(--tw-text-opacity));
927 }863 }
928 864
929-.text-red-500 {865+.text-slate-100 {
930 --tw-text-opacity: 1;866 --tw-text-opacity: 1;
931- color: rgb(239 68 68 / var(--tw-text-opacity));867+ color: rgb(241 245 249 / var(--tw-text-opacity));
932 }868 }
933 869
934-.text-red-600 {870+.text-white {
935 --tw-text-opacity: 1;871 --tw-text-opacity: 1;
936- color: rgb(220 38 38 / var(--tw-text-opacity));872+ color: rgb(255 255 255 / var(--tw-text-opacity));
937 }873 }
938 874
939 .underline {875 .underline {
M pkg/utils/docker/client.go +6 -0
@@ -4,6 +4,7 @@ import (
44 "context"
55 "fmt"
66 "log"
7+ "os"
78
89 "github.com/docker/docker/client"
910 )
@@ -28,6 +29,11 @@ func (d *DockerClient) InitializeClient(config *Config) error {
2829 return fmt.Errorf("Sock field in Config is empty")
2930 }
3031
32+ // Check if the socket file exists if not return an error
33+ if _, err := os.Stat(config.Sock); os.IsNotExist(err) {
34+ return fmt.Errorf("Sock file does not exist: %s", config.Sock)
35+ }
36+
3137 // Initialize Docker client
3238 cli, err := client.NewClientWithOpts(
3339 client.WithAPIVersionNegotiation(),
@@ -4,6 +4,7 @@ import (
4 "context"4 "context"
5 "fmt"5 "fmt"
6 "log"6 "log"
7+ "os"
7 8
8 "github.com/docker/docker/client"9 "github.com/docker/docker/client"
9 )10 )
@@ -28,6 +29,11 @@ func (d *DockerClient) InitializeClient(config *Config) error {
28 return fmt.Errorf("Sock field in Config is empty")29 return fmt.Errorf("Sock field in Config is empty")
29 }30 }
30 31
32+ // Check if the socket file exists if not return an error
33+ if _, err := os.Stat(config.Sock); os.IsNotExist(err) {
34+ return fmt.Errorf("Sock file does not exist: %s", config.Sock)
35+ }
36+
31 // Initialize Docker client37 // Initialize Docker client
32 cli, err := client.NewClientWithOpts(38 cli, err := client.NewClientWithOpts(
33 client.WithAPIVersionNegotiation(),39 client.WithAPIVersionNegotiation(),

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close