summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2022-04-09 15:58:22 +0400
committerIgor Drozdov <idrozdov@gitlab.com>2022-08-03 16:25:47 +0200
commit253679bd0d010db18b8a701ef5bb48ceb0ab4242 (patch)
treed25639c0749440c0b62bd750f4f92a4b39126942
parent8f2a4e90923a852eb386885b9379d5953fd8781b (diff)
downloadgitlab-shell-253679bd0d010db18b8a701ef5bb48ceb0ab4242.tar.gz
Add developer documentation to command package
-rw-r--r--internal/command/README.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/command/README.md b/internal/command/README.md
new file mode 100644
index 0000000..418fbaa
--- /dev/null
+++ b/internal/command/README.md
@@ -0,0 +1,26 @@
+---
+stage: Create
+group: Source Code
+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
+---
+
+# Overview
+
+This package consists of a set of packages that are responsible for executing a particular command/feature/operation.
+The full list of features can be viewed [here](https://gitlab.com/gitlab-org/gitlab-shell/-/blob/main/doc/features.md).
+The commands implement the common interface:
+
+```go
+type Command interface {
+ Execute(ctx context.Context) error
+}
+```
+
+A command is executed by running the `Execute` method. The execution logic mostly shares the common pattern:
+
+- Parse the arguments and validate them.
+- 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.
+- 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.
+- Return results to the client.
+
+[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.