From f596890185c2e5fce2a42acb3da54f2affe0e00e Mon Sep 17 00:00:00 2001 From: jt-dd Date: Wed, 9 Oct 2024 13:08:49 +0200 Subject: [PATCH 1/2] adding nocache flag for dev commands --- cmd/kubehound/dev.go | 4 +++- cmd/kubehound/server.go | 2 +- pkg/backend/containers.go | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/kubehound/dev.go b/cmd/kubehound/dev.go index e2cedcce1..eccc4c3a8 100644 --- a/cmd/kubehound/dev.go +++ b/cmd/kubehound/dev.go @@ -20,6 +20,7 @@ var ( var ( uiTesting bool grpcTesting bool + noCache bool downTesting bool profiles []string ) @@ -71,7 +72,7 @@ func runEnv(ctx context.Context, composePaths []string) error { return docker.Down(ctx) } - return docker.BuildUp(ctx) + return docker.BuildUp(ctx, noCache) } func init() { @@ -79,6 +80,7 @@ func init() { envCmd.PersistentFlags().BoolVar(&downTesting, "down", false, "Tearing down the kubehound dev stack and deleting the data associated with it") envCmd.Flags().BoolVar(&uiTesting, "ui", false, "Include the UI in the dev stack") envCmd.Flags().BoolVar(&grpcTesting, "grpc", false, "Include Grpc Server (ingestor) in the dev stack") + envCmd.Flags().BoolVar(&noCache, "no-cache", false, "Disable the cache when building the images") rootCmd.AddCommand(envCmd) } diff --git a/cmd/kubehound/server.go b/cmd/kubehound/server.go index 8c2884b5d..fbb395c8c 100644 --- a/cmd/kubehound/server.go +++ b/cmd/kubehound/server.go @@ -15,7 +15,7 @@ var ( Long: `instance of Kubehound that pulls data from cloud storage`, SilenceUsage: true, PersistentPreRunE: func(cobraCmd *cobra.Command, args []string) error { - return cmd.InitializeKubehoundConfig(cobraCmd.Context(), cfgFile, true, false) + return cmd.InitializeKubehoundConfig(cobraCmd.Context(), cfgFile, false, false) }, RunE: func(cobraCmd *cobra.Command, args []string) error { // Passing the Kubehound config from viper diff --git a/pkg/backend/containers.go b/pkg/backend/containers.go index 9d8726437..fd11ed7df 100644 --- a/pkg/backend/containers.go +++ b/pkg/backend/containers.go @@ -66,14 +66,14 @@ func newDockerCli() (*command.DockerCli, error) { return dockerCli, nil } -func BuildUp(ctx context.Context) error { - return currentBackend.buildUp(ctx) +func BuildUp(ctx context.Context, noCache bool) error { + return currentBackend.buildUp(ctx, noCache) } -func (b *Backend) buildUp(ctx context.Context) error { +func (b *Backend) buildUp(ctx context.Context, noCache bool) error { log.I.Infof("Building the kubehound stack") err := b.composeService.Build(ctx, b.project, api.BuildOptions{ - NoCache: true, + NoCache: noCache, Pull: true, }) if err != nil { From d2cca71ea876b6148d6ed2e639d0c0b9d1a8b94a Mon Sep 17 00:00:00 2001 From: jt-dd Date: Wed, 9 Oct 2024 13:37:58 +0200 Subject: [PATCH 2/2] typo build path --- deployments/kubehound/docker-compose.dev.ui.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/kubehound/docker-compose.dev.ui.yaml b/deployments/kubehound/docker-compose.dev.ui.yaml index 3daf69db2..6960f720a 100644 --- a/deployments/kubehound/docker-compose.dev.ui.yaml +++ b/deployments/kubehound/docker-compose.dev.ui.yaml @@ -1,7 +1,7 @@ name: kubehound-dev services: ui-jupyter: - build: ./notebook/ + build: ./ui/ restart: unless-stopped volumes: - ./notebook/shared:/root/notebooks/shared