seed

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package seed is used to generate test data for a demo or seeded environment.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAPITokenMissing is returned when the openlane API token is missing
	ErrAPITokenMissing = fmt.Errorf("token is required but not provided")

	// ErrColumnNotFound is returned when a column is not found in the CSV file
	ErrColumnNotFound = fmt.Errorf("column not found in CSV file")

	// ErrInvalidTemplateName is returned when an invalid template name is provided
	ErrInvalidTemplateName = fmt.Errorf("invalid template name")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	*openlaneclient.OpenlaneClient
	// contains filtered or unexported fields
}

Config represents provides the openlane client and configuration for the seed client

func NewDefaultClient

func NewDefaultClient() (*Client, error)

NewDefaultClient creates a new openlane client using the default configuration variables

func (*Client) AuthorizeOrganizationOnPAT

func (c *Client) AuthorizeOrganizationOnPAT(ctx context.Context, orgID, patID string) error

AuthorizeOrganizationOnPAT authorizes the organization id on the personal access token id

func (*Client) GenerateSeedAPIToken

func (c *Client) GenerateSeedAPIToken(ctx context.Context, orgID string) error

GenerateSeedAPIToken generates an API token for the organization id to use for seeding and authenticates the client with the token for future requests

func (*Client) LoadGroups

func (c *Client) LoadGroups(ctx context.Context) error

LoadGroups loads the groups from the groups.csv file

func (*Client) LoadInvites

func (c *Client) LoadInvites(ctx context.Context) error

LoadInvites loads the invites from the invites.csv file

func (*Client) LoadOrgMembers

func (c *Client) LoadOrgMembers(ctx context.Context, userIDs []string) error

LoadOrgMembers loads orgs members from the user ids provided

func (*Client) LoadOrganizations

func (c *Client) LoadOrganizations(ctx context.Context) (string, error)

LoadOrganizations loads the organizations from the organizations.csv file

func (*Client) LoadSubscribers

func (c *Client) LoadSubscribers(ctx context.Context) error

LoadSubscribers loads the subscribers from the subscribers.csv file

func (*Client) LoadTemplates

func (c *Client) LoadTemplates(ctx context.Context) error

LoadTemplates loads the templates from the jsonschema/templates directory

func (*Client) RegisterUsers

func (c *Client) RegisterUsers(ctx context.Context) ([]string, error)

RegisterUsers registers the users from the users.csv file

type Config

type Config struct {
	// Directory is the directory to save generated data
	Directory string `json:"directory" koanf:"directory" default:"demodata"`
	// OpenlaneHost is the host of the openlane server
	OpenlaneHost string `json:"openlaneHost" koanf:"openlaneHost" default:"http://localhost:17608"`
	// Token is the token to use for the openlane client
	Token string `json:"token" koanf:"token" default:""`
	// NumOrganizations is the number of organizations to generate
	NumOrganizations int `json:"numOrganizations" koanf:"numOrganizations" default:"1"`
	// NumUsers is the number of users to generate
	NumUsers int `json:"NumUsers" koanf:"NumUsers" default:"10"`
	// NumGroups is the number of groups to generate
	NumGroups int `json:"NumGroups" koanf:"NumGroups" default:"10"`
	// NumInvites is the number of invites to generate
	NumInvites int `json:"NumInvites" koanf:"NumInvites" default:"5"`
	// NumSubscribers is the number of subscribers to generate
	NumSubscribers int `json:"NumSubscribers" koanf:"NumSubscribers" default:"30"`
	// GenerateTemplates is a flag to generate templates
	GenerateTemplates bool `json:"generateTemplates" koanf:"generateTemplates" default:"true"`
}

Config is the configuration for the seed package

func NewDefaultConfig

func NewDefaultConfig() (*Config, error)

NewDefaultConfig returns a new Config with default values

func (*Config) GenerateData

func (c *Config) GenerateData() error

func (*Config) GenerateUserData

func (c *Config) GenerateUserData() error

func (*Config) NewClient

func (c *Config) NewClient() (*Client, error)

NewClient creates a new openlane client using the provided configuration variables

type Template

type Template struct {
	// Name is the name of the template
	Name string
	// JSONConfig is the JSONschema configuration for the template
	JSONConfig []byte
}

Template represents a template to be seeded

Jump to

Keyboard shortcuts

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