Skip to content

Commit 253679b

Browse files
author
Igor Drozdov
committed
Add developer documentation to command package
1 parent 8f2a4e9 commit 253679b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

internal/command/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
stage: Create
3+
group: Source Code
4+
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
5+
---
6+
7+
# Overview
8+
9+
This package consists of a set of packages that are responsible for executing a particular command/feature/operation.
10+
The full list of features can be viewed [here](https://gitlab.com/gitlab-org/gitlab-shell/-/blob/main/doc/features.md).
11+
The commands implement the common interface:
12+
13+
```go
14+
type Command interface {
15+
Execute(ctx context.Context) error
16+
}
17+
```
18+
19+
A command is executed by running the `Execute` method. The execution logic mostly shares the common pattern:
20+
21+
- Parse the arguments and validate them.
22+
- Communicate with GitLab Rails using [gitlabnet](https://gitlab.com/gitlab-org/gitlab-shell/-/tree/main/internal/gitlabnet) package. For example, it can be checking whether a client is authorized to execute this particular command or asking for a personal access token in order to return it to the client.
23+
- If a command is related to Git operations, establish a connection with Gitaly using [handler](https://gitlab.com/gitlab-org/gitlab-shell/-/tree/main/internal/handler) and [gitaly](https://gitlab.com/gitlab-org/gitlab-shell/-/tree/main/internal/gitaly) packages and provide two-way communication between Gitaly and the client.
24+
- Return results to the client.
25+
26+
[cmd/gitlab-shell/command](https://gitlab.com/gitlab-org/gitlab-shell/-/tree/main/cmd/gitlab-shell/command) is using this package to build a particular command based on the passed arguments.

0 commit comments

Comments
 (0)