-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Izzy Muerte <63051+bruxisma@users.noreply.github.com>
- Loading branch information
Showing
26 changed files
with
1,881 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
[default] | ||
locale = "en-us" | ||
|
||
[files] | ||
extend-exclude = ["go.mod", "go.sum"] |
This file contains 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,24 @@ | ||
name: Lint | ||
on: | ||
pull_request: | ||
types: [synchronize, opened, edited] | ||
jobs: | ||
go.lint: | ||
name: Lint Go | ||
uses: bruxisma/actions/.github/workflows/go.lint.yaml@main | ||
yaml.lint: | ||
name: Lint YAML | ||
uses: bruxisma/actions/.github/workflows/yaml.lint.yml@main | ||
actions.lint: | ||
name: Lint GitHub Action Workflows | ||
uses: bruxisma/actions/.github/workflows/actions.lint.yml@main | ||
spellcheck: | ||
name: Spellcheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Checking Spelling | ||
uses: crate-ci/typos@v1 | ||
with: | ||
config: ${{github.workspace}}/.github/settings/typos.toml |
This file contains 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,60 @@ | ||
name: Pull Request | ||
on: | ||
pull_request: | ||
types: [synchronize, opened, edited] | ||
jobs: | ||
skip: | ||
name: Check Duplicate Actions | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should-skip: ${{steps.skip-checkout.outputs.should_skip}} | ||
steps: | ||
- name: Skip Duplicate Actions (Pull Request) | ||
uses: fkirc/skip-duplicate-actions@v4 | ||
id: skip-check | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
if: needs.skip.outputs.should-skip != 'true' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
cache: true | ||
- name: Get Go Modules Cache location | ||
run: echo "::set-output name=dir::$(go env GOMODCACHE)" | ||
id: go-modules-cache | ||
- name: Get Go Build Cache Location | ||
run: echo "::set-output name=dir::$(go env GOCACHE)" | ||
id: go-build-cache | ||
- name: Setup Go Modules Cache | ||
uses: actions/cache@v3 | ||
with: | ||
restore-keys: go-modules- | ||
path: ${{steps.go-modules-cache.outputs.dir}} | ||
key: go-modules-${{hashFiles('**/go.sum')}} | ||
- name: Setup Go Build Cache | ||
uses: actions/cache@v3 | ||
with: | ||
restore-keys: go-build- | ||
path: ${{steps.go-build-cache.outputs.dir}} | ||
key: go-modules-${{hashFiles('**/go.mod', '**/go.sum')}} | ||
- name: Setup gotestfmt | ||
uses: haveyoudebuggedit/gotestfmt-action@v2 | ||
with: | ||
token: ${{github.token}} | ||
- name: Run Tests | ||
run: >- | ||
go test -v ./... | ||
-json | ||
-coverprofile coverage.out | ||
-cover ${{github.workspace}} | ||
2>&1 | gotestfmt | ||
- name: Upload Code Coverage | ||
uses: codecov/codecov-action@v3.1.0 | ||
with: | ||
fail_ci_if_error: true | ||
directory: ${{github.workspace}} | ||
files: coverage.out |
This file contains 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,46 @@ | ||
# Contributing to `go-apt-transport` | ||
|
||
First, thanks for the interest in contributing! Before contributing, be sure to | ||
read the [Code of Conduct](CODE_OF_CONDUCT.md) | ||
|
||
# License | ||
|
||
By contributing to `go-apt-transport`, you agree to license your commits under | ||
the [MIT License](LICENSE.md) | ||
|
||
# Git Commit Messages | ||
|
||
Git commit messages must utlize [gitmπji](https://gitmoji.dev) or the actual | ||
emoji themselves for each line item. If a line requires more information place | ||
it in a paragraph directly below the line item (unless the description is for | ||
the subject line of the commit). Additionally, messages should use markdown, as | ||
most tooling can render it. For example: | ||
|
||
```gitcommit | ||
β‘ Improve speed by fooing bars instead of bazzes. | ||
Fooing a baz has been proven to be slow in certain cases due to string | ||
expansion. By using a bar, we're able to reduce this performance issue. | ||
π Resolve incorrect usage of cmake_minimum_required | ||
After consulting with 13 oracles, 12 wizards, and a wise Kiwi goat named | ||
"Harold", we've finally figured out when to call `cmake_minimum_required`. | ||
β» Refactor several internal functions just to keep people guessing. | ||
When writing lists, make sure to indent as needed for readability. Think of | ||
explanations for a commit message as "a tweet but with less anger and more | ||
technical reasoning" | ||
- Please make nice clean lists | ||
- spacing between elements matters | ||
- thank you | ||
``` | ||
|
||
Please note that the [gitmπji](https://gitmoji.dev) list has changed over | ||
time, and will continue to change or evolve over time, but always assume that | ||
the currently published list is to be used. | ||
|
||
NOTE: We do not currently have a conventional commit standard used to generate | ||
changelogs, but once implemented this will be an automated operation that will | ||
be enforced, and hopefully still rely on gitmoji. |
This file contains 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 |
---|---|---|
@@ -1,2 +1,30 @@ | ||
# go-apt-transport | ||
Golang library for writing apt transport methods | ||
# Overview | ||
|
||
[![Go Reference][godoc-svg]][godoc-lnk] | ||
[![Coverage][codecov-svg]][codecov-lnk] | ||
|
||
This library provides a common set of operations for writing `apt` transport | ||
methods in golang. It does not handle the exact logic that covers *every* | ||
possible transport protocol, but does allow for an easy to use interface when | ||
communicating with `apt` or `apt-get`. | ||
|
||
In addition to providing a simple interface for acquiring resources in custom | ||
transport methods, this API also exports all pieces necessary to recreate the | ||
common interfaces. This is done to provide users with more granular support | ||
over `Message` deserialization, `Method` acquisition, and introspection. | ||
|
||
# Usage | ||
|
||
To add this as a go module simply do | ||
|
||
```console | ||
$ go get occult.work/apt/transport@latest | ||
``` | ||
|
||
**NOTE**: There is no `occult.work/apt` package. | ||
|
||
[godoc-svg]: https://pkg.go.dev/badge/occult.work/apt/transport.svg | ||
[godoc-lnk]: https://pkg.go.dev/occult.work/apt/transport | ||
|
||
[codecov-svg]: https://codecov.io/gh/bruxisma/go-apt-transport/branch/main/graph/badge.svg | ||
[codecov-lnk]: https://codecov.io/gh/bruxisma/go-apt-transport |
This file contains 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,22 @@ | ||
package transport | ||
|
||
// AuthorizationRequired (status code 402) is sent to APT to request credentials. | ||
// | ||
// The transport method requires a User and Password pair to continue. After | ||
// sending this message, a Method will expect APT to send a 602 Authorization | ||
// Credentials message with the required information. It is possible for a | ||
// transport method to send this message to APT multiple times (both for | ||
// multiple credential steps as well as retries and timeouts) | ||
type AuthorizationRequired struct { | ||
Site string | ||
} | ||
|
||
// AuthorizationCredentials (status code 602) is sent in response to a 402 | ||
// Authorization Required. | ||
// | ||
// When received, it will contain the entered username and password. | ||
type AuthorizationCredentials struct { | ||
Password string | ||
User string | ||
Site string | ||
} |
This file contains 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,77 @@ | ||
package transport | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"reflect" | ||
) | ||
|
||
var ( | ||
ErrDestinationNotPointer = errors.New("destination for value is not a pointer") | ||
ErrDestinationNotStruct = errors.New("destination for value is not a struct") | ||
ErrDestinationIsNil = errors.New("destination for value is nil") | ||
|
||
ErrSourceNotPointer = errors.New("source for value is not a pointer") | ||
ErrSourceNotStruct = errors.New("source for value is not a struct") | ||
ErrSourceIsNil = errors.New("source for value is nil") | ||
|
||
ErrMessageScannerNoData = errors.New("message scanner has not data") | ||
|
||
ErrMessageHeaderNotFound = errors.New("message header not found") | ||
ErrMessageHeaderMalformed = errors.New("message header malformed") | ||
|
||
ErrFieldEntryInvalid = errors.New("header field entry is invalid") | ||
ErrFieldsEmpty = errors.New("header fields are empty") | ||
|
||
ErrEmptyInformationalMessage = errors.New("informational message is empty") | ||
|
||
ErrNotImplemented = errors.New("not implemented") | ||
) | ||
|
||
// MessageMarshalerError is used when performing automatic reflection-based | ||
// marhsalling into a message. | ||
type MessageMarshalerError struct { | ||
Type reflect.Type | ||
Err error | ||
source string | ||
} | ||
|
||
// FieldMarshalerError is used when performing automatic reflection-based | ||
// marshalling into a field. | ||
type FieldMarshalerError struct { | ||
Type reflect.Type | ||
Err error | ||
source string | ||
} | ||
|
||
func (err *FieldMarshalerError) Error() string { | ||
source := err.source | ||
if source == "" { | ||
source = "MarshalFields" | ||
} | ||
return fmt.Sprintf( | ||
"apt/transport: error calling %q for type %q: %s", | ||
source, | ||
err.Type.String(), | ||
err.Err.Error()) | ||
} | ||
|
||
func (err *FieldMarshalerError) Unwrap() error { | ||
return err.Err | ||
} | ||
|
||
func (err *MessageMarshalerError) Error() string { | ||
source := err.source | ||
if source == "" { | ||
source = "MarshalMessage" | ||
} | ||
return fmt.Sprintf( | ||
"apt/transport: error calling %q for type %q: %s", | ||
source, | ||
err.Type.String(), | ||
err.Err.Error()) | ||
} | ||
|
||
func (err *MessageMarshalerError) Unwrap() error { | ||
return err.Err | ||
} |
Oops, something went wrong.