1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-11-23 21:44:44 +02:00
Files
woodpecker/pipeline/backend/local/errors.go
6543 9edaa1e0c3 local backend test shells if unknown (#5570)
currently if we don't know the shell we just assume posix.
this adds a small test, to ensure it is and fail gracefully before doing weird stuff.

## Test Conf

```yaml
skip_clone: true
steps:
  build:
    image: "true"
    commands:
      - echo "building..."
```
2025-10-01 12:29:48 +02:00

49 lines
1.4 KiB
Go

// Copyright 2023 Woodpecker Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// cSpell:ignore ERRORLEVEL
package local
import (
"errors"
"fmt"
)
var (
ErrNoShellSet = errors.New("no shell was set")
ErrNoCmdSet = errors.New("no commands where set")
)
// ErrNoPosixShell indicates that a shell was assumed to be POSIX-compatible but failed the test.
type ErrNoPosixShell struct {
Shell string
Err error
}
func (e *ErrNoPosixShell) Error() string {
return fmt.Sprintf("Shell %q was assumed to be a Posix shell, but test failed: %v\n(if you want support for it, please open an issue)", e.Shell, e.Err)
}
// Unwrap returns the underlying error for errors.Is and errors.As support.
func (e *ErrNoPosixShell) Unwrap() error {
return e.Err
}
// Is enables errors.Is comparison.
func (e *ErrNoPosixShell) Is(target error) bool {
_, ok := target.(*ErrNoPosixShell)
return ok
}