From 253679bd0d010db18b8a701ef5bb48ceb0ab4242 Mon Sep 17 00:00:00 2001 From: Igor Drozdov Date: Sat, 9 Apr 2022 15:58:22 +0400 Subject: Add developer documentation to command package --- internal/command/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 internal/command/README.md 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. -- cgit v1.2.1 From 3183c96d9c18ba9a7863fd8c5ced3f3a53d0cae8 Mon Sep 17 00:00:00 2001 From: Patrick Bajao Date: Fri, 3 Jun 2022 11:07:24 +0000 Subject: Specify all packages that use commands --- internal/command/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/command/README.md b/internal/command/README.md index 418fbaa..06551e1 100644 --- a/internal/command/README.md +++ b/internal/command/README.md @@ -23,4 +23,8 @@ A command is executed by running the `Execute` method. The execution logic mostl - 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. +This package is being used to build a particular command based on the passed arguments in the following files that are under `cmd` directory: +- [cmd/gitlab-shell/command](https://gitlab.com/gitlab-org/gitlab-shell/-/tree/main/cmd/gitlab-shell/command) +- [cmd/check/command](https://gitlab.com/gitlab-org/gitlab-shell/-/tree/main/cmd/check/command) +- [cmd/gitlab-shell-authorized-keys-check/command](https://gitlab.com/gitlab-org/gitlab-shell/-/tree/main/cmd/gitlab-shell-authorized-keys-check/command) +- [cmd/gitlab-shell-authorized-principals-check/command](https://gitlab.com/gitlab-org/gitlab-shell/-/tree/main/cmd/gitlab-shell-authorized-principals-check/command) -- cgit v1.2.1