Better error handling through stdout for the docker client package
- commit
- 09af87ff6a2ae146b1b2e47c56d3d0eb8a8ce370
- author
- bnema · · 2023-09-22 16:48 UTC
- parent
- a5a2735
- signature
- unsigned
3 files · +24 -82
M cmd/srv/main.go +2 -2
| @@ -27,7 +27,7 @@ func main() { | |||
| 27 | 27 | // Initialize database | |
| 28 | 28 | memDb, err := app.InitializeDB(a) | |
| 29 | 29 | if err != nil { | |
| 30 | - | log.Fatal(err) | |
| 30 | + | log.Fatal("Failed to initialize database:", err) | |
| 31 | 31 | } | |
| 32 | 32 | // Pass memDb to the app with the rest of the configs | |
| 33 | 33 | a.DB = memDb | |
| @@ -35,7 +35,7 @@ func main() { | |||
| 35 | 35 | dockerClient := &docker.DockerClient{} | |
| 36 | 36 | err = dockerClient.InitializeClient(a.Config.NewDockerConfig()) | |
| 37 | 37 | if err != nil { | |
| 38 | - | log.Printf("Error from DockerClient: %s", err) | |
| 38 | + | log.Printf("Error: %s", err) | |
| 39 | 39 | } | |
| 40 | 40 | // Setup a channel to capture termination signals | |
| 41 | 41 | sigs := make(chan os.Signal, 1) | |
| @@ -27,7 +27,7 @@ func main() { | |||||
| 27 | // Initialize database | 27 | // 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 configs | 32 | // Pass memDb to the app with the rest of the configs | ||
| 33 | a.DB = memDb | 33 | 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 signals | 40 | // 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 { | |||
| 575 | 575 | } | |
| 576 | 576 | } | |
| 577 | 577 | ||
| 578 | - | .relative { | |
| 579 | - | position: relative; | |
| 580 | - | } | |
| 581 | - | ||
| 582 | 578 | .my-2 { | |
| 583 | 579 | margin-top: 0.5rem; | |
| 584 | 580 | margin-bottom: 0.5rem; | |
| @@ -596,14 +592,14 @@ video { | |||
| 596 | 592 | margin-right: 0.5rem; | |
| 597 | 593 | } | |
| 598 | 594 | ||
| 599 | - | .mt-4 { | |
| 600 | - | margin-top: 1rem; | |
| 601 | - | } | |
| 602 | - | ||
| 603 | 595 | .mt-2 { | |
| 604 | 596 | margin-top: 0.5rem; | |
| 605 | 597 | } | |
| 606 | 598 | ||
| 599 | + | .mt-4 { | |
| 600 | + | margin-top: 1rem; | |
| 601 | + | } | |
| 602 | + | ||
| 607 | 603 | .flex { | |
| 608 | 604 | display: flex; | |
| 609 | 605 | } | |
| @@ -656,18 +652,6 @@ video { | |||
| 656 | 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 | 655 | .min-w-fit { | |
| 672 | 656 | min-width: -moz-fit-content; | |
| 673 | 657 | min-width: fit-content; | |
| @@ -737,10 +721,6 @@ video { | |||
| 737 | 721 | border-radius: 0.125rem; | |
| 738 | 722 | } | |
| 739 | 723 | ||
| 740 | - | .rounded { | |
| 741 | - | border-radius: 0.25rem; | |
| 742 | - | } | |
| 743 | - | ||
| 744 | 724 | .border { | |
| 745 | 725 | border-width: 1px; | |
| 746 | 726 | } | |
| @@ -754,11 +734,6 @@ video { | |||
| 754 | 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 | 737 | .bg-gordonmascot-hblue { | |
| 763 | 738 | --tw-bg-opacity: 1; | |
| 764 | 739 | background-color: rgb(1 30 92 / var(--tw-bg-opacity)); | |
| @@ -788,21 +763,6 @@ video { | |||
| 788 | 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 | 766 | .p-0 { | |
| 807 | 767 | padding: 0px; | |
| 808 | 768 | } | |
| @@ -830,20 +790,6 @@ video { | |||
| 830 | 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 | 793 | .text-2xl { | |
| 848 | 794 | font-size: 1.5rem; | |
| 849 | 795 | line-height: 2rem; | |
| @@ -874,14 +820,14 @@ video { | |||
| 874 | 820 | line-height: 1.75rem; | |
| 875 | 821 | } | |
| 876 | 822 | ||
| 877 | - | .font-semibold { | |
| 878 | - | font-weight: 600; | |
| 879 | - | } | |
| 880 | - | ||
| 881 | 823 | .font-bold { | |
| 882 | 824 | font-weight: 700; | |
| 883 | 825 | } | |
| 884 | 826 | ||
| 827 | + | .font-semibold { | |
| 828 | + | font-weight: 600; | |
| 829 | + | } | |
| 830 | + | ||
| 885 | 831 | .tracking-tighter { | |
| 886 | 832 | letter-spacing: -0.05em; | |
| 887 | 833 | } | |
| @@ -906,34 +852,24 @@ video { | |||
| 906 | 852 | color: rgb(31 41 55 / var(--tw-text-opacity)); | |
| 907 | 853 | } | |
| 908 | 854 | ||
| 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 { | |
| 920 | 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 | 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 | 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 | 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 | 875 | .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 ( | |||
| 4 | 4 | "context" | |
| 5 | 5 | "fmt" | |
| 6 | 6 | "log" | |
| 7 | + | "os" | |
| 7 | 8 | ||
| 8 | 9 | "github.com/docker/docker/client" | |
| 9 | 10 | ) | |
| @@ -28,6 +29,11 @@ func (d *DockerClient) InitializeClient(config *Config) error { | |||
| 28 | 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 | 37 | // Initialize Docker client | |
| 32 | 38 | cli, err := client.NewClientWithOpts( | |
| 33 | 39 | 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 client | 37 | // Initialize Docker client | ||
| 32 | cli, err := client.NewClientWithOpts( | 38 | cli, err := client.NewClientWithOpts( | ||
| 33 | client.WithAPIVersionNegotiation(), | 39 | client.WithAPIVersionNegotiation(), | ||