util

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const EnableWebHookEnvVar = "ENABLE_WEBHOOK"
View Source
const WatchNamespaceEnvVar = "WATCH_NAMESPACE"

Variables

View Source
var ErrInvalidFileFormatError = errors.New("InvalidFileFormat")
View Source
var ErrInvalidTarArchive = errors.New("InvalidTarArchive")
View Source
var ErrInvalidZipArchive = errors.New("InvalidZipArchive")

Functions

func ApplyGraphmanBundle added in v1.0.2

func ApplyGraphmanBundle(username string, password string, target string, encpass string, bundle []byte) error

func ApplyToGraphmanTarget

func ApplyToGraphmanTarget(path string, singleton bool, username string, password string, target string, encpass string) error

func BuildAndValidateBundle added in v1.0.4

func BuildAndValidateBundle(path string) ([]byte, error)

func BuildCWPBundle

func BuildCWPBundle(cwps []securityv1.Property) ([]byte, string, error)

func BuildCustomListenPortBundle

func BuildCustomListenPortBundle(gw *securityv1.Gateway) ([]byte, string, error)

func BuildDefaultListenPortBundle

func BuildDefaultListenPortBundle() ([]byte, string, error)

func BuildLayer7PolicyXml added in v1.0.4

func BuildLayer7PolicyXml(name string, gatewayHost string, fipId string) ([]byte, error)

func BuildOtkOverrideBundle added in v1.0.4

func BuildOtkOverrideBundle(mode string, gatewayHost string, otkPort int) ([]byte, string, error)

func CloneRepository

func CloneRepository(url string, username string, token string, privateKey []byte, privateKeyPass string, branch string, tag string, remoteName string, name string, vendor string, authType string, knownHosts []byte) (string, error)

func CompressGraphmanBundle

func CompressGraphmanBundle(path string) ([]byte, error)

func Contains

func Contains(arr []string, str string) bool

Contains returns true if string array contains string

func ConvertOpaqueMapToGraphmanBundle added in v1.0.2

func ConvertOpaqueMapToGraphmanBundle(secrets []GraphmanSecret) ([]byte, error)

func ConvertX509ToGraphmanBundle added in v1.0.2

func ConvertX509ToGraphmanBundle(keys []GraphmanKey) ([]byte, error)

func DefaultLabels

func DefaultLabels(name string, additionalLabels map[string]string) map[string]string

func DownloadArtifact added in v1.0.4

func DownloadArtifact(URL string, username string, token string, name string, forceUpdate bool) (string, error)

Download Artifact retrieves a compressed Graphman Bundle from an HTTP URL This is currently limited to URLs that contain the file extension as would be the case when targeting releases from Git releases. The following extensions are accepted .tar, .tar.gz, .zip

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

GetOperatorNamespace returns the namespace of the operator pod

func GetPortalAccessToken added in v1.0.4

func GetPortalAccessToken(name string, authServer string, clientId string, clientSecret string) (string, error)

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func GetWebhookEnabled added in v1.0.4

func GetWebhookEnabled() (bool, error)

func RemoveL7API added in v1.0.4

func RemoveL7API(username string, password string, target string, apiName string, policyFragmentName string) error

func RestCall

func RestCall(method string, URL string, insecureSkipVerify bool, headers map[string]string, contentType string, data []byte, username string, password string) ([]byte, error)

func Untar added in v1.0.4

func Untar(folderName string, repoName string, tarStream io.Reader, gz bool) error

func Unzip

func Unzip(src string, dest string) error

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

Types

type AssertionComment added in v1.0.4

type AssertionComment struct {
	AssertionComment string            `xml:"assertionComment,attr"`
	Properties       MappingProperties `xml:"L7p:Properties"`
}

type AuthenticateAgainstIdpAssertion added in v1.0.4

type AuthenticateAgainstIdpAssertion struct {
	IdentityProviderOid IdentityProviderOid `xml:"L7p:IdentityProviderOid"`
}

type Bundle

type Bundle struct {
	XMLName    xml.Name   `xml:"l7:Bundle"`
	XMLNS      string     `xml:"xmlns:l7,attr"`
	References References `xml:"l7:References"`
	Mappings   Mappings   `xml:"l7:Mappings"`
}

type CachedSyncRequest added in v1.0.2

type CachedSyncRequest struct {
	SyncRequest
	// contains filtered or unexported fields
}

type ClusterProperty

type ClusterProperty struct {
	ID    string `xml:"id,attr"`
	Name  string `xml:"l7:Name"`
	Value string `xml:"l7:Value"`
}

type CommentAssertion added in v1.0.4

type CommentAssertion struct {
	Comment CommentAssertionComment `xml:"L7p:Comment"`
}

type CommentAssertionComment added in v1.0.4

type CommentAssertionComment struct {
	StringValue string `xml:"stringValue,attr"`
}

type EnabledCipherSuites

type EnabledCipherSuites struct {
	StringValue []string `xml:"l7:StringValue"`
}

type EnabledFeatures

type EnabledFeatures struct {
	StringValue []string `xml:"l7:StringValue"`
}

type EnabledVersions

type EnabledVersions struct {
	StringValue []string `xml:"l7:StringValue"`
}

type EncapsulatedAssertion added in v1.0.4

type EncapsulatedAssertion struct {
	AssertionComment                *AssertionComment `xml:"L7p:AssertionComment"`
	EncapsulatedAssertionConfigGuid PolicyStringValue `xml:"L7p:EncapsulatedAssertionConfigGuid"`
	EncapsulatedAssertionConfigName PolicyStringValue `xml:"L7p:EncapsulatedAssertionConfigName"`
	Parameters                      MappingProperties `xml:"L7p:Parameters"`
}

type GPolicy added in v1.0.4

type GPolicy struct {
	Xml string `json:"xml"`
}

type GraphmanKey added in v1.0.2

type GraphmanKey struct {
	Name      string `json:"name,omitempty"`
	Crt       string `json:"crt,omitempty"`
	Key       string `json:"key,omitempty"`
	Port      string `json:"port,omitempty"`
	Alias     string `json:"alias,omitempty"`
	UsageType string `json:"usageType,omitempty"`
}

type GraphmanOtkConfig added in v1.0.4

type GraphmanOtkConfig struct {
	Type                     string `json:"type,omitempty"`
	InternalGatewayReference string `json:"internalGatewayReference,omitempty"`
}

type GraphmanSecret added in v1.0.2

type GraphmanSecret struct {
	Name        string `json:"name,omitempty"`
	Secret      string `json:"secret,omitempty"`
	Description string `json:"description,omitempty"`

	VariableReferencable bool `json:"variableReferencable,omitempty"`
}

type HttpMapping added in v1.0.4

type HttpMapping struct {
	UrlPattern string `xml:"l7:UrlPattern"`
	Verbs      Verbs  `xml:"l7:Verbs"`
}

type IdentityProviderOid added in v1.0.4

type IdentityProviderOid struct {
	GoidValue string `xml:"goidValue,attr"`
}

type Item

type Item struct {
	Name     string   `xml:"l7:Name"`
	ID       string   `xml:"l7:Id"`
	Type     string   `xml:"l7:Type"`
	Resource Resource `xml:"l7:Resource"`
}

type ListenPort

type ListenPort struct {
	ID              string          `xml:"id,attr"`
	Name            string          `xml:"l7:Name"`
	Enabled         string          `xml:"l7:Enabled"`
	Protocol        string          `xml:"l7:Protocol"`
	Port            string          `xml:"l7:Port"`
	EnabledFeatures EnabledFeatures `xml:"l7:EnabledFeatures"`
	TlsSettings     *TlsSettings    `xml:"l7:TlsSettings"`
	Properties      Properties      `xml:"l7:Properties"`
}

type Mapping

type Mapping struct {
	Action     string     `xml:"action,attr"`
	SrcId      string     `xml:"srcId,attr"`
	Type       string     `xml:"type,attr"`
	Properties Properties `xml:"l7:Properties"`
}

type MappingEntry added in v1.0.4

type MappingEntry struct {
	Key   PolicyStringValue `xml:"L7p:key"`
	Value PolicyStringValue `xml:"L7p:value"`
}

type MappingProperties added in v1.0.4

type MappingProperties struct {
	MapValue string         `xml:"mapValue,attr"`
	Entry    []MappingEntry `xml:"L7p:entry"`
}

type Mappings

type Mappings struct {
	Mapping []Mapping `xml:"l7:Mapping"`
}

type OneOrMore added in v1.0.4

type OneOrMore struct {
	Text             string                          `xml:",chardata"`
	Usage            string                          `xml:"Usage,attr"`
	CommentAssertion *CommentAssertion               `xml:"L7p:CommentAssertion"`
	Authentication   AuthenticateAgainstIdpAssertion `xml:"L7p:Authentication"`
	Encapsulated     EncapsulatedAssertion           `xml:"L7p:Encapsulated"`
}

type Policy added in v1.0.4

type Policy struct {
	Guid         string       `xml:"guid,attr"`
	ID           string       `xml:"id,attr"`
	Version      string       `xml:"version,attr"`
	PolicyDetail PolicyDetail `xml:"l7:PolicyDetail"`

	Resources PolicyResources
}

type PolicyBody added in v1.0.4

type PolicyBody struct {
	Usage            string                  `xml:"wsp:Usage,attr"`
	CommentAssertion *CommentAssertion       `xml:"L7p:CommentAssertion"`
	SetVariable      *[]SetVariableAssertion `xml:"L7p:SetVariable"`
	OneOrMore        *OneOrMore              `xml:"wsp:OneOrMore"`
}

type PolicyDetail added in v1.0.4

type PolicyDetail struct {
	FolderId   string                 `xml:"folderId,attr"`
	Guid       string                 `xml:"guid,attr"`
	ID         string                 `xml:"id,attr"`
	Name       string                 `xml:"l7:Name"`
	PolicyType string                 `xml:"l7:PolicyType"`
	Properties PolicyDetailProperties `xml:"l7:Properties"`
}

type PolicyDetailProperties added in v1.0.4

type PolicyDetailProperties struct {
	Text     string `xml:",chardata"`
	Property []PolicyProperty
}

type PolicyProperty added in v1.0.4

type PolicyProperty struct {
	Text         string `xml:",chardata"`
	Key          string `xml:"key,attr"`
	LongValue    string `xml:"LongValue"`
	BooleanValue string `xml:"BooleanValue"`
}

type PolicyResource added in v1.0.4

type PolicyResource struct {
	Type string `xml:"type,attr"`
	Text string `xml:",chardata"`
}

type PolicyResourceSet added in v1.0.4

type PolicyResourceSet struct {
	Tag      string         `xml:"tag,attr"`
	Resource PolicyResource `xml:"l7:Resource"`
}

type PolicyResources added in v1.0.4

type PolicyResources struct {
	ResourceSet PolicyResourceSet `xml:"l7:ResourceSet"`
}

type PolicyStringValue added in v1.0.4

type PolicyStringValue struct {
	StringValue string `xml:"stringValue,attr"`
}

type PolicyXml added in v1.0.4

type PolicyXml struct {
	XMLName  xml.Name   `xml:"wsp:Policy"`
	XMLNSL7p string     `xml:"xmlns:L7p,attr"`
	XMLNSWsp string     `xml:"xmlns:wsp,attr"`
	All      PolicyBody `xml:"wsp:All"`
}

type PortalPapiToken added in v1.0.4

type PortalPapiToken struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
}

type PrivateKeyReference

type PrivateKeyReference struct {
	ID          string `xml:"id,attr"`
	ResourceURI string `xml:"resourceUri,attr"`
}

type Properties

type Properties struct {
	Property []Property `xml:"l7:Property"`
}

type Property

type Property struct {
	Key          string `xml:"key,attr"`
	StringValue  string `xml:"l7:StringValue,omitempty"`
	BooleanValue bool   `xml:"l7:BooleanValue,omitempty"`
}

type References

type References struct {
	Item []Item `xml:"l7:Item"`
}

type Resource

type Resource struct {
	ClusterProperty *ClusterProperty `xml:"l7:ClusterProperty,omitempty"`
	ListenPort      *ListenPort      `xml:"l7:ListenPort,omitempty"`
	Policy          *Policy          `xml:"l7:Policy,omitempty"`
	Service         *Service         `xml:"l7:Service,omitempty"`
}

type Service added in v1.0.4

type Service struct {
	ID            string           `xml:"id,attr"`
	L7            string           `xml:"l7,attr"`
	ServiceDetail ServiceDetail    `xml:"l7:ServiceDetail"`
	Properties    ServiceProperty  `xml:"l7:Properties"`
	Resources     ServiceResources `xml:"l7:Resources"`
}

type ServiceDetail added in v1.0.4

type ServiceDetail struct {
	Text            string            `xml:",chardata"`
	FolderId        string            `xml:"folderId,attr"`
	ID              string            `xml:"id,attr"`
	Name            string            `xml:"l7:Name"`
	Enabled         bool              `xml:"l7:Enabled"`
	ServiceMappings ServiceMappings   `xml:"l7:ServiceMappings"`
	Properties      ServiceProperties `xml:"l7:Properties"`
}

type ServiceMappings added in v1.0.4

type ServiceMappings struct {
	HttpMapping HttpMapping
}

type ServiceProperties added in v1.0.4

type ServiceProperties struct {
	Property []ServiceProperty `xml:"l7:Property"`
}

type ServiceProperty added in v1.0.4

type ServiceProperty struct {
	Key          string `xml:"key,attr"`
	BooleanValue string `xml:"l7:BooleanValue"`
	StringValue  string `xml:"l7:StringValue"`
}

type ServiceResource added in v1.0.4

type ServiceResource struct {
	Type string `xml:"type,attr"`
}

type ServiceResourceSet added in v1.0.4

type ServiceResourceSet struct {
	Tag      string          `xml:"tag,attr"`
	Resource ServiceResource `xml:"l7:Resource"`
}

type ServiceResources added in v1.0.4

type ServiceResources struct {
	ResourceSet ServiceResourceSet `xml:"l7:ResourceSet"`
}

type SetVariableAssertion added in v1.0.4

type SetVariableAssertion struct {
	AssertionComment AssertionComment  `xml:"L7p:AssertionComment"`
	Base64Expression PolicyStringValue `xml:"L7p:Base64Expression"`
	VariableToSet    PolicyStringValue `xml:"L7p:VariableToSet"`
}

type SyncCache added in v1.0.2

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

func NewSyncCache added in v1.0.2

func NewSyncCache(cleanupInterval time.Duration) *SyncCache

func (*SyncCache) Delete added in v1.0.2

func (sc *SyncCache) Delete(requestName string)

func (*SyncCache) Read added in v1.0.2

func (sc *SyncCache) Read(requestName string) (SyncRequest, error)

func (*SyncCache) Update added in v1.0.2

func (sc *SyncCache) Update(sr SyncRequest, expiryTimestamp int64)

type SyncRequest added in v1.0.2

type SyncRequest struct {
	RequestName string `json:"RequestName"`
	CacheData   string `json:"CacheData,omitempty"`
	Attempts    int    `json:"Attempts,omitempty"`
}

type TlsSettings

type TlsSettings struct {
	ClientAuthentication string              `xml:"l7:ClientAuthentication"`
	PrivateKeyReference  PrivateKeyReference `xml:"l7:PrivateKeyReference"`
	EnabledVersions      EnabledVersions     `xml:"l7:EnabledVersions"`
	EnabledCipherSuites  EnabledCipherSuites `xml:"l7:EnabledCipherSuites"`
	UseCipherSuitesOrder bool                `xml:"l7:UseCipherSuitesOrder"`
	Properties           Properties          `xml:"l7:Properties"`
}

type Verbs added in v1.0.4

type Verbs struct {
	Verb []string `xml:"l7:Verb"`
}

Jump to

Keyboard shortcuts

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