upload2gcs

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package upload2gcs stores feeds as JSON files in a GCS bucket

Manage file creation (with override) and deletion.

Triggered by

Messages in related PubSub topics.

Instances

one-one, one pubsub message - one file created (with override) or deleted.

Output

JSON files into a GCS bucket.

Cardinality

One-one: one feed message - one operation performed in FireStore.

Automatic retrying

Yes.

Is recurssive

Yes.

Required environment variables

- ASSETSCOLLECTIONID the name of the FireStore collection grouping all assets documents

- BUCKETNAME name of the Google Cloud Storage bucket where to write JSON files

- OWNERLABELKEYNAME key name for the label identifying the asset owner

- VIOLATIONRESOLVERLABELKEYNAME key name for the label identifying the asset violation resolver

Implementation example

package p
import (
    "context"

    "github.com/BrunoReboul/ram/services/upload2gcs"
    "github.com/BrunoReboul/ram/utilities/ram"
)
var global upload2gcs.Global
var ctx = context.Background()

// EntryPoint is the function to be executed for each cloud function occurence
func EntryPoint(ctxEvent context.Context, PubSubMessage ram.PubSubMessage) error {
    return upload2gcs.EntryPoint(ctxEvent, PubSubMessage, &global)
}

func init() {
    upload2gcs.Initialize(ctx, &global)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntryPoint

func EntryPoint(ctxEvent context.Context, PubSubMessage ram.PubSubMessage, global *Global) error

EntryPoint is the function to be executed for each cloud function occurence

func Initialize

func Initialize(ctx context.Context, global *Global)

Initialize is to be executed in the init() function of the cloud function to optimize the cold start

Types

type Asset

type Asset struct {
	Name                    string                 `json:"name"`
	Ancestors               []string               `json:"ancestors"`
	AncestorsDisplayName    []string               `json:"ancestorsDisplayName"`
	AncestryPath            string                 `json:"ancestryPath"`
	AncestryPathDisplayName string                 `json:"ancestryPathDisplayName"`
	AncestryPathLegacy      string                 `json:"ancestry_path"`
	AssetType               string                 `json:"assetType"`
	AssetTypeLegacy         string                 `json:"asset_type"`
	Origin                  string                 `json:"origin"`
	Owner                   string                 `json:"owner"`
	ViolationResolver       string                 `json:"violationResolver"`
	Resource                json.RawMessage        `json:"resource"`
	IamPolicy               map[string]interface{} `json:"iamPolicy"`
	IamPolicyLegacy         map[string]interface{} `json:"iam_policy"`
}

Asset Cloud Asset Metadata

type FeedMessage

type FeedMessage struct {
	Asset   Asset      `json:"asset"`
	Window  ram.Window `json:"window"`
	Deleted bool       `json:"deleted"`
	Origin  string     `json:"origin"`
}

FeedMessage Cloud Asset Inventory feed message

type Global

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

Global structure for global variables to optimize the cloud function performances

Jump to

Keyboard shortcuts

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