Skip to content

configuration diff view for harbor config apply command with interactive confirmation prompt#568

Merged
Vad1mo merged 8 commits into
goharbor:mainfrom
qcserestipy:557_null_configs
Nov 11, 2025
Merged

configuration diff view for harbor config apply command with interactive confirmation prompt#568
Vad1mo merged 8 commits into
goharbor:mainfrom
qcserestipy:557_null_configs

Conversation

@qcserestipy

@qcserestipy qcserestipy commented Nov 5, 2025

Copy link
Copy Markdown
Collaborator

Closes #557

Description

Implements a configuration diff view for harbor config apply command with interactive confirmation prompt.

Changes

New Features

  • AWS CDK-style diff output: Color-coded change visualization with [+] additions, [~] modifications, and [-] deletions
  • Interactive confirmation prompt: Users must explicitly confirm changes with y/N (safe default: No)
  • --yes flag: Skip confirmation for CI/CD automation (-y short form also supported)
  • Change summary: Shows count of additions, modifications, and deletions at the top
  • Smart filtering: Only shows fields explicitly set in the local config file (partial configs supported)

Implementation Details

  • Added DiffConfigurations() view in pkg/views/configurations/diff/view.go
  • Updated ApplyConfigCmd() to use the new diff view
  • Added ExtractConfigValues() utility to normalize *models.ConfigurationsResponse into flat maps
  • Styled output using charmbracelet/lipgloss for consistent terminal colors

Visual Output

Configuration changes to be applied:

[+] 1 to add  [~] 2 to modify

[+] OIDCClientID
    └─ "harbor-client"

[~] AuthMode
    [-] "db_auth"
    [+] "ldap_auth"

[~] TokenExpiration
    [-] 30
    [+] 60

Do you want to apply these changes? (y/N): 

Usage

Interactive mode (default)

harbor config apply -f config.yaml
# Shows diff, prompts for confirmation

Auto-apply mode (CI/CD)

harbor config apply -f config.yaml --yes
# Skips confirmation prompt

Partial configuration files

# config.yaml - only specify fields you want to change
auth_mode: ldap_auth
token_expiration: 60

Screenshots

Screen.Recording.2025-11-05.at.10.54.27.mov
Screenshot 2025-11-05 at 14 38 52

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
-add templated function to extract config values from different models
-add view for diff in color coded fashion
-add user prompt for applied diff, if canceled not applied

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
@qcserestipy qcserestipy requested a review from bupd November 5, 2025 10:09
@codecov

codecov Bot commented Nov 5, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 154 lines in your changes missing coverage. Please review.
✅ Project coverage is 6.53%. Comparing base (60ad0bd) to head (6705449).
⚠️ Report is 54 commits behind head on main.

Files with missing lines Patch % Lines
pkg/views/configurations/diff/view.go 0.00% 94 Missing ⚠️
cmd/harbor/root/configurations/apply.go 0.00% 30 Missing ⚠️
pkg/utils/reflect.go 0.00% 30 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #568      +/-   ##
=========================================
- Coverage   10.99%   6.53%   -4.46%     
=========================================
  Files         173     259      +86     
  Lines        8671   12677    +4006     
=========================================
- Hits          953     828     -125     
- Misses       7612   11743    +4131     
  Partials      106     106              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the idea of showing the modifications before applying

lgtm

@Vad1mo Vad1mo merged commit 906c147 into goharbor:main Nov 11, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Applying config with empty fields throws error

3 participants