utils

package
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Utility methods for PCTL Cluster manipulation

Utility methods for Config struct

Utility methods for PCTL Group struct

Utility methods for PCTL Project struct

Utility methods for testing

Utility methods for PCTL User struct

General program utilities

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResourceNotExists   = errors.New("resource does not exist")
	ErrOperationNotAllowed = errors.New("operation not allowed")
	ErrInvalidCredentials  = errors.New("invalid credentials")
)

error types

View Source
var NON_PROJECT_ROLES = []string{"ADMIN", "ADMIN_READ_ONLY"}

Thesea are the roles that don't require specifying a project

Functions

func ApplyGroup added in v0.0.35

func ApplyGroup(ctx context.Context, grp *groupv3.Group, auth *authprofile.Profile) error

Apply group takes the group details and sends it to the core

func ApplyProject added in v0.0.35

func ApplyProject(ctx context.Context, proj *systemv3.Project, auth *authprofile.Profile) error

Apply project takes the project details and sends it to the core

func AssertConfigNotEmpty added in v0.0.40

func AssertConfigNotEmpty(conf *config.Config) error

func AssertStringNotEmpty added in v0.0.29

func AssertStringNotEmpty(message, str string) diag.Diagnostics

AssertStringNotEmpty asserts when the string is not empty

func AssertUniquePRNStruct added in v0.0.43

func AssertUniquePRNStruct(pnrStruct []*userv3.ProjectNamespaceRole) diag.Diagnostics

Assures that the combination of project, role, namespace, and group are all unique

func AssertUniqueRoles added in v0.0.29

func AssertUniqueRoles(pnrStruct []*userv3.ProjectNamespaceRole) diag.Diagnostics

Check to make sure that the list of roles from ProjectNamespaceRole has unique role values. This is required due to a limitation with Paralus. See: https://github.com/paralus/paralus/issues/136

func BuildClusterStructFromResource

func BuildClusterStructFromResource(d *schema.ResourceData) *infrav3.Cluster

Build the cluster struct from a schema resource

func BuildGroupStructFromResource added in v0.0.29

func BuildGroupStructFromResource(d *schema.ResourceData) *groupv3.Group

Build the group struct from a schema resource

func BuildKubeConfigStruct added in v0.0.45

func BuildKubeConfigStruct(ctx context.Context, d *schema.ResourceData, kubeconfigYAML string) (string, error)

func BuildProjectStructFromResource

func BuildProjectStructFromResource(d *schema.ResourceData) *systemv3.Project

Build the project struct from a schema resource

func BuildResourceFromClusterStruct

func BuildResourceFromClusterStruct(cluster *infrav3.Cluster, d *schema.ResourceData)

Build the schema resource from Cluster Struct

func BuildResourceFromGroupStruct added in v0.0.29

func BuildResourceFromGroupStruct(group *groupv3.Group, d *schema.ResourceData)

Build the schema resource from group Struct

func BuildResourceFromProjectStruct

func BuildResourceFromProjectStruct(project *systemv3.Project, d *schema.ResourceData)

Build the schema resource from project Struct

func BuildResourceFromUsersStruct added in v0.0.46

func BuildResourceFromUsersStruct(users []*userv3.User, d *schema.ResourceData)

Build the schema resource from users Struct

func BuildUsersStructFromResource added in v0.0.46

func BuildUsersStructFromResource(d *schema.ResourceData) []*userv3.User

Build the project struct from a schema resource

func CheckAllowEmptyProject added in v0.0.33

func CheckAllowEmptyProject(role string) diag.Diagnostics

Check the role desired allows for no project specified

func CheckGroupsFromPNRStructExist added in v0.0.33

func CheckGroupsFromPNRStructExist(ctx context.Context, pnrStruct []*groupv3.ProjectNamespaceRole, auth *authprofile.Profile) diag.Diagnostics

Check groups specified in the ProjectNamespaceRoles struct exist in Paralus

func CheckProjectsFromPNRStructExist added in v0.0.33

func CheckProjectsFromPNRStructExist(ctx context.Context, pnrStruct []*userv3.ProjectNamespaceRole, auth *authprofile.Profile) diag.Diagnostics

Check projects specified in the ProjectNamespaceRoles struct exist in Paralus

func CheckUserRoleUsersExist added in v0.0.33

func CheckUserRoleUsersExist(ctx context.Context, userRoles []*userv3.UserRole, auth *authprofile.Profile) diag.Diagnostics

Check users from a UserRole structs exist in paralus

func CheckUsersExist added in v0.0.33

func CheckUsersExist(ctx context.Context, users []string, auth *authprofile.Profile) diag.Diagnostics

Check users from a list exist in paralus

func CreateCluster added in v0.0.35

func CreateCluster(ctx context.Context, cluster *infrav3.Cluster, auth *authprofile.Profile) error

Update cluster takes the updated cluster details and sends it to the core

func DeleteCluster added in v0.0.35

func DeleteCluster(ctx context.Context, name, project string, auth *authprofile.Profile) error

Delete the cluster

func DeleteGroup added in v0.0.35

func DeleteGroup(ctx context.Context, groupName string, auth *authprofile.Profile) error

Delete group

func DeleteProject added in v0.0.35

func DeleteProject(ctx context.Context, project string, auth *authprofile.Profile) error

Delete project

func FilterUsers added in v0.0.46

func FilterUsers(users []*userv3.User, filter_is string, filter_is_value string,
	filter_is_case_senstive bool, filter_allow_more_than_one bool) ([]*userv3.User, error)

Filter the list of users based on the filter value requested

func GetBootstrapFile added in v0.0.35

func GetBootstrapFile(ctx context.Context, name, project string, auth *authprofile.Profile) (string, error)

Will retrieve the bootstrap file for imported clusters

func GetCluster added in v0.0.35

func GetCluster(ctx context.Context, name, project string, auth *authprofile.Profile) (*infrav3.Cluster, error)

Retrieves cluster info

func GetConfigAsMap added in v0.0.23

func GetConfigAsMap(conf *config.Config) map[string]interface{}

retrieve the Config as a map

func GetGroupByName added in v0.0.35

func GetGroupByName(ctx context.Context, groupName string, auth *authprofile.Profile) (*groupv3.Group, error)

Get group by name

func GetKubeConfig added in v0.0.45

func GetKubeConfig(ctx context.Context, accountID string, namespace string, cluster string, auth *authprofile.Profile) (string, error)

retrieves the kubeconfig for the user with either all or specific cluster info

func GetProjectByName added in v0.0.35

func GetProjectByName(ctx context.Context, projectName string, auth *authprofile.Profile) (*systemv3.Project, error)

Get project by name

func GetUserByName added in v0.0.35

func GetUserByName(ctx context.Context, userName string, auth *authprofile.Profile) (*userv3.User, error)

Get user by name

func GetUsers added in v0.0.46

func GetUsers(ctx context.Context, params []string, auth *authprofile.Profile) ([]*userv3.User, error)

Get all users based on provided filter/limit/offset

func JsonToMap

func JsonToMap(jsonStr string) (map[string]interface{}, error)

Convert a json to a string map interface

func ListAllClusters added in v0.0.35

func ListAllClusters(ctx context.Context, projectId string, auth *authprofile.Profile) ([]*infrav3.Cluster, error)

ListAllClusters uses the lower level func ListClusters to retrieve a list of all clusters

func MapToJsonString

func MapToJsonString(jsonMap map[string]string) (string, error)

Convert a map to json string

func MultiEnvSearch

func MultiEnvSearch(ks []string) string

func SetBootstrapFileAndRelays added in v0.0.28

func SetBootstrapFileAndRelays(ctx context.Context, d *schema.ResourceData, auth *authprofile.Profile) error

Retrieve the YAML files that will be used to setup paralus agents in cluster and assign it to the schema Also retrieve the relays from the data of the relay-agent configMap YAML Due to the parallel nature of testing, it might be that the cluster would be created before the relay was effectively populated. So let's do a increased delay check

func UpdateCluster added in v0.0.35

func UpdateCluster(ctx context.Context, cluster *infrav3.Cluster, auth *authprofile.Profile) error

Update cluster takes the updated cluster details and sends it to the core

func ValidateProjectNamespaceRolesSet added in v0.0.29

func ValidateProjectNamespaceRolesSet(pnrStruct []*userv3.ProjectNamespaceRole, projectRoles map[string]string) error

Validate that the passed in map of project roles match what was set in the project struct

func ValidateUserRolesSet added in v0.0.29

func ValidateUserRolesSet(urStruct []*userv3.UserRole, userRoles map[string]string) error

Validate that the passed in map of user roles match what was set in the project struct

Types

This section is empty.

Jump to

Keyboard shortcuts

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