Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func runLogsOperator(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

// Create kubectl command with context
kubectlCmd := exec.CommandContext(ctx, "kubectl", kubectlArgs...)

// Get stdout pipe for streaming
Expand All @@ -69,20 +68,15 @@ func runLogsOperator(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to create stdout pipe: %w", err)
}

// Pass through stderr directly
kubectlCmd.Stderr = os.Stderr

// Start the command
if err := kubectlCmd.Start(); err != nil {
return fmt.Errorf("failed to start kubectl: %w", err)
}

// Process stdout with color coding
processLogStream(stdout)

// Wait for command to complete
if err := kubectlCmd.Wait(); err != nil {
// Check if it was a timeout
if ctx.Err() == context.DeadlineExceeded {
return fmt.Errorf("timeout connecting to cluster - ensure your kubeconfig is correct and the cluster is reachable")
}
Expand All @@ -99,7 +93,6 @@ func runLogsOperator(cmd *cobra.Command, args []string) error {
func processLogStream(reader io.Reader) {
scanner := bufio.NewScanner(reader)

// Define colors for different log levels
infoColor := color.New(color.FgWhite)
debugColor := color.New(color.Faint)
errorColor := color.New(color.FgRed, color.Bold)
Expand All @@ -108,7 +101,6 @@ func processLogStream(reader io.Reader) {
for scanner.Scan() {
line := scanner.Text()

// Determine log level and apply appropriate color
switch {
case strings.Contains(line, "ERROR"):
errorColor.Println(line)
Expand Down
158 changes: 73 additions & 85 deletions internal/deployer/deploy_via_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (d *Deployer) createCentralValues(resourcesName, exposure string) (map[stri
func (d *Deployer) createSecuredClusterValues(clusterName, resources string) (map[string]interface{}, error) {
base := map[string]interface{}{
"clusterName": clusterName,
"centralEndpoint": "https://central.acs-central.svc:443",
"centralEndpoint": "https://central." + centralNamespace + ".svc:443",
"allowNonstandardNamespace": true,
}

Expand Down Expand Up @@ -318,102 +318,90 @@ func (d *Deployer) getCentralExposureConfigHelm(exposure string) map[string]inte

// getCentralResourcesHelm returns resource overlays for Central Helm deployment
func (d *Deployer) getCentralResourcesHelm(resourcesName string) map[string]interface{} {
resourcesSmall := map[string]interface{}{
"central": map[string]interface{}{
"resources": centralResourcesSmall,
"db": map[string]interface{}{
"resources": centralDbResourcesSmall,
},
},
"scanner": map[string]interface{}{
"resources": centralScannerResourcesSmall,
"dbResources": centralScannerDbResourcesSmall,
},
"scannerV4": map[string]interface{}{
"indexer": map[string]interface{}{
"resources": centralScannerV4IndexerResourcesSmall,
},
"matcher": map[string]interface{}{
"resources": centralScannerV4MatcherResourcesSmall,
switch resourcesName {
case "small":
return map[string]interface{}{
"central": map[string]interface{}{
"resources": centralResourcesSmall,
"db": map[string]interface{}{
"resources": centralDbResourcesSmall,
},
},
"db": map[string]interface{}{
"resources": centralScannerV4DbResourcesSmall,
"scanner": map[string]interface{}{
"resources": centralScannerResourcesSmall,
"dbResources": centralScannerDbResourcesSmall,
},
},
}

resourcesMedium := map[string]interface{}{
"central": map[string]interface{}{
"resources": centralResourcesMedium,
"db": map[string]interface{}{
"resources": centralDbResourcesMedium,
"scannerV4": map[string]interface{}{
"indexer": map[string]interface{}{
"resources": centralScannerV4IndexerResourcesSmall,
},
"matcher": map[string]interface{}{
"resources": centralScannerV4MatcherResourcesSmall,
},
"db": map[string]interface{}{
"resources": centralScannerV4DbResourcesSmall,
},
},
},
"scanner": map[string]interface{}{
"resources": centralScannerResourcesMedium,
"dbResources": centralScannerDbResourcesMedium,
},
"scannerV4": map[string]interface{}{
"indexer": map[string]interface{}{
"resources": centralScannerV4IndexerResourcesMedium,
}
case "medium":
return map[string]interface{}{
"central": map[string]interface{}{
"resources": centralResourcesMedium,
"db": map[string]interface{}{
"resources": centralDbResourcesMedium,
},
},
"matcher": map[string]interface{}{
"resources": centralScannerV4MatcherResourcesMedium,
"scanner": map[string]interface{}{
"resources": centralScannerResourcesMedium,
"dbResources": centralScannerDbResourcesMedium,
},
"db": map[string]interface{}{
"resources": centralScannerV4DbResourcesMedium,
"scannerV4": map[string]interface{}{
"indexer": map[string]interface{}{
"resources": centralScannerV4IndexerResourcesMedium,
},
"matcher": map[string]interface{}{
"resources": centralScannerV4MatcherResourcesMedium,
},
"db": map[string]interface{}{
"resources": centralScannerV4DbResourcesMedium,
},
},
},
}

var resources map[string]interface{}

switch resourcesName {
case "small":
resources = resourcesSmall
case "medium":
resources = resourcesMedium
}
default:
return nil
}

return resources
}

// getSecuredClusterResourcesHelm returns resource overlays for SecuredCluster Helm deployment
func (d *Deployer) getSecuredClusterResourcesHelm(resourcesName string) map[string]interface{} {
resourcesSmall := map[string]interface{}{
"sensor": map[string]interface{}{
"resources": securedClusterSensorResourcesSmall,
},
"scanner": map[string]interface{}{
"disable": true,
},
"scannerV4": map[string]interface{}{
"disable": true,
},
}

resourcesMedium := map[string]interface{}{
"sensor": map[string]interface{}{
"resources": securedClusterSensorResourcesMedium,
},
"scanner": map[string]interface{}{
"disable": true,
},
"scannerV4": map[string]interface{}{
"disable": true,
},
}

var resources map[string]interface{}

switch resourcesName {
case "small":
resources = resourcesSmall
return map[string]interface{}{
"sensor": map[string]interface{}{
"resources": securedClusterSensorResourcesSmall,
},
"scanner": map[string]interface{}{
"disable": true,
},
"scannerV4": map[string]interface{}{
"disable": true,
},
}
case "medium":
resources = resourcesMedium
return map[string]interface{}{
"sensor": map[string]interface{}{
"resources": securedClusterSensorResourcesMedium,
},
"scanner": map[string]interface{}{
"disable": true,
},
"scannerV4": map[string]interface{}{
"disable": true,
},
}
default:
return nil
}

return resources
}

// verifyHelmChartImages renders the Helm template and verifies that images are pullable
Expand All @@ -431,7 +419,7 @@ func (d *Deployer) verifyHelmChartImages(ctx context.Context, chartDir, valuesFi
return fmt.Errorf("failed to render helm template: %w", err)
}

imageRefs := extractImageReferences(string(output))
imageRefs := extractMainImageReferences(string(output))

if len(imageRefs) == 0 {
d.logger.Warning("No images found in rendered template")
Expand All @@ -451,8 +439,8 @@ func (d *Deployer) verifyHelmChartImages(ctx context.Context, chartDir, valuesFi
return nil
}

// extractImageReferences extracts unique image references from rendered YAML
func extractImageReferences(renderedYAML string) []string {
// extractMainImageReferences extracts unique image references from rendered YAML
func extractMainImageReferences(renderedYAML string) []string {
seen := make(map[string]bool)
var images []string

Expand Down
Loading
Loading