utils

package
v0.0.0-...-b7fd0f1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright (c) 2021 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads file content for a given file location.

Types

type Commander

type Commander struct {
	Command string
	Options []string
}

Commander is a wrapper around os/exec.Command(). It returns a byte array containing the output of stdout and error. An error in command execution will land there. Stderr is scanned as well, its output is printed out.

func NewCommander

func NewCommander() *Commander

NewCommander returns a new commander.

func (*Commander) CallCMD

func (c *Commander) CallCMD(cmd []string, dir string) ([]byte, error)

CallCMD calls a specified command in sh and returns its stdout as a byte slice and potentially an error. As per os/exec doc: ``` If the command fails to run or doesn't complete successfully, the error is of type *ExitError. Other error types may be returned for I/O problems. ```

func (*Commander) Run

func (c *Commander) Run(cmd string) ([]byte, error)

Run is a facade command that runs a single command from the current directory.

type Executor

type Executor interface {
	CallCMD(cmd []string, dir string) ([]byte, error)
}

Executor is an interface for calling a command and process its output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL