-
Notifications
You must be signed in to change notification settings - Fork 142
feat(repo): Implement Repository Update Command #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bhavyaKhatri2703
wants to merge
5
commits into
goharbor:main
Choose a base branch
from
bhavyaKhatri2703:feat(repo)/Implement-repository-update-cmd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
85aa514
feat(repo): Implement Repository Update Command
bhavyaKhatri2703 7f4f12a
Merge branch 'goharbor:main' into feat(repo)/Implement-repository-upd…
bhavyaKhatri2703 5299a21
Merge branch 'goharbor:main' into feat(repo)/Implement-repository-upd…
bhavyaKhatri2703 0858010
feat(repo):Make description flag optional for update command
bhavyaKhatri2703 c6dc1f0
fix(repo):lint issues
bhavyaKhatri2703 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| title: harbor repo update | ||
| weight: 55 | ||
| --- | ||
| ## harbor repo update | ||
|
|
||
| ### Description | ||
|
|
||
| ##### Update a repository | ||
|
|
||
| ### Synopsis | ||
|
|
||
| Update the description of a repository. | ||
|
|
||
| This command updates the description associated with a repository | ||
| within a Harbor project. | ||
|
|
||
| Examples: | ||
| # Update repository description using project/repository format | ||
| harbor repository update library/nginx --description "Official nginx image" | ||
|
|
||
| ```sh | ||
| harbor repo update [flags] | ||
| ``` | ||
|
|
||
| ### Options | ||
|
|
||
| ```sh | ||
| -d, --description string Repository description | ||
| -h, --help help for update | ||
| ``` | ||
|
|
||
| ### Options inherited from parent commands | ||
|
|
||
| ```sh | ||
| -c, --config string config file (default is $HOME/.config/harbor-cli/config.yaml) | ||
| -o, --output-format string Output format. One of: json|yaml | ||
| -v, --verbose verbose output | ||
| ``` | ||
|
|
||
| ### SEE ALSO | ||
|
|
||
| * [harbor repo](harbor-repo.md) - Manage repositories | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| .nh | ||
| .TH "HARBOR" "1" "Harbor Community" "Harbor User Manuals" | ||
|
|
||
| .SH NAME | ||
| harbor-repo-update - Update a repository | ||
|
|
||
|
|
||
| .SH SYNOPSIS | ||
| \fBharbor repo update [flags]\fP | ||
|
|
||
|
|
||
| .SH DESCRIPTION | ||
| Update the description of a repository. | ||
|
|
||
| .PP | ||
| This command updates the description associated with a repository | ||
| within a Harbor project. | ||
|
|
||
| .PP | ||
| Examples: | ||
| # Update repository description using project/repository format | ||
| harbor repository update library/nginx --description "Official nginx image" | ||
|
|
||
|
|
||
| .SH OPTIONS | ||
| \fB-d\fP, \fB--description\fP="" | ||
| Repository description | ||
|
|
||
| .PP | ||
| \fB-h\fP, \fB--help\fP[=false] | ||
| help for update | ||
|
|
||
|
|
||
| .SH OPTIONS INHERITED FROM PARENT COMMANDS | ||
| \fB-c\fP, \fB--config\fP="" | ||
| config file (default is $HOME/.config/harbor-cli/config.yaml) | ||
|
|
||
| .PP | ||
| \fB-o\fP, \fB--output-format\fP="" | ||
| Output format. One of: json|yaml | ||
|
|
||
| .PP | ||
| \fB-v\fP, \fB--verbose\fP[=false] | ||
| verbose output | ||
|
|
||
|
|
||
| .SH SEE ALSO | ||
| \fBharbor-repo(1)\fP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright Project Harbor Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package update | ||
|
|
||
| import ( | ||
| "github.com/charmbracelet/huh" | ||
| "github.com/goharbor/go-client/pkg/sdk/v2.0/models" | ||
| ) | ||
|
|
||
| func UpdateRepositoryView(repo *models.Repository) (string, error) { | ||
| var description string | ||
|
|
||
| if repo.Description != "" { | ||
| description = repo.Description | ||
| } | ||
|
|
||
| theme := huh.ThemeCharm() | ||
|
|
||
| form := huh.NewForm( | ||
| huh.NewGroup( | ||
| huh.NewText(). | ||
| Title("Repository Description"). | ||
| Description("Update the description for " + repo.Name). | ||
| Value(&description). | ||
| Placeholder("Enter repository description..."), | ||
| ), | ||
| ).WithTheme(theme) | ||
|
|
||
| err := form.Run() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| return description, nil | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are creating a new blank repository object without fetching the info of the already existing repo from the api. I would expect that this could lead to some issues. I think the correct behavior would be something like getting the repo object from the api, updating the description and then calling the update request to the api.