gateway

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 100 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

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"`
}

ClientConfig describes the endpoints we wish to connect to

type ClientsFactory

type ClientsFactory interface {
	CfgMgmtClient() (cfgmgmt.CfgMgmtClient, error)
	IngestStatusClient() (chef_ingest.IngestStatusClient, error)
	ChefIngesterClient() (chef_ingest.ChefIngesterClient, error)
	ChefIngesterJobSchedulerClient() (chef_ingest.JobSchedulerClient, error)
	ComplianceIngesterClient() (cc_ingest.ComplianceIngesterClient, error)
	NotificationsClient() (notifications.NotificationsClient, error)
	AuthenticationClient() (authn.AuthenticationClient, error)
	AuthorizationClient() (authz.AuthorizationClient, error)
	AuthorizationV2Client() (iam_v2beta.AuthorizationClient, error)
	PoliciesClient() (iam_v2beta.PoliciesClient, error)
	ProjectsClient() (iam_v2beta.ProjectsClient, error)
	TeamsV1Client() (teams_v1.TeamsV1Client, error)
	TeamsV2Client() (teams_v2.TeamsV2Client, error)
	TokensMgmtClient() (authn.TokensMgmtClient, error)
	UsersMgmtClient() (local_user.UsersMgmtClient, error)
	Notifier() (notifier.Notifier, error)
	ApplicationsClient() (applications.ApplicationsServiceClient, error)
	SecretClient() (secrets.SecretsServiceClient, error)
	NodesClient() (nodes.NodesServiceClient, error)
	FeedClient() (automate_feed.FeedServiceClient, 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.LicenseControlClient, error)
	DeploymentServiceClient() (deployment.DeploymentClient, error)
}

ClientsFactory is the interface for grpc client connections

func NewClientsFactory

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

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.

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"`
}

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 NotifierOptions

type NotifierOptions struct {
}

NotifierOptions contains options used to configure Notifier

type Opts

type Opts func(*Server)

Opts is for supporting functional options like WithClientsFactory, WithConnectionFactory, ..., passed to New()

func WithAuthorizer

WithAuthorizer allows setting the Authorizer to use

func WithAutomateURL

func WithAutomateURL(u *url.URL) Opts

WithAutomateURL allows setting the URL used externally

func WithClientsFactory

func WithClientsFactory(fy ClientsFactory) Opts

WithClientsFactory allows setting the ClientsFactory to use

func WithConnectionsFactory

func WithConnectionsFactory(fy *secureconn.Factory) Opts

WithConnectionsFactory allows setting the ConnectionsFactory to use

func WithGRPCURI

func WithGRPCURI(hostname string, port int) Opts

WithGRPCURI allows setting the internal GRPC URI to use from hostname/port

func WithLogLevel

func WithLogLevel(lvl string) Opts

WithLogLevel sets the log level to use.

Note that we keep the "functional options" style here, although we end up changing the global logger's settings, not the Server. This could become confusing, but it's also paving a way for having the Server control _its own logger_, instead of using the global one. The potential confusing scenario is unlikely: spinning up multiple Server instances with different log levels.

func WithOpenAPIUIDir

func WithOpenAPIUIDir(dir string) Opts

WithOpenAPIUIDir sets the swagger ui directory

func WithRouteFeatureToggles

func WithRouteFeatureToggles(c *Config) Opts

func WithServiceKeyPair

func WithServiceKeyPair(cert *tls.Certificate, root *x509.CertPool) Opts

WithServiceKeyPair allows setting the ServiceKeyPair to use

func WithTrialLicenseURL

func WithTrialLicenseURL(u *url.URL) Opts

WithTrialLicenseURL allows setting the URL used for trial-license-service

func WithURI

func WithURI(hostname string, port int) Opts

WithURI allows setting the URI to use from hostname and port

type ProfileRequest

type ProfileRequest struct {
	Name    string
	Version string
	Owner   string
}

type Server

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

Server holds the state of an instance of this service

func New

func New(opts ...Opts) *Server

New initializes a *Server from the passed options

func NewFromConfig

func NewFromConfig(cfg *Config) (*Server, error)

NewFromConfig initializes a Server given a Config

func (*Server) AsyncChefRunNotification

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

func (*Server) NewGRPCServer

func (s *Server) NewGRPCServer() (*grpc.Server, error)

NewGRPCServer returns a *grpc.Server instance

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

func (*Server) ReportExportHandler

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

func (*Server) Serve

func (s *Server) Serve() error

Serve finalizes the Server setup, and listens for connections. Only returns if something went wrong, with a non-nil error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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