gateway

package
v0.0.0-...-be2ef80 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 118 Imported by: 1

Documentation

Index

Constants

View Source
const (
	UnknownMsg dataCollectorMsgType
	ChefActionMsg
	ChefRunStartMsg
	ChefRunConvergeMsg
	LivenessAgentMsg
	ComplianceReportMsg
)

Variables

View Source
var ErrNoConnectionConfigured = errors.New("Client not configured")

Functions

func NewDebugServer

func NewDebugServer() *debugServer

func ParseBytesToChefAction

func ParseBytesToChefAction(body []byte) *ingestProto.Action

ParseBytesToChefAction converts a message body in bytes to a ChefAction protobuf msg

func ParseBytesToChefRun

func ParseBytesToChefRun(body []byte) *ingestProto.Run

ParseBytesToChefRun converts a message body in bytes to a ChefRun protobuf msg

func ParseBytesToComplianceReport

func ParseBytesToComplianceReport(body []byte) *complianceEvent.Report

ParseBytesToComplianceReport converts a message body in bytes to a Report protobuf msg

func ParseBytesToLivenessPing

func ParseBytesToLivenessPing(body []byte) *ingestProto.Liveness

ParseBytesToLivenessPing converts a message body in bytes to a Liveness protobuf msg

func UnmarshalProtoFromBytes

func UnmarshalProtoFromBytes(body []byte, pb proto.Message) error

UnmarshalProtoFromBytes unmarshals a message body in byte to a generic protobuf msg

func UnmarshalProtoFromString

func UnmarshalProtoFromString(body string, pb proto.Message) error

UnmarshalProtoFromString unmarshals a message body (string) to a generic protobuf msg

Types

type ClientConfig

type ClientConfig struct {
	Endpoints       map[string]ConnectionOptions `mapstructure:"endpoints" toml:"endpoints"`
	Notifier        NotifierOptions              `mapstructure:"notifier" toml:"notifier"`
	NullBackendSock string                       `mapstructure:"null_backend_sock" toml:"null_backend_sock"`
}

ClientConfig describes the endpoints we wish to connect to

func (*ClientConfig) DialEndpoints

func (c *ClientConfig) DialEndpoints(connFactory *secureconn.Factory) (ClientConnections, error)

DialEndpoints dials the configured endpoints. If the configuration is missing a known gRPC service target and the null backend socket has been configured, it will attempt to dial the null backend.

type ClientConnections

type ClientConnections map[string]*grpc.ClientConn

type ClientsFactory

type ClientsFactory interface {
	CfgMgmtClient() (cfgmgmt.CfgMgmtServiceClient, error)
	IngestStatusClient() (chef_ingest.IngestStatusServiceClient, error)
	ChefIngesterClient() (chef_ingest.ChefIngesterServiceClient, error)
	ChefIngesterJobSchedulerClient() (chef_ingest.JobSchedulerServiceClient, error)
	ComplianceIngesterClient() (cc_ingest.ComplianceIngesterServiceClient, error)
	NotificationsClient() (notifications.NotificationsClient, error)
	AuthenticationClient() (authn.AuthenticationServiceClient, error)
	AuthorizationClient() (authz.AuthorizationServiceClient, error)
	PoliciesClient() (authz.PoliciesServiceClient, error)
	ProjectsClient() (authz.ProjectsServiceClient, error)
	TeamsClient() (teams.TeamsServiceClient, error)
	TokensMgmtClient() (authn.TokensMgmtServiceClient, error)
	UsersMgmtClient() (local_user.UsersMgmtServiceClient, error)
	Notifier() (notifier.Notifier, error)
	ApplicationsClient() (applications.ApplicationsServiceClient, error)
	SecretClient() (secrets.SecretsServiceClient, error)
	NodesClient() (nodes.NodesServiceClient, error)
	FeedClient() (event_feed.EventFeedServiceClient, error)
	ComplianceReportingServiceClient() (cc_reporting.ReportingServiceClient, error)
	ComplianceProfilesServiceClient() (profiles.ProfilesServiceClient, error)
	ComplianceJobsServiceClient() (jobs.JobsServiceClient, error)
	ComplianceStatsServiceClient() (cc_stats.StatsServiceClient, error)
	ComplianceVersionServiceClient() (cc_version.VersionServiceClient, error)
	NodeManagerClient() (manager.NodeManagerServiceClient, error)
	LicenseControlClient() (license_control.LicenseControlServiceClient, error)
	DeploymentServiceClient() (deployment.DeploymentClient, error)
	DatafeedClient() (data_feed.DatafeedServiceClient, error)
	PurgeClient(service string) (data_lifecycle.PurgeClient, error)
	InfraProxyClient() (infra_proxy.InfraProxyServiceClient, error)
	CdsClient() (cds.AutomateCdsServiceClient, error)
	UserSettingsClient() (user_settings.UserSettingsServiceClient, error)
	ReportManagerClient() (report_manager.ReportManagerServiceClient, error)
	Close() error
}

ClientsFactory is the interface for grpc client connections

func NewClientsFactory

func NewClientsFactory(config ClientConfig, connFactory *secureconn.Factory) (ClientsFactory, error)

NewClientsFactory creates a client factory that keeps one ClientConn per endpoint. Each factory method that returns a client will reuse the ClientConn endpoint. What this means is that you are allowed to cache each client. The target can never change. The underlying ClientConn will be responsible for maintaining the connection, where maintaining includes dealing with disconnects, service processes entering and leaving the pool, ip addresses changing, etc.

In cases where our configuration is missing known endpoints and a null backend socket location has been set in the ClientConfig, we'll connect all missing clients to the null backend via the socket. The null backend is an aggregate server backend that implements failures for all backend gRPC's that the gateway needs. This is useful because depending on the products that are deployed, not all backend services will be guaranteed to running and therefore the target bind information for those services won't be present. Yet we still want to the gateway to start up up successfully, to initialize clients, and to properly return errors when backend services are not up. Without this, gRPC will continue to dial non-existent service targets and spam the logs endlessly.

type Config

type Config struct {
	ExternalFqdn string       `mapstructure:"external_fqdn" toml:"external_fqdn"`
	GrpcClients  ClientConfig `mapstructure:"grpc_clients" toml:"grpc_clients"`
	GRPCPort     int          `mapstructure:"grpc_port" toml:"grpc_port"`
	Hostname     string       `mapstructure:"host" toml:"host"`
	Log          struct {
		Level string `mapstructure:"level" toml:"level"`
	} `mapstructure:"log" toml:"log"`
	OpenAPIUIDir      string `mapstructure:"open_api_ui_dir" toml:"open_api_ui_dir"`
	Port              int    `mapstructure:"port" toml:"port"`
	ServiceCerts      *certs.ServiceCerts
	TLSConfig         certs.TLSConfig `mapstructure:"tls" toml:"tls"`
	TrialLicenseURL   string          `mapstructure:"trial_license_url" toml:"trial_license_url"`
	EnableAppsFeature bool            `mapstructure:"enable_apps_feature" toml:"enable_apps_feature"`
	DataCollector     struct {
		DisableLimiter     bool `mapstructure:"disable_limiter" toml:"disable_limiter"`
		LimiterMaxRequests int  `mapstructure:"limiter_max_requests" toml:"limiter_max_requests"`
	} `mapstructure:"data_collector" toml:"data_collector"`
}

func ConfigFromViper

func ConfigFromViper() (Config, error)

ConfigFromViper returns a Gateway config from the services configuration file and the viper CLI arguments.

type ConnectionOptions

type ConnectionOptions struct {
	// Target to connect to
	Target string `mapstructure:"target" toml:"target"`
	Secure bool   `mapstructure:"secure" toml:"secure"`
}

ConnectionOptions describes how we wish to connect to a certain endpoint.

type DeploymentStatus

type DeploymentStatus struct {
	Ok              bool            `json:"ok"`
	ServiceStatuses []ServiceStatus `json:"service_status"`
}

type NotifierOptions

type NotifierOptions struct {
}

NotifierOptions contains options used to configure Notifier

type ProfileRequest

type ProfileRequest struct {
	Name    string
	Version string
	Owner   string
}

type Server

type Server struct {
	Config
	// contains filtered or unexported fields
}

Server holds the state of an instance of this service

func New

func New(cfg Config) *Server

New initializes a *Server from the passed options

func (*Server) AsyncChefRunNotification

func (s *Server) AsyncChefRunNotification(ctx context.Context, run *ingestProto.Run)

func (*Server) DeploymentStatusHandler

func (s *Server) DeploymentStatusHandler(w http.ResponseWriter, r *http.Request)

func (*Server) NodeExportHandler

func (s *Server) NodeExportHandler(w http.ResponseWriter, r *http.Request)

func (*Server) ProfileCreateHandler

func (s *Server) ProfileCreateHandler(w http.ResponseWriter, r *http.Request)

func (*Server) ProfileTarHandler

func (s *Server) ProfileTarHandler(w http.ResponseWriter, r *http.Request)

func (*Server) RegisterGRPCServices

func (s *Server) RegisterGRPCServices(grpcServer *grpc.Server) error

RegisterGRPCServices registers all grpc services in the passed *grpc.Server nolint: gocyclo

func (*Server) ReportExportHandler

func (s *Server) ReportExportHandler(w http.ResponseWriter, r *http.Request)

func (*Server) ReportManagerExportHandler

func (s *Server) ReportManagerExportHandler(w http.ResponseWriter, r *http.Request)

func (*Server) Start

func (s *Server) Start() error

type ServiceStatus

type ServiceStatus struct {
	Service string `json:"service"`
	Status  string `json:"status"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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