Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
petrutlucian94 committed Jan 28, 2025
1 parent 7e7162b commit c52558d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
50 changes: 25 additions & 25 deletions src/k8s/cmd/k8s/k8s_inspect.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package k8s

import (
"syscall"
"syscall"

cmdutil "github.com/canonical/k8s/cmd/util"
"github.com/spf13/cobra"
cmdutil "github.com/canonical/k8s/cmd/util"
"github.com/spf13/cobra"
)

func newInspectCmd(env cmdutil.ExecutionEnvironment) *cobra.Command {
// We're copying the help string from the "inspect.sh" script with
// only minor adjustments. At the same time, we'll avoid parsing the
// same arguments twice.
return &cobra.Command{
Use: "inspect <output-file>",
Short: "generate inspection report",
Long: `
// We're copying the help string from the "inspect.sh" script with
// only minor adjustments. At the same time, we'll avoid parsing the
// same arguments twice.
return &cobra.Command{
Use: "inspect <output-file>",
Short: "generate inspection report",
Long: `
This command collects diagnostics and other relevant information from a Kubernetes
node (either control-plane or worker node) and compiles them into a tarball report.
The collected data includes service arguments, Kubernetes cluster info, SBOM, system
Expand All @@ -32,20 +32,20 @@ Arguments:
--timeout (Optional) The maximum time in seconds to wait for a command.
Default: 180s.
`,
DisableFlagParsing: true,
PreRun: chainPreRunHooks(hookRequireRoot(env)),
Run: func(cmd *cobra.Command, args []string) {
inspectScriptPath := env.Snap.K8sInspectScriptPath()
DisableFlagParsing: true,
PreRun: chainPreRunHooks(hookRequireRoot(env)),
Run: func(cmd *cobra.Command, args []string) {
inspectScriptPath := env.Snap.K8sInspectScriptPath()

command := append([]string{inspectScriptPath}, args...)
environ := cmdutil.EnvironWithDefaults(
env.Environ,
)
if err := syscall.Exec(inspectScriptPath, command, environ); err != nil {
cmd.PrintErrf("Failed to run %s.\n\nError: %v\n", command, err)
env.Exit(1)
return
}
},
}
command := append([]string{inspectScriptPath}, args...)
environ := cmdutil.EnvironWithDefaults(
env.Environ,
)
if err := syscall.Exec(inspectScriptPath, command, environ); err != nil {
cmd.PrintErrf("Failed to run %s.\n\nError: %v\n", command, err)
env.Exit(1)
return
}
},
}
}
2 changes: 1 addition & 1 deletion src/k8s/pkg/snap/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Snap interface {
ContainerdSocketPath() string // classic confinement: /run/containerd/containerd.sock, strict confinement: /var/snap/k8s/common/run/containerd/containerd.sock
ContainerdStateDir() string // classic confinement: /run/containerd, strict confinement: /var/snap/k8s/common/run/containerd

K8sScriptsDir() string // /snap/k8s/current/k8s/scripts
K8sScriptsDir() string // /snap/k8s/current/k8s/scripts
K8sInspectScriptPath() string // /snap/k8s/current/k8s/scripts/inspect.sh

K8sdStateDir() string // /var/snap/k8s/common/var/lib/k8sd/state
Expand Down
3 changes: 1 addition & 2 deletions src/k8s/pkg/snap/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Mock struct {
ContainerdSocketDir string
ContainerdSocketPath string
ContainerdStateDir string
K8sScriptsDir string
K8sScriptsDir string
K8sInspectScriptPath string
K8sdStateDir string
K8sDqliteStateDir string
Expand Down Expand Up @@ -178,7 +178,6 @@ func (s *snap) K8sInspectScriptPath() string {
return s.Mock.K8sInspectScriptPath
}


func (s *Snap) KubernetesConfigDir() string {
return s.Mock.KubernetesConfigDir
}
Expand Down

0 comments on commit c52558d

Please sign in to comment.