server

package
v0.0.0-...-e500b2c Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromAPIIncludedSolutionDependencies

func FromAPIIncludedSolutionDependencies(sp chef.SolutionDep) []*response.SolutionDependencies

func GRPC

func GRPC(addr string, s *service.Service) error

GRPC creates and listens on grpc server

func GetExpandRunlistFromRole

func GetExpandRunlistFromRole(runlist []string, result *RoleListResult) ([]*response.RunList, error)

GetExpandRunlistFromRole expands the run-list based on role's run-list

func GetOrgAdminKeyFrom

func GetOrgAdminKeyFrom(secret *secrets.Secret) string

GetOrgAdminKeyFrom returns AdminKey

func InputValidationInterceptor

func InputValidationInterceptor() grpc.UnaryServerInterceptor

InputValidationInterceptor is a middleware for running the protobuf validation.

func NewGRPCServer

func NewGRPCServer(s *service.Service) *grpc.Server

NewGRPCServer creates a grpc server that serves all infra-proxy-service GRPC APIs

func ParseAPIError

func ParseAPIError(err error) error

ParseAPIError parses common Chef Infra Server API errors into a user-readable format.

func RemoveElement

func RemoveElement(a []string, str string) []string

RemoveElement removes the element from slice.

func SafeBooleanFromMap

func SafeBooleanFromMap(values map[string]interface{}, key string) bool

SafeStringFromMap returns the value referenced by `key` in `values`. as a boolean. If not found, it returns a boolean false.

func SafeSliceFromMap

func SafeSliceFromMap(values map[string]interface{}, key string) []string

SafeSliceFromMap returns the value referenced by `key` in `values`. as a slice. If not found, it returns an empty slice.

func SafeStringFromMap

func SafeStringFromMap(values map[string]interface{}, key string) string

SafeStringFromMap returns the value referenced by `key` in `values`. as a string. If not found, it returns an empty string.

func SafeStringFromMapFloat

func SafeStringFromMapFloat(values map[string]interface{}, key string) string

SafeStringFromMapFloat returns the value referenced by `key` in `values`. as a string (after first formatting as a base 64 float). If not found, it returns an empty string.

func StructToJSON

func StructToJSON(data *structpb.Struct) (interface{}, error)

StructToJSON convert the structpb to JSON interface object.

func SubtractSlice

func SubtractSlice(a []string, b []string) []string

SubtractSlice returns the slice a with all elements of b removed.

func ToResponseExpandedRunList

func ToResponseExpandedRunList(client *ChefClient, runlist []string, cookbooks chef.EnvironmentCookbookResult, runlistCache RunListCache) ([]*response.RunList, error)

func Unique

func Unique(a []string) []string

Unique returns a slice with duplicate values removed.

Types

type AccessKeyReq

type AccessKeyReq struct {
	Name           string `json:"name,omitempty"`
	PublicKey      string `json:"public_key,omitempty"`
	ExpirationDate string `json:"expiration_date,omitempty"`
	CreateKey      bool   `json:"create_key,omitempty"`
}

AccessKeyReq struct to add key.

type ChefClient

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

ChefClient type definition for the chef client

func NewChefClient

func NewChefClient(config *ChefConfig) (*ChefClient, error)

NewChefClient is an infra-proxy server

func (*ChefClient) SearchObjectsWithDefaults

func (c *ChefClient) SearchObjectsWithDefaults(searchIndex string, searchQuery *request.SearchQuery, params map[string]interface{}) (*chef.SearchResult, error)

SearchObjectsWithDefaults constructs the search query with defaults params values Default per_page is set 1000 Default search term q is "*:*" Default page is set to 0

func (*ChefClient) SearchRoles

func (c *ChefClient) SearchRoles(searchQuery *request.SearchQuery) (RoleListResult, error)

SearchRoles gets roles list from Chef Infra Server search API.

type ChefConfig

type ChefConfig struct {
	Name    string
	Key     string
	SkipSSL bool
	BaseURL string
}

ChefConfig is an infra-proxy server

type InfraServerStatusChecker

type InfraServerStatusChecker struct {
}

InfraServerStatusChecker implements StatusChecker

func (*InfraServerStatusChecker) GetInfraServerStatus

func (s *InfraServerStatusChecker) GetInfraServerStatus(serverHost string) (*http.Response, error)

GetInfraServerStatus gets the status of the Chef Infra Server from https://<server>/_status route

type RoleListResult

type RoleListResult struct {
	Total int          `json:"total"`
	Start int          `json:"start"`
	Rows  []*chef.Role `json:"rows"`
}

RoleListResult role list result from Search API

type RunListCache

type RunListCache map[string]map[string]bool

type Server

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

Server is an infra-proxy server

func NewServer

func NewServer(service *service.Service) *Server

NewServer returns an infra-proxy server

func (*Server) CreateClient

func (s *Server) CreateClient(ctx context.Context, req *request.CreateClient) (*response.CreateClient, error)

CreateClient creates the client

func (*Server) CreateDataBag

func (s *Server) CreateDataBag(ctx context.Context, req *request.CreateDataBag) (*response.CreateDataBag, error)

CreateDataBag creates a data bag

func (*Server) CreateDataBagItem

func (s *Server) CreateDataBagItem(ctx context.Context, req *request.CreateDataBagItem) (*response.CreateDataBagItem, error)

CreateDataBagItem creates a data bag item

func (*Server) CreateEnvironment

func (s *Server) CreateEnvironment(ctx context.Context, req *request.CreateEnvironment) (*response.Environment, error)

CreateEnvironment creates the environment

func (*Server) CreateNode

func (s *Server) CreateNode(ctx context.Context, req *request.NodeDetails) (*response.Node, error)

CreateNode creates the node

func (*Server) CreateOrg

func (s *Server) CreateOrg(ctx context.Context, req *request.CreateOrg) (*response.CreateOrg, error)

CreateOrg creates a new org

func (*Server) CreateRole

func (s *Server) CreateRole(ctx context.Context, req *request.CreateRole) (*response.Role, error)

CreateRole creates the role

func (*Server) CreateServer

func (s *Server) CreateServer(ctx context.Context, req *request.CreateServer) (*response.CreateServer, error)

CreateServer creates a new server

func (*Server) DeleteClient

func (s *Server) DeleteClient(ctx context.Context, req *request.Client) (*response.Client, error)

DeleteClient deletes the client

func (*Server) DeleteDataBag

func (s *Server) DeleteDataBag(ctx context.Context, req *request.DataBag) (*response.DataBag, error)

DeleteDataBag deletes the data bag

func (*Server) DeleteDataBagItem

func (s *Server) DeleteDataBagItem(ctx context.Context, req *request.DataBagItem) (*response.DataBagItem, error)

DeleteDataBagItem deletes the data bag item

func (*Server) DeleteEnvironment

func (s *Server) DeleteEnvironment(ctx context.Context, req *request.Environment) (*response.Environment, error)

DeleteEnvironment deletes the environment

func (*Server) DeleteNode

func (s *Server) DeleteNode(ctx context.Context, req *request.Node) (*response.DeleteNode, error)

DeleteNode deletes the node by name

func (*Server) DeleteOrg

func (s *Server) DeleteOrg(ctx context.Context, req *request.DeleteOrg) (*response.DeleteOrg, error)

DeleteOrg deletes an org from the db

func (*Server) DeletePolicyfile

func (s *Server) DeletePolicyfile(ctx context.Context, req *request.DeletePolicyfile) (*response.DeletePolicyfile, error)

DeletePolicyfile deletes the policyfile

func (*Server) DeleteRole

func (s *Server) DeleteRole(ctx context.Context, req *request.Role) (*response.Role, error)

DeleteRole deletes the role

func (*Server) DeleteServer

func (s *Server) DeleteServer(ctx context.Context, req *request.DeleteServer) (*response.DeleteServer, error)

DeleteServer deletes a server from the db

func (*Server) GetClient

func (s *Server) GetClient(ctx context.Context, req *request.Client) (*response.Client, error)

GetClient gets client

func (*Server) GetClients

func (s *Server) GetClients(ctx context.Context, req *request.Clients) (*response.Clients, error)

GetClients gets clients list

func (*Server) GetCookbook

func (s *Server) GetCookbook(ctx context.Context, req *request.Cookbook) (*response.Cookbook, error)

GetCookbook get cookbook detail

func (*Server) GetCookbookFileContent

func (s *Server) GetCookbookFileContent(ctx context.Context, req *request.CookbookFileContent) (*response.CookbookFileContent, error)

GetCookbookFileContent get the data file content of the cookbook

func (*Server) GetCookbookVersions

func (s *Server) GetCookbookVersions(ctx context.Context, req *request.CookbookVersions) (*response.CookbookVersions, error)

GetCookbookVersions get cookbook with all available versions

func (*Server) GetCookbooks

func (s *Server) GetCookbooks(ctx context.Context, req *request.Cookbooks) (*response.Cookbooks, error)

GetCookbooks get cookbooks list

func (*Server) GetDataBagItem

func (s *Server) GetDataBagItem(ctx context.Context, req *request.DataBagItem) (*response.DataBagItem, error)

GetDataBagItem gets data bag item

func (*Server) GetDataBagItems

func (s *Server) GetDataBagItems(ctx context.Context, req *request.DataBagItems) (*response.DataBagItems, error)

GetDataBagItems gets data bag items list

func (*Server) GetDataBags

func (s *Server) GetDataBags(ctx context.Context, req *request.DataBags) (*response.DataBags, error)

GetDataBags gets data bags list

func (*Server) GetEnvironment

func (s *Server) GetEnvironment(ctx context.Context, req *request.Environment) (*response.Environment, error)

GetEnvironment gets the environment details

func (*Server) GetEnvironmentRecipes

func (s *Server) GetEnvironmentRecipes(ctx context.Context, req *request.Environment) (*response.EnvironmentRecipesList, error)

GetEnvironmentRecipes get environment based recipes list

func (*Server) GetEnvironments

func (s *Server) GetEnvironments(ctx context.Context, req *request.Environments) (*response.Environments, error)

GetEnvironments gets environments list

func (*Server) GetNode

func (s *Server) GetNode(ctx context.Context, req *request.Node) (*response.Node, error)

GetNode fetches the node from chef infra server

func (*Server) GetNodeExpandedRunList

func (s *Server) GetNodeExpandedRunList(ctx context.Context, req *request.NodeExpandedRunList) (*response.NodeExpandedRunList, error)

GetNodeExpandedRunList fetches the expanded runlist of a node

func (*Server) GetNodes

func (s *Server) GetNodes(ctx context.Context, req *request.Nodes) (*response.Nodes, error)

GetNodes fetches the nodes from chef infra server

func (*Server) GetOrg

func (s *Server) GetOrg(ctx context.Context, req *request.GetOrg) (*response.GetOrg, error)

GetOrg takes an ID and returns an org object

func (*Server) GetOrgUsersList

func (s *Server) GetOrgUsersList(ctx context.Context, req *request.OrgUsers) (*response.OrgUsers, error)

GetUsersList Get a list of all users in an organization

func (*Server) GetOrgs

func (s *Server) GetOrgs(ctx context.Context, req *request.GetOrgs) (*response.GetOrgs, error)

GetOrgs returns a list of orgs from the db

func (*Server) GetPolicyfile

func (s *Server) GetPolicyfile(ctx context.Context, req *request.Policyfile) (*response.Policyfile, error)

GetPolicyfile gets a policy file

func (*Server) GetPolicyfileRevisions

func (s *Server) GetPolicyfileRevisions(ctx context.Context, req *request.PolicyfileRevisions) (*response.PolicyfileRevisions, error)

GetPolicyfileRevisions gets a policy file revisions

func (*Server) GetPolicyfiles

func (s *Server) GetPolicyfiles(ctx context.Context, req *request.Policyfiles) (*response.Policyfiles, error)

GetPolicyfiles gets a list of all policy files

func (*Server) GetPolicygroup

func (s *Server) GetPolicygroup(ctx context.Context, req *request.Policygroup) (*response.Policygroup, error)

GetPolicygroup gets a policy group

func (*Server) GetRole

func (s *Server) GetRole(ctx context.Context, req *request.Role) (*response.Role, error)

GetRole gets the role

func (*Server) GetRoleEnvironments

func (s *Server) GetRoleEnvironments(ctx context.Context, req *request.Role) (*response.RoleEnvironments, error)

GetRoleEnvironments fetches the role environments.

func (*Server) GetRoleExpandedRunList

func (s *Server) GetRoleExpandedRunList(ctx context.Context, req *request.ExpandedRunList) (*response.ExpandedRunList, error)

GetRoleExpandedRunList fetches the role run-list.

func (*Server) GetRoles

func (s *Server) GetRoles(ctx context.Context, req *request.Roles) (*response.Roles, error)

GetRoles gets roles list

func (*Server) GetServer

func (s *Server) GetServer(ctx context.Context, req *request.GetServer) (*response.GetServer, error)

GetServer takes an ID and returns a server object

func (*Server) GetServerStatus

func (s *Server) GetServerStatus(ctx context.Context, req *request.GetServerStatus) (*response.GetServerStatus, error)

GetServerStatus get the status of server

func (*Server) GetServerUsersList

func (s *Server) GetServerUsersList(ctx context.Context, req *request.ServerUsers) (*response.ServerUsers, error)

GetServerUsersList: Get a list of all users in server

func (*Server) GetServers

func (s *Server) GetServers(ctx context.Context, req *request.GetServers) (*response.GetServers, error)

GetServers returns a list of servers from the db

func (*Server) ResetClientKey

func (s *Server) ResetClientKey(ctx context.Context, req *request.ClientKey) (*response.ResetClient, error)

ResetClientKey resets the client key Deletes the associated key pair and generates new key pair again, and then attaches it to the client.

func (*Server) ResetOrgAdminKey

func (s *Server) ResetOrgAdminKey(ctx context.Context, req *request.ResetOrgAdminKey) (*response.ResetOrgAdminKey, error)

ResetOrgAdminKey updates the org admin key via PUT

func (*Server) SetAuthenticator

func (s *Server) SetAuthenticator(statusChecker StatusChecker)

func (*Server) UpdateDataBagItem

func (s *Server) UpdateDataBagItem(ctx context.Context, req *request.UpdateDataBagItem) (*response.UpdateDataBagItem, error)

UpdateDataBagItem updates a data bag item

func (*Server) UpdateEnvironment

func (s *Server) UpdateEnvironment(ctx context.Context, req *request.UpdateEnvironment) (*response.Environment, error)

UpdateEnvironment updates the environment attributes

func (*Server) UpdateNode

func (s *Server) UpdateNode(ctx context.Context, req *request.NodeDetails) (*response.Node, error)

UpdateNode updates the node

func (*Server) UpdateNodeAttributes

func (s *Server) UpdateNodeAttributes(ctx context.Context, req *request.UpdateNodeAttributes) (*response.UpdateNodeAttributes, error)

UpdateNodeAttributes updates the node attributes

func (*Server) UpdateNodeEnvironment

func (s *Server) UpdateNodeEnvironment(ctx context.Context, req *request.UpdateNodeEnvironment) (*response.UpdateNodeEnvironment, error)

UpdateNodeEnvironment updates the node environment

func (*Server) UpdateNodeTags

func (s *Server) UpdateNodeTags(ctx context.Context, req *request.UpdateNodeTags) (*response.UpdateNodeTags, error)

UpdateNodeTags updates the tags

func (*Server) UpdateOrg

func (s *Server) UpdateOrg(ctx context.Context, req *request.UpdateOrg) (*response.UpdateOrg, error)

UpdateOrg updates an org in the db via PUT

func (*Server) UpdateRole

func (s *Server) UpdateRole(ctx context.Context, req *request.UpdateRole) (*response.Role, error)

UpdateRole updates the role

func (*Server) UpdateServer

func (s *Server) UpdateServer(ctx context.Context, req *request.UpdateServer) (*response.UpdateServer, error)

UpdateServer updates a server in the db via post

type StatusChecker

type StatusChecker interface {
	GetInfraServerStatus(string) (*http.Response, error)
}

StatusChecker should have all the functions required to check the status of Chef Infra Server

Jump to

Keyboard shortcuts

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