Skip to content

feat/Add: Configuration command to Manage System Configuration#114

Closed
bupd wants to merge 2 commits into
goharbor:mainfrom
bupd:configuration
Closed

feat/Add: Configuration command to Manage System Configuration#114
bupd wants to merge 2 commits into
goharbor:mainfrom
bupd:configuration

Conversation

@bupd

@bupd bupd commented Jun 9, 2024

Copy link
Copy Markdown
Member

Overview:

This pull request adds the config command, a vital enhancement for managing system configurations. The command is designed to fetch, update and store the system configuration in the Harbor config file, ensuring that the current configuration of the system is easily accessible and manageable.

Key Features:

  • Fetch System Configuration: Retrieves the complete system configuration.
  • Store Configuration: Saves the fetched configuration to the Harbor config file, providing a centralized location for configuration management.

Motivation and Context:

Managing system configurations is a fundamental task for system administrators. The current cli lacks the configuration management. By introducing the config command, we aim to streamline configuration management, making it easier for administrators to access and update system settings.

New Commands:

  • config get -- This command fetches and stores the system config in the harbor config file.
  • config update -- This command updates the system config based on provided harbor config file.

Fix: #94 #113 #438

This command fetches and stores the system config in the harbor config
file.

Signed-off-by: bupd <bupdprasanth@gmail.com>
@bupd bupd changed the title feat/Add: ` command feat/Add: Configuration command to Manage System Configuration Jun 9, 2024
@bupd bupd marked this pull request as draft June 9, 2024 19:30
@bupd

bupd commented Jun 9, 2024

Copy link
Copy Markdown
Member Author

Screenshots:

Config Get:

configGet

Config Update:

configUpdate

Note:

config will be udpated based on the config file by default

@bupd bupd marked this pull request as ready for review June 9, 2024 21:52
Signed-off-by: bupd <bupdprasanth@gmail.com>
@bupd bupd force-pushed the configuration branch from 3f93ace to a4fa7c3 Compare June 9, 2024 23:52
@bupd bupd mentioned this pull request Jun 10, 2024
4 tasks
@Jellyfrog

Copy link
Copy Markdown

Is there anything preventing this from being merged? (Except for the merge conflict)

@bupd bupd linked an issue Dec 28, 2024 that may be closed by this pull request
@Vad1mo Vad1mo requested a review from Copilot April 22, 2025 13:21
@Vad1mo Vad1mo added the Changes Requesed feedback that must be addressed before merging. label Apr 22, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces a configuration management command to the Harbor CLI, allowing users to fetch and update system configurations via new CLI commands.

  • Introduces conversion helpers for transforming API responses to configuration structs.
  • Adds new utility functions for reading from and writing to the Harbor configuration file.
  • Integrates "config get" and "config update" commands into the CLI command hierarchy.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/views/config/update/view.go Adds a conversion function for configuration responses
pkg/utils/config.go Adds utility functions for managing the Harbor configuration file
pkg/api/config_handler.go Implements API handlers for getting and updating system configurations
cmd/harbor/root/config.go Introduces new CLI commands for configuration management
cmd/harbor/root/cmd.go Registers the new config command in the CLI

Comment thread pkg/utils/config.go

func AddConfigToConfigFile(config *models.ConfigurationsResponse, configPath string) error {
if _, err := os.Stat(configPath); os.IsNotExist(err) {
return err

Copilot AI Apr 22, 2025

Copy link

Choose a reason for hiding this comment

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

Consider using the existing CreateConfigFile() utility to create the configuration file when it does not exist, rather than immediately returning an error.

Suggested change
return err
if err := CreateConfigFile(); err != nil {
return err
}

Copilot uses AI. Check for mistakes.
@Vad1mo

Vad1mo commented Apr 22, 2025

Copy link
Copy Markdown
Member

@bupd @rizul2108, we need to rename the current/existing config command to context, otherwise we have a conflict with registry config, which make more sense.

  • we also agreed to allow the import of json/yaml config input files.

@Vad1mo

Vad1mo commented Apr 22, 2025

Copy link
Copy Markdown
Member

The Harbor config sub-commands should have

  • authentication ( with similar functionalities as on the WebUI)
  • security (as in WebUI)
  • System Settings (as in webUI) --> (rename to) system
harbor-cli config authentication ..
harbor-cli config security ..
harbor-cli config system ..

@bupd

bupd commented Jul 15, 2025

Copy link
Copy Markdown
Member Author

@qcserestipy we could use your help here. Thanks

@bupd bupd assigned qcserestipy and bupd and unassigned rizul2108 Jul 15, 2025
@qcserestipy

Copy link
Copy Markdown
Collaborator

@bupd I continued working on this branch in qcserestipy/rework-bupd-pr-114 and will open a draft PR within the next days. Do you think there is a good way how we can filter according to those three categories:

harbor-cli config authentication ..
harbor-cli config security ..
harbor-cli config system ..

as suggested by @Vad1mo. I would be happy about some ideas for filtering. One of my ideas was creating some categorization as a global var. Which I think is not optimal in case the api specification changes.

// pkg/utils/config_categories.go
package utils

var ConfigurationCategories = map[string]string{
    // Authentication
    "AuthMode":                     "authentication",
    "LdapBaseDn":                   "authentication", 
    "LdapFilter":                   "authentication",
    "LdapSearchDn":                 "authentication",
    "LdapSearchPassword":           "authentication",
    "LdapUID":                      "authentication",
    "LdapURL":                      "authentication",
    "OIDCClientID":                 "authentication",
    "OIDCClientSecret":             "authentication",
    "OIDCEndpoint":                 "authentication",
    "UaaClientID":                  "authentication",
    "UaaClientSecret":              "authentication",
    "HTTPAuthproxyEndpoint":        "authentication",
    "PrimaryAuthMode":              "authentication",
    
    // Security
    "LdapVerifyCert":               "security",
    "OIDCVerifyCert":               "security",
    "UaaVerifyCert":                "security",
    "HTTPAuthproxyVerifyCert":      "security",
    "SelfRegistration":             "security",
    "ProjectCreationRestriction":   "security",
    "RobotTokenDuration":           "security",
    "TokenExpiration":              "security",
    "SessionTimeout":               "security",
    
    // System
    "ReadOnly":                     "system",
    "QuotaPerProjectEnable":        "system", 
    "StoragePerProject":            "system",
    "RobotNamePrefix":              "system",
    "NotificationEnable":           "system",
    "ScannerSkipUpdatePulltime":    "system",
    "SkipAuditLogDatabase":         "system",
    "AuditLogForwardEndpoint":      "system",
    "BannerMessage":                "system",
}

@bupd

bupd commented Aug 12, 2025

Copy link
Copy Markdown
Member Author

closing in favor of #521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changes Requesed feedback that must be addressed before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement LDAP/OIDC Authentication for Usergroup Functionality 📌 Tracker: Missing and To-Be-Added CLI Commands

6 participants