rules_api

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rule

type Rule struct {
	Path          string `json:"Path"`
	Operation     string `json:"Operation"`
	ComponentName string `json:"ComponentName"`
	ComponentType string `json:"ComponentType"`
	Required      bool   `json:"Required"`
	Notification  string `json:"Notification"`
	URL           string `json:"Docs"`
}

Rule holds all needed attribute from a parsed rule

func (Rule) DoesRuleApplyInContext

func (r Rule) DoesRuleApplyInContext(filePath, resourceName, resourceType string) (bool, error)

DoesRuleApplyInContext

@brief:

DoesRuleApplyInContext checks if the rule applies to the user's context

@params:

filepath - string - the path to the file
resourceName - string - the resource the rule applies to
resourceType - string - the type of the resource the rule applies to

@returns:

bool - true if applies. else false
error - if exists, otherwise false

func (Rule) IsNew

func (r Rule) IsNew() bool

IsNew

@brief:

IsNew checks if the Rule in context represents a new resource / component

func (Rule) IsParameterChange

func (r Rule) IsParameterChange() bool

IsParameterChange

@brief:

IsParameterChange validates that a rule does not concern to a new parameter (computed, deprecated etc.)

@returns:

bool - true if parameter. else false

func (Rule) PrettyPrint

func (r Rule) PrettyPrint()

PrettyPrint

@brief:

PrettyPrint prints the Rule object

func (Rule) PrettyPrintWhatsNew

func (r Rule) PrettyPrintWhatsNew()

PrettyPrintWhatsNew

@brief:

PrettyPrintWhatsNew prints the Rule object if new

type RuleSet

type RuleSet struct {
	ResourceName string   `json:"ResourceName"`
	Appearances  []string `json:"Appearances"`
	Rules        []Rule   `json:"Changes"`
}

RuleSet is holding the ruleset as a gabs.Container object alongside relevant metadata

func (RuleSet) GetNewComponents

func (r RuleSet) GetNewComponents() []string

GetNewComponents

@brief:

GetNewComponents finds all the new components in the next version

@returns:

[]string - a slice of notifications of what's new

func (RuleSet) PrettyPrint

func (r RuleSet) PrettyPrint(rules []Rule)

PrettyPrint

@brief:

PrettyPrint prints the RuleSet object

func (RuleSet) PrettyPrintWhatsNew

func (r RuleSet) PrettyPrintWhatsNew()

PrettyPrintWhatsNew

@brief:

PrettyPrintWhatsNew prints the RuleSet new objects

type Rulebook

type Rulebook struct {
	SourceVersion string
	TargetVersion string
	Bytes         []byte
}

Rulebook is holding the rulebook as bytes alongside relevant metadata

func GetRules

func GetRules(provider, sourceVersion string) (Rulebook, error)

GetRules

@brief:

GetRules retrieves a rulebook from the API

@params:

provider - string - the provider name
sourceVersion - string - the source version

@returns:

Rulebook - the initializes Rulebook
error - if exists, else nil

func (Rulebook) GetAllRuleSets

func (r Rulebook) GetAllRuleSets() (map[string]interface{}, error)

GetAllRuleSets

@brief:

GetAllRuleSets returns all RuleSets in a rulebook

@returns:

map[string]interface{} - the rules as a map of interfaces
error - if exists, else nil

func (Rulebook) GetRuleSetByResource

func (r Rulebook) GetRuleSetByResource(resourceName, resourceType string) (rule *gabs.Container, err error)

GetRuleSetByResource

@brief:

GetRuleSetByResource retrieves a rule from the rulebook in context by its name

@params:

resourceName - string - the resource name to fetch the rule for

@returns:

rule - *gabs.Container - the rule as a gabs json object
err - error - if exists, else nil

func (Rulebook) GetTargetVersion

func (r Rulebook) GetTargetVersion() string

Jump to

Keyboard shortcuts

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