Skip to content

Commit

Permalink
chore: add typos pre commit hook
Browse files Browse the repository at this point in the history
Signed-off-by: Sertac Ozercan <[email protected]>
  • Loading branch information
sozercan committed Nov 14, 2024
1 parent 565b9c0 commit cd08250
Show file tree
Hide file tree
Showing 27 changed files with 63 additions and 57 deletions.
10 changes: 7 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.16.3
rev: v8.21.2
hooks:
- id: gitleaks
- repo: https://github.com/golangci/golangci-lint
rev: v1.52.2
rev: v1.62.0
hooks:
- id: golangci-lint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/crate-ci/typos
rev: v1.27.3
hooks:
- id: typos
2 changes: 2 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[default.extend-words]
ba = "ba"
2 changes: 1 addition & 1 deletion cmd/test2json2gha/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func do(in io.Reader, out io.Writer, modName string) (bool, error) {
}

if te.Test == "" {
// Don't bother processing events that aren't specfically for a test
// Don't bother processing events that aren't specifically for a test
// Go adds extra events in for package level info that we don't need.
continue
}
Expand Down
10 changes: 5 additions & 5 deletions docs/spec.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
},
"additionalProperties": false,
"type": "object",
"description": "CheckOutput is used to specify the exepcted output of a check, such as stdout/stderr or a file."
"description": "CheckOutput is used to specify the expected output of a check, such as stdout/stderr or a file."
},
"Command": {
"properties": {
Expand Down Expand Up @@ -497,7 +497,7 @@
"type": "string"
},
"type": "array",
"description": "Version is a list of version constraints for the package.\nThe format of these strings is depenendent on the package manager of the target system.\nExamples:\n [\"\u003e=1.0.0\", \"\u003c2.0.0\"]"
"description": "Version is a list of version constraints for the package.\nThe format of these strings is dependent on the package manager of the target system.\nExamples:\n [\"\u003e=1.0.0\", \"\u003c2.0.0\"]"
},
"arch": {
"items": {
Expand Down Expand Up @@ -776,11 +776,11 @@
"properties": {
"file": {
"$ref": "#/$defs/SourceInlineFile",
"description": "File is the inline file to generate.\nFile is treated as a literal single file.\n[SourceIsDir] will return false when this is set.\nThis is mutally exclusive with [Dir]"
"description": "File is the inline file to generate.\nFile is treated as a literal single file.\n[SourceIsDir] will return false when this is set.\nThis is mutually exclusive with [Dir]"
},
"dir": {
"$ref": "#/$defs/SourceInlineDir",
"description": "Dir creates a directory with the given files and directories.\n[SourceIsDir] will return true when this is set.\nThis is mutally exclusive with [File]"
"description": "Dir creates a directory with the given files and directories.\n[SourceIsDir] will return true when this is set.\nThis is mutually exclusive with [File]"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -984,7 +984,7 @@
"$ref": "#/$defs/TestSpec"
},
"type": "array",
"description": "Tests are the list of tests to run for the package that should work regardless of target OS\nEach item in this list is run with a separate rootfs and cannot interact with other tests.\nEach [TestSpec] is run with a separate rootfs, asyncronously from other [TestSpec]."
"description": "Tests are the list of tests to run for the package that should work regardless of target OS\nEach item in this list is run with a separate rootfs and cannot interact with other tests.\nEach [TestSpec] is run with a separate rootfs, asynchronously from other [TestSpec]."
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion frontend/deb/debroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var patchHeader []byte
var debianInstall []byte

// This creates a directory in the debian root directory for each patch, and copies the patch files into it.
// The format for each patch dir matches what would normaly be under `debian/patches`, just that this is a separate dir for every source we are patching
// The format for each patch dir matches what would normally be under `debian/patches`, just that this is a separate dir for every source we are patching
// This is purely for documenting in the source package how patches are applied in a more readable way than the big merged patch file.
func sourcePatchesDir(sOpt dalec.SourceOpts, base llb.State, dir, name string, spec *dalec.Spec, opts ...llb.ConstraintsOpt) ([]llb.State, error) {
patchesPath := filepath.Join(dir, name)
Expand Down
2 changes: 1 addition & 1 deletion frontend/deb/template_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (w *rulesWrapper) OverrideSystemd() (fmt.Stringer, error) {
// custom postinst/postrm script.
//
// We also only need to do this once per basename, so we don't need to
// itterate over every unit.
// iterate over every unit.

// Get the first key which we'll use to check if the unit is enabled.
// Either all units are enabled or not enabled OR we need to do custom enable
Expand Down
4 changes: 2 additions & 2 deletions frontend/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ func Warn(ctx context.Context, client gwclient.Client, st llb.State, msg string)

def, err := st.Marshal(ctx)
if err != nil {
bklog.G(ctx).WithError(err).WithField("warn", msg).Warn("Error marshalling state for outputing warning message")
bklog.G(ctx).WithError(err).WithField("warn", msg).Warn("Error marshalling state for outputting warning message")
}

var dgst digest.Digest
if def != nil {
dgst, err = def.Head()
if err != nil {
bklog.G(ctx).WithError(err).WithField("warn", msg).Warn("Could not get state digest for outputing warning message")
bklog.G(ctx).WithError(err).WithField("warn", msg).Warn("Could not get state digest for outputting warning message")
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/jammy/handle_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func buildImageRootfs(worker llb.State, spec *dalec.Spec, sOpt dalec.SourceOpts,
tmp := llb.Scratch().File(llb.Mkfile("tmp", 0o644, nil))
// Warning: HACK here
// The base ubuntu image has this `excludes` config file which prevents
// installation of a lot of thigns, including doc files.
// installation of a lot of things, including doc files.
// This is mounting over that file with an empty file so that our test suite
// passes (as it is looking at these files).
llb.AddMount("/etc/dpkg/dpkg.cfg.d/excludes", tmp, llb.SourcePath("tmp")).SetRunOption(cfg)
Expand Down
8 changes: 4 additions & 4 deletions frontend/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (m *BuildMux) loadSpec(ctx context.Context, client gwclient.Client) (*dalec
return nil, err
}

// Note: this is not suitable for passing to builds since it does ot have platform information
// Note: this is not suitable for passing to builds since it does not have platform information
spec, err := LoadSpec(ctx, dc, nil)
if err != nil {
return nil, err
Expand All @@ -220,7 +220,7 @@ func maybeSetDalecTargetKey(client gwclient.Client, key string) gwclient.Client
return client
}

// optimization to help prevent uneccessary grpc requests
// optimization to help prevent unnecessary grpc requests
// The gateway client will make a grpc request to get the build opts from the gateway.
// This just caches those opts locally.
// If the client is already a clientWithCustomOpts, then the opts are already cached.
Expand All @@ -239,7 +239,7 @@ func (m *BuildMux) list(ctx context.Context, client gwclient.Client, target stri
if target == "" {
check = maps.Keys(m.handlers)
} else {
// Use the target as a filter so the response only incldues routes that are underneath the target
// Use the target as a filter so the response only includes routes that are underneath the target
check = append(check, target)
}

Expand Down Expand Up @@ -309,7 +309,7 @@ func (m *BuildMux) lookupTarget(ctx context.Context, target string) (matchedPatt
// cases for `t` are as follows:
// 1. may have an exact match in the handlers (ideal)
// 2. No matching handler and `target == ""` and there is a default handler set (assume default handler)
// 3. may have a prefix match in the handlers, e.g. hander for `foo`, `target == "foo/bar"` (assume nested route)
// 3. may have a prefix match in the handlers, e.g. handler for `foo`, `target == "foo/bar"` (assume nested route)
// 4. No match in the handlers (error)
h, ok := m.handlers[target]
if ok {
Expand Down
2 changes: 1 addition & 1 deletion frontend/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestBuildMux(t *testing.T) {
t.Errorf("expected real handler call count to be %d, got %d", expectedRealcount, count)
}

// create a subrouter namespaced under the "real" hanlder.
// create a subrouter namespaced under the "real" handler.
// This should handle routes for real/subroute/*.
var subRouter BuildMux
subRouteACount, subrouteAH := newCallback()
Expand Down
2 changes: 1 addition & 1 deletion frontend/windows/handle_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
defaultPlatform = ocispecs.Platform{
OS: outputKey,
// NOTE: Windows is (currently) only supported on amd64.
// Making this use runtime.GOARCH so that builds are more explicitly and not suprising.
// Making this use runtime.GOARCH so that builds are more explicitly and not surprising.
// If/when Windows is supported on another platform (ie arm64) this will work as expected.
// Until then, if someone really wants to build an amd64 image from arm64 they'll need to set the platform explicitly in the build request.
Architecture: runtime.GOARCH,
Expand Down
2 changes: 1 addition & 1 deletion frontend/windows/handle_zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func withSourcesMounted(dst string, states map[string]llb.State, sources map[str
for _, k := range sorted {
state := states[k]

// In cases where we have a generated soruce (e.g. gomods) we don't have a [dalec.Source] in the `sources` map.
// In cases where we have a generated source (e.g. gomods) we don't have a [dalec.Source] in the `sources` map.
// So we need to check for this.
src, ok := sources[k]

Expand Down
2 changes: 1 addition & 1 deletion load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func TestSourceValidation(t *testing.T) {
},
},
{
title: "cmd souce mount dest must not be /",
title: "cmd source mount dest must not be /",
expectErr: true,
src: Source{
Path: "/foo",
Expand Down
10 changes: 5 additions & 5 deletions source.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func generateSourceFromImage(st llb.State, cmd *Command, sOpts SourceOpts, subPa
}

if subPath == "" {
// TODO: We should log a warning here since extracing an entire image while also running a command is
// TODO: We should log a warning here since extracting an entire image while also running a command is
// probably not what the user really wanted to do here.
// The buildkit client provides functionality to do this we just need to wire it in.
subPath = "/"
Expand Down Expand Up @@ -487,21 +487,21 @@ func (s Source) Doc(name string) (io.Reader, error) {
fmt.Fprintln(b, " Remote:", ref.Remote)
fmt.Fprintln(b, " Ref:", git.Commit)
if s.Path != "" {
fmt.Fprintln(b, " Extraced path:", s.Path)
fmt.Fprintln(b, " Extracted path:", s.Path)
}
case s.DockerImage != nil:
img := s.DockerImage
if img.Cmd == nil {
fmt.Fprintln(b, "Generated from a docker image:")
fmt.Fprintln(b, " Image:", img.Ref)
if s.Path != "" {
fmt.Fprintln(b, " Extraced path:", s.Path)
fmt.Fprintln(b, " Extracted path:", s.Path)
}
} else {
fmt.Fprintln(b, "Generated from running a command(s) in a docker image:")
fmt.Fprintln(b, " Image:", img.Ref)
if s.Path != "" {
fmt.Fprintln(b, " Extraced path:", s.Path)
fmt.Fprintln(b, " Extracted path:", s.Path)
}
if len(img.Cmd.Env) > 0 {
fmt.Fprintln(b, " With the following environment variables set for all commands:")
Expand Down Expand Up @@ -580,7 +580,7 @@ func patchSource(worker, sourceState llb.State, sourceToState map[string]llb.Sta
}

// PatchSources returns a new map containing the patched LLB state for each source in the source map.
// Sources that are not patched are also included in the result for convienence.
// Sources that are not patched are also included in the result for convenience.
// `sourceToState` must be a complete map from source name -> llb state for each source in the dalec spec.
// `worker` must be an LLB state with a `patch` binary present.
func PatchSources(worker llb.State, spec *Spec, sourceToState map[string]llb.State, opts ...llb.ConstraintsOpt) map[string]llb.State {
Expand Down
12 changes: 6 additions & 6 deletions spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type Spec struct {

// Tests are the list of tests to run for the package that should work regardless of target OS
// Each item in this list is run with a separate rootfs and cannot interact with other tests.
// Each [TestSpec] is run with a separate rootfs, asyncronously from other [TestSpec].
// Each [TestSpec] is run with a separate rootfs, asynchronously from other [TestSpec].
Tests []*TestSpec `yaml:"tests,omitempty" json:"tests,omitempty"`
}

Expand Down Expand Up @@ -243,11 +243,11 @@ type SourceInline struct {
// File is the inline file to generate.
// File is treated as a literal single file.
// [SourceIsDir] will return false when this is set.
// This is mutally exclusive with [Dir]
// This is mutually exclusive with [Dir]
File *SourceInlineFile `yaml:"file,omitempty" json:"file,omitempty"`
// Dir creates a directory with the given files and directories.
// [SourceIsDir] will return true when this is set.
// This is mutally exclusive with [File]
// This is mutually exclusive with [File]
Dir *SourceInlineDir `yaml:"dir,omitempty" json:"dir,omitempty"`
}

Expand Down Expand Up @@ -299,7 +299,7 @@ type Source struct {
// Generators are used to generate additional sources from this source.
// As an example the `godmod` generator can be used to generate a go module cache from a go source.
// How a genator operates is dependent on the actual generator.
// Geneators may also cauuse modifications to the build environment.
// Generators may also cauuse modifications to the build environment.
//
// Currently only one generator is supported: "gomod"
Generate []*SourceGenerator `yaml:"generate,omitempty" json:"generate,omitempty"`
Expand All @@ -322,7 +322,7 @@ type SourceGenerator struct {
// PackageConstraints is used to specify complex constraints for a package dependency.
type PackageConstraints struct {
// Version is a list of version constraints for the package.
// The format of these strings is depenendent on the package manager of the target system.
// The format of these strings is dependent on the package manager of the target system.
// Examples:
// [">=1.0.0", "<2.0.0"]
Version []string `yaml:"version,omitempty" json:"version,omitempty"`
Expand Down Expand Up @@ -489,7 +489,7 @@ type TestStep struct {
Stdin string `yaml:"stdin,omitempty" json:"stdin,omitempty"`
}

// CheckOutput is used to specify the exepcted output of a check, such as stdout/stderr or a file.
// CheckOutput is used to specify the expected output of a check, such as stdout/stderr or a file.
// All non-empty fields will be checked.
type CheckOutput struct {
// Equals is the exact string to compare the output to.
Expand Down
8 changes: 4 additions & 4 deletions test/azlinux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type workerConfig struct {
// the output [llb.StateOption] should install the repo into the worker image.
CreateRepo func(llb.State) llb.StateOption
// ContextName is the name of the worker context that the build target will use
// to see if a custom worker is proivded in a context
// to see if a custom worker is provided in a context
ContextName string

Constraints constraintsSymbols
Expand All @@ -141,8 +141,8 @@ type targetConfig struct {
// Target is the build target for creating the worker image.
Worker string

// FormatDepEqual, when set, alters the provided depenedency version to match
// what is neccessary for the target distro to set a dependency for an equals
// FormatDepEqual, when set, alters the provided dependency version to match
// what is necessary for the target distro to set a dependency for an equals
// operator.
FormatDepEqual func(ver, rev string) string
}
Expand Down Expand Up @@ -482,7 +482,7 @@ echo "$BAR" > bar.txt
},
})

// update the spec in the solve reuqest
// update the spec in the solve request
withSpec(ctx, t, &spec)(&newSolveRequestConfig{req: &sr})

if _, err := gwc.Solve(ctx, sr); err == nil {
Expand Down
2 changes: 1 addition & 1 deletion test/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestStateWrapper_Walk(t *testing.T) {
func TestStateWrapper_ReadPartial(t *testing.T) {
contents := []byte(`
This is a
multline
multiline
file
`)
st := llb.Scratch().File(llb.Mkfile("/foo", 0644, contents))
Expand Down
6 changes: 3 additions & 3 deletions test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ func TestMain(m *testing.M) {

go func() {
<-ctx.Done()
// The context was cancelled due to interupt
// The context was cancelled due to interrupt
// This _should_ trigger builds to cancel naturally and exit the program,
// but in some cases it may not (due to timing, bugs in buildkit, uninteruptable operations, etc.).
// Cancel our signal handler so the normal handler takes over from here.
// This allows subsequent interupts to use the default behavior (exit the program)
// This allows subsequent interrupts to use the default behavior (exit the program)
done()

<-time.After(30 * time.Second)
fmt.Fprintln(os.Stderr, "Timeout waiting for builds to cancel after interupt")
fmt.Fprintln(os.Stderr, "Timeout waiting for builds to cancel after interrupt")
os.Exit(int(syscall.SIGINT))
}()

Expand Down
2 changes: 1 addition & 1 deletion test/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func TestSourceHTTP(t *testing.T) {
})
}

// Create a very simple fake module with a limited depdenency tree just to
// Create a very simple fake module with a limited dependency tree just to
// keep the test as fast/reliable as possible.
const gomodFixtureMain = `package main
Expand Down
4 changes: 2 additions & 2 deletions test/testenv/buildkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
// Buildkit treats the frontend ref (`#syntax=<ref>` or via the BUILDKIT_SYNTAX
// var) as a docker image ref.
// Buildkit will always check the remote registry for a new version of the image.
// As of buildkit v0.12 you can use named contexts to ovewrite the frontend ref
// As of buildkit v0.12 you can use named contexts to overwrite the frontend ref
// with another type of ref.
// This can be another docker-image, an oci-layout, or even a frontend "input"
// (like feeding the output of a build into another build).
Expand Down Expand Up @@ -67,7 +67,7 @@ func supportsFrontendAsInput(info *client.Info) bool {

// withGHCache adds the necessary cache export and import options to the solve request in order to use the GitHub Actions cache.
// It uses the test name as a scope for the cache. Each test will have its own scope.
// This means that caches are not shared between tests, but it also means that tests won't ovewrite each other's cache.
// This means that caches are not shared between tests, but it also means that tests won't overwrite each other's cache.
//
// Github Actions sets some specific environment variables that we'll look for to even determine if we should configure the cache or not.
//
Expand Down
6 changes: 3 additions & 3 deletions test/testenv/buildx.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (b *BuildxEnv) WithBuilder(builder string) *BuildxEnv {
return b
}

// Load loads the output of the speecified [gwclient.BuildFunc] into the buildkit instance.
// Load loads the output of the specified [gwclient.BuildFunc] into the buildkit instance.
func (b *BuildxEnv) Load(ctx context.Context, id string, f gwclient.BuildFunc) error {
if b.refs == nil {
b.refs = make(map[string]gwclient.BuildFunc)
Expand Down Expand Up @@ -126,7 +126,7 @@ func (b *BuildxEnv) dialStdio(ctx context.Context) error {
err := cmd.Wait()
c1.Close()
// pkgerrors.Wrap will return nil if err is nil, otherwise it will give
// us a wrapped error with the buffered stderr fromt he command.
// us a wrapped error with the buffered stderr from he command.
w.CloseWithError(pkgerrors.Wrapf(err, "%s", errBuf))
}()

Expand Down Expand Up @@ -221,7 +221,7 @@ type FrontendSpec struct {
}

// withResolveLocal tells buildkit to prefer local images when resolving image references.
// This prevents uneccessary API requests to registries.
// This prevents unnecessary API requests to registries.
func withResolveLocal(so *client.SolveOpt) {
if so.FrontendAttrs == nil {
so.FrontendAttrs = make(map[string]string)
Expand Down
Loading

0 comments on commit cd08250

Please sign in to comment.