ram

package
v0.0.35-rc01 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package ram avoid code redundancy by grouping types and functions used by other ram packages

Index

Constants

View Source
const (
	DevelopmentEnvironmentName   = "dev"
	SettingsFileName             = "settings.yaml"
	SolutionSettingsFileName     = "solution.yaml"
	ServiceSettingsFileName      = "service.yaml"
	InstanceSettingsFileName     = "instance.yaml"
	MicroserviceParentFolderName = "services"
	InstancesFolderName          = "instances"
	RegoConstraintsFolderName    = "constraints"
	SolutionName                 = "ram"
)

Settings file names

View Source
const YAMLDisclaimer = `` /* 577-byte string literal not displayed */

YAMLDisclaimer text to be added on top of yaml files

Variables

This section is empty.

Functions

func BuildAncestorsDisplayName

func BuildAncestorsDisplayName(ctx context.Context, ancestors []string, collectionID string, firestoreClient *firestore.Client, cloudresourcemanagerService *cloudresourcemanager.Service, cloudresourcemanagerServiceV2 *cloudresourcemanagerv2.Service) []string

BuildAncestorsDisplayName build a slice of Ancestor friendly name from a slice of ancestors

func BuildAncestryPath

func BuildAncestryPath(ancestors []string) string

BuildAncestryPath build a path from a slice of ancestors

func CheckPath added in v0.0.24

func CheckPath(path string)

CheckPath crashes execution when the path is not found or when an other error occurs

func Find

func Find(slice []string, val string) bool

Find a string in a slice of string. Return true when found else false

func GetAssetContact

func GetAssetContact(contactRole string, resourceJSON json.RawMessage) (string, error)

GetAssetContact retrieve owner of resolver contact from asset labels and parent labels

func GetByteSet

func GetByteSet(start byte, length int) []byte

GetByteSet return a set of lenght contiguous bytes starting at bytes

func GetChild added in v0.0.24

func GetChild(basePath string, relativeFolderPath string) []string

GetChild returns the list to relative subfolders path for a folder + a relative path, crashes execution on errors

func GetClientOptionAndCleanKeys

func GetClientOptionAndCleanKeys(ctx context.Context, serviceAccountEmail string, keyJSONFilePath string, projectID string, gciAdminUserToImpersonate string, scopes []string) (option.ClientOption, bool)

GetClientOptionAndCleanKeys build a clientOption object and manage the init state

func GetEnvVarBool added in v0.0.24

func GetEnvVarBool(envVarName string) bool

GetEnvVarBool retreive an os var, and convert it to bool

func GetEnvVarInt64

func GetEnvVarInt64(envVarName string) (int64, bool)

GetEnvVarInt64 retreive an os var, convert it and manage the init state

func GetEnvVarTime

func GetEnvVarTime(envVarName string) (time.Time, bool)

GetEnvVarTime retreive an os var, convert it and manage the init state

func GetEnvVarUint64

func GetEnvVarUint64(envVarName string) (uint64, bool)

GetEnvVarUint64 retreive an os var, convert it and manage the init state

func GetJWTConfigAndCleanKeys added in v0.0.24

func GetJWTConfigAndCleanKeys(ctx context.Context, serviceAccountEmail string, keyJSONFilePath string, projectID string, gciAdminUserToImpersonate string, scopes []string) (jwtConfig *jwt.Config, err error)

GetJWTConfigAndCleanKeys build a JWT config and manage the init state

func GetPublishCallResult

func GetPublishCallResult(ctx context.Context, publishResult *pubsub.PublishResult, waitgroup *sync.WaitGroup, msgInfo string, pubSubErrNumber *uint64, pubSubMsgNumber *uint64, logEventEveryXPubSubMsg uint64)

GetPublishCallResult func to be used in go routine to scale pubsub event publish

func IntialRetryCheck

func IntialRetryCheck(ctxEvent context.Context, initFailed bool, retryTimeOutSeconds int64) (bool, *metadata.Metadata, error)

IntialRetryCheck performs intitial controls 1) return true and metadata when controls are passed 2) return false when controls failed: - 2a) with an error to retry the cloud function entry point function - 2b) with nil to stop the cloud function entry point function

func JSONMarshalIndentPrint added in v0.0.24

func JSONMarshalIndentPrint(v interface{})

JSONMarshalIndentPrint marshal with 4 spaces indent no prefix and fmt print

func MarshalYAMLWrite added in v0.0.24

func MarshalYAMLWrite(path string, v interface{}) (err error)

MarshalYAMLWrite Marshal an interface to YAML format and write the bytes to a given path

func PrintEnptyInterfaceType

func PrintEnptyInterfaceType(value interface{}, valueName string) error

PrintEnptyInterfaceType discover the type below an empty interface

func ReadUnmarshalYAML added in v0.0.24

func ReadUnmarshalYAML(path string, settings interface{}) (err error)

ReadUnmarshalYAML Read bytes from a given path and unmarshal assuming YAML format

func ReadValidate added in v0.0.24

func ReadValidate(serviceName, settingsType, path string, settings interface{}) (err error)

ReadValidate reads a YAML config file to a struct and validate the struct

func RevertSlash

func RevertSlash(txt string) string

RevertSlash replace slash / by back slash \

func YAMLMarshalPrint added in v0.0.24

func YAMLMarshalPrint(v interface{})

YAMLMarshalPrint marshal from YAML and fmt print

func ZipSource added in v0.0.24

func ZipSource(zipFullPath string, zipFiles map[string]string) (err error)

ZipSource make a zip file from a map where the key is the file name and the value the string file content

Types

type AssetGroup

type AssetGroup struct {
	Name         string          `json:"name"`
	AssetType    string          `json:"assetType"`
	Ancestors    []string        `json:"ancestors"`
	AncestryPath string          `json:"ancestryPath"`
	IamPolicy    json.RawMessage `json:"iamPolicy"`
	Resource     *admin.Group    `json:"resource"`
}

AssetGroup CAI like format

type AssetGroupSettings

type AssetGroupSettings struct {
	Name      string                 `json:"name"`
	AssetType string                 `json:"assetType"`
	Ancestors []string               `json:"ancestors"`
	IamPolicy json.RawMessage        `json:"iamPolicy"`
	Resource  *groupssettings.Groups `json:"resource"`
}

AssetGroupSettings CAI like format

type AssetMember

type AssetMember struct {
	Name         string          `json:"name"`
	AssetType    string          `json:"assetType"`
	Ancestors    []string        `json:"ancestors"`
	AncestryPath string          `json:"ancestryPath"`
	IamPolicy    json.RawMessage `json:"iamPolicy"`
	Resource     Member          `json:"resource"`
}

AssetMember CAI like format

type ComplianceStatus added in v0.0.14

type ComplianceStatus struct {
	AssetName               string    `json:"assetName"`
	AssetInventoryTimeStamp time.Time `json:"assetInventoryTimeStamp"`
	AssetInventoryOrigin    string    `json:"assetInventoryOrigin"`
	RuleName                string    `json:"ruleName"`
	RuleDeploymentTimeStamp time.Time `json:"ruleDeploymentTimeStamp"`
	Compliant               bool      `json:"compliant"`
	Deleted                 bool      `json:"deleted"`
}

ComplianceStatus by asset, by rule, true/false compliance status

type FeedMessageGroup

type FeedMessageGroup struct {
	Asset   AssetGroup `json:"asset"`
	Window  Window     `json:"window"`
	Deleted bool       `json:"deleted"`
	Origin  string     `json:"origin"`
}

FeedMessageGroup CAI like format

type FeedMessageGroupSettings

type FeedMessageGroupSettings struct {
	Asset   AssetGroupSettings `json:"asset"`
	Window  Window             `json:"window"`
	Deleted bool               `json:"deleted"`
	Origin  string             `json:"origin"`
}

FeedMessageGroupSettings CAI like format

type FeedMessageMember

type FeedMessageMember struct {
	Asset   AssetMember `json:"asset"`
	Window  Window      `json:"window"`
	Deleted bool        `json:"deleted"`
	Origin  string      `json:"origin"`
}

FeedMessageMember CAI like format

type GCSEvent

type GCSEvent struct {
	Kind                    string                 `json:"kind"`
	ID                      string                 `json:"id"`
	SelfLink                string                 `json:"selfLink"`
	Name                    string                 `json:"name"`
	Bucket                  string                 `json:"bucket"`
	Generation              string                 `json:"generation"`
	Metageneration          string                 `json:"metageneration"`
	ContentType             string                 `json:"contentType"`
	TimeCreated             time.Time              `json:"timeCreated"`
	Updated                 time.Time              `json:"updated"`
	TemporaryHold           bool                   `json:"temporaryHold"`
	EventBasedHold          bool                   `json:"eventBasedHold"`
	RetentionExpirationTime time.Time              `json:"retentionExpirationTime"`
	StorageClass            string                 `json:"storageClass"`
	TimeStorageClassUpdated time.Time              `json:"timeStorageClassUpdated"`
	Size                    string                 `json:"size"`
	MD5Hash                 string                 `json:"md5Hash"`
	MediaLink               string                 `json:"mediaLink"`
	ContentEncoding         string                 `json:"contentEncoding"`
	ContentDisposition      string                 `json:"contentDisposition"`
	CacheControl            string                 `json:"cacheControl"`
	Metadata                map[string]interface{} `json:"metadata"`
	CRC32C                  string                 `json:"crc32c"`
	ComponentCount          int                    `json:"componentCount"`
	Etag                    string                 `json:"etag"`
	CustomerEncryption      struct {
		EncryptionAlgorithm string `json:"encryptionAlgorithm"`
		KeySha256           string `json:"keySha256"`
	}
	KMSKeyName    string `json:"kmsKeyName"`
	ResourceState string `json:"resourceState"`
}

GCSEvent is the payload of a GCS event.

type Member

type Member struct {
	MemberEmail string `json:"memberEmail"`
	GroupEmail  string `json:"groupEmail"`
	ID          string `json:"id"`
	Kind        string `json:"kind"`
	Role        string `json:"role"`
	Type        string `json:"type"`
}

Member is sligthly different from admim.Member to have both group email and member email

type PubSubMessage

type PubSubMessage struct {
	Data []byte `json:"data"`
}

PubSubMessage is the payload of a Pub/Sub event.

type PublishRequest

type PublishRequest struct {
	Topic string `json:"topic"`
}

PublishRequest Pub/sub

type Window

type Window struct {
	StartTime time.Time `json:"startTime" firestore:"startTime"`
}

Window Cloud Asset Inventory feed message time window

Jump to

Keyboard shortcuts

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