common

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiVersionV1 apiVersion = iota + 1
	ApiVersionV2 apiVersion = 2
)

Variables

This section is empty.

Functions

func AddExportToTypesDeclarations

func AddExportToTypesDeclarations(tsSource string) string

AddExportToTypesDeclarations Add export to (interface, class, enum, type) XXX found in the source.

func CallWorkerApi

func CallWorkerApi(c model.IntFlagProvider, params ApiCallParams) error

func CleanImports

func CleanImports(source string) string

func CloseQuietly

func CloseQuietly(c io.Closer)

func DecryptManifestSecrets

func DecryptManifestSecrets(mf *model.Manifest, withPassword ...string) error

func DecryptSecret

func DecryptSecret(password string, encryptedValue string) (string, error)

func EncryptSecret

func EncryptSecret(password string, secretValue string) (string, error)

func ExtractActionUsedTypes

func ExtractActionUsedTypes(md *model.ActionMetadata) []string

ExtractActionUsedTypes extracts all the type used in an action's sampleCode and defined in the action's typesDefinitions.

func ExtractProjectAndKeyFromCommandContext

func ExtractProjectAndKeyFromCommandContext(c stringFlagAware, args []string, minArguments int, onlyGeneric bool) (string, string, error)

ExtractProjectAndKeyFromCommandContext Extracts the project key and worker key from the command context. If the project key is not provided, it will be taken from the manifest. The workerKey could either be the first argument or the name in the manifest. The first argument will only be considered as the workerKey if total arguments are greater than minArgument.

func ExtractUsedTypes

func ExtractUsedTypes(tsSource string) []string

ExtractUsedTypes extracts types from a TypeScript source file.

func FetchWorkerDetails

func FetchWorkerDetails(c model.IntFlagProvider, serverUrl string, accessToken string, workerKey string, projectKey string) (*model.WorkerDetails, error)

FetchWorkerDetails Fetch a worker by its name. Returns nil if the worker does not exist (statusCode=404). Any other statusCode other than 200 will result as an error.

func NewCsvWriter

func NewCsvWriter() *csv.Writer

func PrepareSecretsUpdate

func PrepareSecretsUpdate(mf *model.Manifest, existingWorker *model.WorkerDetails) []*model.Secret

func PrettifyJson

func PrettifyJson(in []byte) []byte

func Print

func Print(message string, args ...any) error

func PrintJson

func PrintJson(data []byte) error

func ReadManifest

func ReadManifest(dir ...string) (*model.Manifest, error)

ReadManifest reads a manifest from the working directory or from the directory provided as argument.

func ReadSecretPassword

func ReadSecretPassword(prompt ...string) (string, error)

func ReadSourceCode

func ReadSourceCode(mf *model.Manifest) (string, error)

ReadSourceCode reads the content of the file pointed by SourceCodePath

func SaveManifest

func SaveManifest(mf *model.Manifest, dir ...string) error

func ValidateManifest

func ValidateManifest(mf *model.Manifest, actionsMeta ActionsMetadata) error

Types

type ActionsMetadata

type ActionsMetadata []*model.ActionMetadata

func FetchActions

func FetchActions(c model.IntFlagProvider, serverUrl string, accessToken string, projectKey string) (ActionsMetadata, error)

func (ActionsMetadata) ActionNeedsCriteria

func (c ActionsMetadata) ActionNeedsCriteria(actionName string, service ...string) bool

func (ActionsMetadata) ActionsNames

func (c ActionsMetadata) ActionsNames() []string

func (ActionsMetadata) FindAction

func (c ActionsMetadata) FindAction(actionName string, service ...string) (*model.ActionMetadata, error)

type ApiCallParams

type ApiCallParams struct {
	Method      string
	ServerUrl   string
	ServerToken string
	Body        []byte
	Query       map[string]string
	Path        []string
	ProjectKey  string
	ApiVersion  apiVersion
	OkStatuses  []int
	OnContent   ApiContentHandler
}

type ApiContentHandler

type ApiContentHandler func(content []byte) error

type ApiError

type ApiError struct {
	StatusCode int
	Message    string
}

func (*ApiError) Error

func (e *ApiError) Error() string

type InputReader

type InputReader struct {
	// contains filtered or unexported fields
}

func NewInputReader

func NewInputReader(ctx *components.Context) *InputReader

func (*InputReader) ReadData

func (c *InputReader) ReadData() (map[string]any, error)

func (*InputReader) ReadDataFromFile

func (c *InputReader) ReadDataFromFile(filePath string) (map[string]any, error)

func (*InputReader) ReadDataFromStdin

func (c *InputReader) ReadDataFromStdin() (map[string]any, error)

Jump to

Keyboard shortcuts

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