formatter

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableFormatKey  = "table"
	RawFormatKey    = "raw"
	PrettyFormatKey = "pretty"
	JSONFormatKey   = "json"

	DefaultQuietFormat = "{{.ID}}"

	GREEN_COLOR = "green"
	RED_COLOR   = "red"
)

Format keys used to specify certain kinds of output formats

Variables

This section is empty.

Functions

func BackupWrite

func BackupWrite(ctx Context, Backups []ybmclient.BackupData) error

BackupWrite renders the context for a list of backups

func CdcSinkWrite

func CdcSinkWrite(ctx Context, cdcSinks []ybmclient.CdcSinkData) error

CdcSinkWrite renders the context for a list of cdc sinks

func CdcStreamWrite

func CdcStreamWrite(ctx Context, cdcStreams []ybmclient.CdcStreamData) error

CdStreamWrite renders the context for a list of cdc streams

func CloudRegionWrite

func CloudRegionWrite(ctx Context, cloudRegions []ybmclient.RegionListResponseDataItem) error

CloudRegionWrite renders the context for a list of cloud regions

func ClusterWrite

func ClusterWrite(ctx Context, clusters []ybmclient.ClusterData) error

ClusterWrite renders the context for a list of clusters

func Colorize

func Colorize(message string, colors string) string

Colorize the message accoring the colors var

func FormatDate

func FormatDate(dateToBeFormatted string) string

TODO add error handling

func InstanceTypeWrite

func InstanceTypeWrite(ctx Context, instanceTypes []ybmclient.NodeConfigurationResponseItem) error

InstanceTypeWrite renders the context for a list of instance types

func NetworkAllowListWrite

func NetworkAllowListWrite(ctx Context, nals []ybmclient.NetworkAllowListData) error

NetworkAllowListWrite renders the context for a list of network allow lists

func NewClusterInfoRegionsContext added in v0.0.6

func NewClusterInfoRegionsContext() *clusterInfoRegionsContext

func ReadReplicaWrite

func ReadReplicaWrite(ctx Context, rrSpecs []ybmclient.ReadReplicaSpec, rrEndpoints []ybmclient.Endpoint) error

ReadReplicaWrite renders the context for a list of read replicas

func VPCPeeringWrite

func VPCPeeringWrite(ctx Context, VPCPeerings []ybmclient.VpcPeeringData) error

VPCPeeringWrite renders the context for a list of VPC Peerings

func VPCWrite

func VPCWrite(ctx Context, VPCs []ybmclient.SingleTenantVpcDataResponse) error

VPCWrite renders the context for a list of VPCs

Types

type BackupContext

type BackupContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewBackupContext

func NewBackupContext() *BackupContext

NewBackupContext creates a new context for rendering Backup

func (*BackupContext) BackupState

func (c *BackupContext) BackupState() string

func (*BackupContext) BackupType

func (c *BackupContext) BackupType() string

func (*BackupContext) ClusterName

func (c *BackupContext) ClusterName() string

func (*BackupContext) CreatedOn

func (c *BackupContext) CreatedOn() string

func (*BackupContext) Description

func (c *BackupContext) Description() string

func (*BackupContext) ExpireOn

func (c *BackupContext) ExpireOn() string

func (*BackupContext) Id

func (c *BackupContext) Id() string

func (*BackupContext) MarshalJSON

func (c *BackupContext) MarshalJSON() ([]byte, error)

func (*BackupContext) RetainInDays

func (c *BackupContext) RetainInDays() string

type CdcSinkContext

type CdcSinkContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewCdcSinkContext

func NewCdcSinkContext() *CdcSinkContext

NewCdcSinkContext creates a new context for rendering cdc sink

func (*CdcSinkContext) HostName

func (c *CdcSinkContext) HostName() string

func (*CdcSinkContext) MarshalJSON

func (c *CdcSinkContext) MarshalJSON() ([]byte, error)

func (*CdcSinkContext) Name

func (c *CdcSinkContext) Name() string

func (*CdcSinkContext) State

func (c *CdcSinkContext) State() string

func (*CdcSinkContext) Type

func (c *CdcSinkContext) Type() string

type CdcStreamContext

type CdcStreamContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewCdcStreamContext

func NewCdcStreamContext() *CdcStreamContext

NewCdcStreamContext creates a new context for rendering cdc stream

func (*CdcStreamContext) DBName

func (c *CdcStreamContext) DBName() string

func (*CdcStreamContext) KafkaPrefix

func (c *CdcStreamContext) KafkaPrefix() string

func (*CdcStreamContext) LagTime

func (c *CdcStreamContext) LagTime() string

func (*CdcStreamContext) MarshalJSON

func (c *CdcStreamContext) MarshalJSON() ([]byte, error)

func (*CdcStreamContext) Name

func (c *CdcStreamContext) Name() string

func (*CdcStreamContext) State

func (c *CdcStreamContext) State() string

func (*CdcStreamContext) Tables

func (c *CdcStreamContext) Tables() string

type CloudRegionContext

type CloudRegionContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewCloudRegionContext

func NewCloudRegionContext() *CloudRegionContext

NewCloudRegionContext creates a new context for rendering cloud regions

func (*CloudRegionContext) CountryCode

func (c *CloudRegionContext) CountryCode() string

func (*CloudRegionContext) MarshalJSON

func (c *CloudRegionContext) MarshalJSON() ([]byte, error)

func (*CloudRegionContext) RegionCode

func (c *CloudRegionContext) RegionCode() string

func (*CloudRegionContext) RegionName

func (c *CloudRegionContext) RegionName() string

type ClusterContext

type ClusterContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewClusterContext

func NewClusterContext() *ClusterContext

NewClusterContext creates a new context for rendering cluster

func (*ClusterContext) DataDistribution added in v0.0.6

func (c *ClusterContext) DataDistribution() string

func (*ClusterContext) FaultTolerance added in v0.0.6

func (c *ClusterContext) FaultTolerance() string

func (*ClusterContext) HealthState

func (c *ClusterContext) HealthState() string

func (*ClusterContext) ID added in v0.0.6

func (c *ClusterContext) ID() string

func (*ClusterContext) MarshalJSON

func (c *ClusterContext) MarshalJSON() ([]byte, error)

func (*ClusterContext) Name

func (c *ClusterContext) Name() string

func (*ClusterContext) Nodes

func (c *ClusterContext) Nodes() string

func (*ClusterContext) NodesSpec

func (c *ClusterContext) NodesSpec() string

func (*ClusterContext) Provider added in v0.0.6

func (c *ClusterContext) Provider() string

func (*ClusterContext) Regions

func (c *ClusterContext) Regions() string

Return single region or the first regions with +number of others region

func (*ClusterContext) SoftwareVersion

func (c *ClusterContext) SoftwareVersion() string

func (*ClusterContext) State

func (c *ClusterContext) State() string

type Context

type Context struct {
	// Output is the output stream to which the formatted string is written.
	Output io.Writer
	// Format is used to choose raw, table or custom format for the output.
	Format Format
	// contains filtered or unexported fields
}

Context contains information required by the formatter to print the output as desired.

func (*Context) Write

func (c *Context) Write(sub SubContext, f SubFormat) error

Write the template to the buffer using this Context

type Format

type Format string

Format is the format string rendered using the Context

func NewBackupFormat

func NewBackupFormat(source string) Format

func NewCdcSinkFormat

func NewCdcSinkFormat(source string) Format

func NewCdcStreamFormat

func NewCdcStreamFormat(source string) Format

func NewCloudRegionFormat

func NewCloudRegionFormat(source string) Format

func NewClusterFormat

func NewClusterFormat(source string) Format

func NewFullClusterFormat added in v0.0.6

func NewFullClusterFormat(source string) Format

func NewInstanceTypeFormat

func NewInstanceTypeFormat(source string) Format

func NewNetworkAllowListFormat

func NewNetworkAllowListFormat(source string) Format

func NewReadReplicaFormat

func NewReadReplicaFormat(source string) Format

func NewVPCFormat

func NewVPCFormat(source string) Format

func NewVPCPeeringFormat

func NewVPCPeeringFormat(source string) Format

func (Format) Contains

func (f Format) Contains(sub string) bool

Contains returns true if the format contains the substring

func (Format) IsJSON

func (f Format) IsJSON() bool

IsJSON returns true if the format is the json format

func (Format) IsPrettyJson

func (f Format) IsPrettyJson() bool

IsJSON returns true if the format is the json format

func (Format) IsTable

func (f Format) IsTable() bool

IsTable returns true if the format is a table-type format

type FullClusterContext added in v0.0.6

type FullClusterContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewFullClusterContext added in v0.0.6

func NewFullClusterContext() *FullClusterContext

NewFullClusterContext creates a new context for rendering cluster

func (*FullClusterContext) SetFullCluster added in v0.0.6

func (c *FullClusterContext) SetFullCluster(authApi client.AuthApiClient, clusterData ybmclient.ClusterData)

func (*FullClusterContext) SubSection added in v0.0.6

func (c *FullClusterContext) SubSection(name string)

func (*FullClusterContext) Write added in v0.0.6

func (c *FullClusterContext) Write() error

type HeaderContext

type HeaderContext struct {
	Header interface{}
}

HeaderContext provides the subContext interface for managing headers

func (*HeaderContext) FullHeader

func (c *HeaderContext) FullHeader() interface{}

FullHeader returns the header as an interface

type InstanceTypeContext

type InstanceTypeContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewInstanceTypeContext

func NewInstanceTypeContext() *InstanceTypeContext

NewInstanceTypeContext creates a new context for rendering cloud regions

func (*InstanceTypeContext) AZs

func (c *InstanceTypeContext) AZs() int32

func (*InstanceTypeContext) Cores

func (c *InstanceTypeContext) Cores() int32

func (*InstanceTypeContext) DiskSize

func (c *InstanceTypeContext) DiskSize() int32

func (*InstanceTypeContext) IsEnabled

func (c *InstanceTypeContext) IsEnabled() bool

func (*InstanceTypeContext) MarshalJSON

func (c *InstanceTypeContext) MarshalJSON() ([]byte, error)

func (*InstanceTypeContext) Memory

func (c *InstanceTypeContext) Memory() int32

type NetworkAllowListContext

type NetworkAllowListContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewNetworkAllowListContext

func NewNetworkAllowListContext() *NetworkAllowListContext

NewNetworkAllowListContext creates a new context for rendering nal

func (*NetworkAllowListContext) AllowedList

func (c *NetworkAllowListContext) AllowedList() string

func (*NetworkAllowListContext) Clusters

func (c *NetworkAllowListContext) Clusters() string

func (*NetworkAllowListContext) Desc

func (c *NetworkAllowListContext) Desc() string

func (*NetworkAllowListContext) MarshalJSON

func (c *NetworkAllowListContext) MarshalJSON() ([]byte, error)

func (*NetworkAllowListContext) Name

func (c *NetworkAllowListContext) Name() string

type ReadReplicaContext

type ReadReplicaContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewReadReplicaContext

func NewReadReplicaContext() *ReadReplicaContext

NewReadReplicaContext creates a new context for rendering readReplica

func (*ReadReplicaContext) Endpoint

func (c *ReadReplicaContext) Endpoint() string

func (*ReadReplicaContext) Nodes

func (c *ReadReplicaContext) Nodes() string

func (*ReadReplicaContext) NodesSpec

func (c *ReadReplicaContext) NodesSpec() string

func (*ReadReplicaContext) Region

func (c *ReadReplicaContext) Region() string

func (*ReadReplicaContext) State

func (c *ReadReplicaContext) State() string

type SubContext

type SubContext interface {
	FullHeader() interface{}
}

SubContext defines what Context implementation should provide

type SubFormat

type SubFormat func(func(SubContext) error) error

SubFormat is a function type accepted by Write()

type SubHeaderContext

type SubHeaderContext map[string]string

SubHeaderContext is a map destined to formatter header (table format)

func (SubHeaderContext) Label

func (c SubHeaderContext) Label(name string) string

Label returns the header label for the specified string

type VPCContext

type VPCContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewVPCContext

func NewVPCContext() *VPCContext

NewVPCContext creates a new context for rendering VPC

func (*VPCContext) CIDR added in v0.0.6

func (c *VPCContext) CIDR() string

func (*VPCContext) Clusters

func (c *VPCContext) Clusters() string

func (*VPCContext) MarshalJSON

func (c *VPCContext) MarshalJSON() ([]byte, error)

func (*VPCContext) Name

func (c *VPCContext) Name() string

func (*VPCContext) Peerings

func (c *VPCContext) Peerings() string

func (*VPCContext) Provider

func (c *VPCContext) Provider() string

func (*VPCContext) Regions added in v0.0.6

func (c *VPCContext) Regions() string

func (*VPCContext) RegionsCIDR

func (c *VPCContext) RegionsCIDR() string

func (*VPCContext) State

func (c *VPCContext) State() string

type VPCPeeringContext

type VPCPeeringContext struct {
	HeaderContext
	Context
	// contains filtered or unexported fields
}

func NewVPCPeeringContext

func NewVPCPeeringContext() *VPCPeeringContext

NewVPCPeeringContext creates a new context for rendering VPC Peering

func (*VPCPeeringContext) AppVPC

func (c *VPCPeeringContext) AppVPC() string

func (*VPCPeeringContext) MarshalJSON

func (c *VPCPeeringContext) MarshalJSON() ([]byte, error)

func (*VPCPeeringContext) Name

func (c *VPCPeeringContext) Name() string

func (*VPCPeeringContext) Provider

func (c *VPCPeeringContext) Provider() string

func (*VPCPeeringContext) Status

func (c *VPCPeeringContext) Status() string

func (*VPCPeeringContext) YbVPC

func (c *VPCPeeringContext) YbVPC() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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