Skip to content

Commit

Permalink
Merge branch 'develop' into vsukhin/fix/id-sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Jul 29, 2024
2 parents 251a8da + dd0316d commit dbf4c48
Show file tree
Hide file tree
Showing 110 changed files with 5,815 additions and 3,022 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand Down
2 changes: 1 addition & 1 deletion build/api-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
ARG ALPINE_IMAGE
FROM ${ALPINE_IMAGE}
RUN apk --no-cache add ca-certificates libssl3 git skopeo
RUN apk --no-cache add ca-certificates libssl3 git
WORKDIR /root/
COPY testkube-api-server /bin/app
USER 1001
Expand Down
2 changes: 1 addition & 1 deletion build/testworkflow-toolkit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
ARG ALPINE_IMAGE
FROM ${ALPINE_IMAGE}
RUN apk --no-cache add ca-certificates libssl3 git skopeo openssh-client
RUN apk --no-cache add ca-certificates libssl3 git openssh-client
COPY testworkflow-toolkit /toolkit
RUN adduser --disabled-password --home / --no-create-home --uid 1001 default
USER 1001
Expand Down
2 changes: 1 addition & 1 deletion cmd/api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func main() {
}
inspector := imageinspector.NewInspector(
cfg.TestkubeRegistry,
imageinspector.NewSkopeoFetcher(),
imageinspector.NewCraneFetcher(),
imageinspector.NewSecretFetcher(secretClient, cache.NewInMemoryCache[*corev1.Secret](), imageinspector.WithSecretCacheTTL(cfg.TestkubeImageCredentialsCacheTTL)),
inspectorStorages...,
)
Expand Down
79 changes: 79 additions & 0 deletions cmd/kubectl-testkube/commands/common/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package common

import (
"fmt"
"os"

"github.com/pterm/pterm"
)

const (
// TKERR-1xx errors are to issues when running testkube CLI commands.

// TKERR-11xx errors are related to missing dependencies.

// TKErrMissingDependencyHelm is returned when kubectl is not found in $PATH.
TKErrMissingDependencyHelm = "TKERR-1101"
// TKErrMissingDependencyKubectl is returned when kubectl is not found in $PATH.
TKErrMissingDependencyKubectl = "TKERR-1102"

// TKERR-12xx errors are related to configuration issues.

// TKErrConfigLoadingFailed is returned when configuration loading fails.
TKErrConfigLoadingFailed = "TKERR-1201"
// TKErrInvalidInstallConfig is returned when invalid configuration is supplied when installing or upgrading.
TKErrInvalidInstallConfig = "TKERR-1202"

// TKERR-13xx errors are related to install operations.

// TKErrHelmCommandFailed is returned when a helm command fails.
TKErrHelmCommandFailed = "TKERR-1301"
// TKErrKubectlCommandFailed is returned when a kubectl command fail.
TKErrKubectlCommandFailed = "TKERR-1302"
)

type CLIError struct {
Code string
Title string
Description string
ActualError error
StackTrace string
MoreInfo string
}

func (e *CLIError) Error() string {
return fmt.Sprintf("%s: %s", e.Code, e.Description)
}

func (e *CLIError) Print() {
pterm.DefaultHeader.Println("Testkube Init Error")

pterm.DefaultSection.Println("Error Details")

items := []pterm.BulletListItem{
{Level: 0, Text: pterm.Sprintf("[%s]: %s", e.Code, e.Title), TextStyle: pterm.NewStyle(pterm.FgRed)},
{Level: 0, Text: pterm.Sprintf("%s", e.Description), TextStyle: pterm.NewStyle(pterm.FgLightWhite)},
}
if e.MoreInfo != "" {
items = append(items, pterm.BulletListItem{Level: 0, Text: pterm.Sprintf("%s", e.MoreInfo), TextStyle: pterm.NewStyle(pterm.FgGray)})
}
pterm.DefaultBulletList.WithItems(items).Render()
}

func NewCLIError(code, title, moreInfoURL string, err error) *CLIError {
return &CLIError{
Code: code,
Title: title,
Description: err.Error(),
ActualError: err,
MoreInfo: moreInfoURL,
}
}

// HandleCLIError checks does the error exist, and if it does, prints the error and exits the program.
func HandleCLIError(err *CLIError) {
if err != nil {
err.Print()
os.Exit(1)
}
}
Loading

0 comments on commit dbf4c48

Please sign in to comment.