{"modulePath":"github.com/jetstack/preflight","version":"v1.13.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package client\n\n## Constants\n\n```go\nconst (\n\t// URL for the venafi-cloud backend services\n\tVenafiCloudProdURL = \"https://api.venafi.cloud\"\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// ClientID is the auth0 client identifier (injected at build time)\n\tClientID string\n\n\t// ClientSecret is the auth0 client secret (injected at build time)\n\tClientSecret string\n\n\t// AuthServerDomain is the auth0 domain (injected at build time)\n\tAuthServerDomain string\n)\n```\n\n## Types\n\n```go\ntype APITokenClient struct {\n\t// contains filtered or unexported fields\n}\n```\nThe APITokenClient type is a Client implementation used to upload data readings to the Jetstack Secure platform using API tokens as its authentication method.\n\n```go\nfunc NewAPITokenClient(agentMetadata *api.AgentMetadata, apiToken, baseURL string) (*APITokenClient, error)\n```\nNewAPITokenClient returns a new instance of the APITokenClient type that will perform HTTP requests using the provided API token for authentication.\n\n```go\nfunc (c *APITokenClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, opts Options) error\n```\nPostDataReadingsWithOptions uploads the slice of api.DataReading to the Jetstack Secure backend to be processed for later viewing in the user-interface.\n\n```go\ntype Client interface {\n\tPostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, options Options) error\n}\n```\nThe Client interface describes types that perform requests against the Jetstack Secure backend.\n\n```go\nfunc NewFileClient(path string) Client\n```\n\n```go\ntype Credentials interface {\n\tIsClientSet() (ok bool, why string)\n\tValidate() error\n}\n```\nThe Credentials interface describes methods for credential types to implement for verification.\n\n```go\ntype CyberArkClient struct {\n\t// contains filtered or unexported fields\n}\n```\nCyberArkClient is a client for publishing data readings to CyberArk's discoverycontext API.\n\n```go\nfunc NewCyberArk(log logr.Logger, httpClient *http.Client, subdomain, serviceID, account, jwtSource, jwtFilePath string) (*CyberArkClient, error)\n```\nNewCyberArk initializes a CyberArk client. subdomain, serviceID, account, jwtSource, and jwtFilePath come from the agent YAML config (config.cyberark.\\*); subdomain falls back to ARK\\_SUBDOMAIN when empty. Legacy username/password credentials remain env-var-only (ARK\\_USERNAME, ARK\\_SECRET) since they're real credentials.\n\n```go\nfunc (o *CyberArkClient) Config() (cyberark.ClientConfig, error)\n```\n\n```go\nfunc (o *CyberArkClient) DiscoveryClient() *servicediscovery.Client\n```\n\n```go\nfunc (o *CyberArkClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, opts Options) error\n```\nPostDataReadingsWithOptions uploads data readings to CyberArk. It converts the supplied data readings into a snapshot format expected by CyberArk. Deleted resources are excluded from the snapshot because they are not needed by CyberArk. It then minimizes the snapshot to avoid uploading unnecessary data. It initializes a data upload client with the configured HTTP client and credentials, then uploads a snapshot. The supplied Options are not used by this publisher.\n\n```go\ntype FileClient struct {\n\t// contains filtered or unexported fields\n}\n```\nFileClient writes the supplied readings to a file, in JSON format.\n\n```go\nfunc (o *FileClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, _ Options) error\n```\n\n```go\ntype NGTSClient struct {\n\n\t// Made public for testing purposes.\n\tClient *http.Client\n\t// contains filtered or unexported fields\n}\n```\nNGTSClient is a Client implementation for uploading data readings to NGTS using service account keypair authentication. It follows the Private Key JWT authentication pattern (RFC 7521 + RFC 7523).\n\n```go\nfunc NewNGTSClient(agentMetadata *api.AgentMetadata, credentials *NGTSServiceAccountCredentials, baseURL string, tsgID string, rootCAs *x509.CertPool) (*NGTSClient, error)\n```\nNewNGTSClient creates a new NGTS client that authenticates using keypair authentication and uploads data to NGTS endpoints. Exactly one of tsgID or baseURL must be provided: tsgID derives the production NGTS URL; baseURL sets a custom URL for testing.\n\n```go\nfunc (c *NGTSClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, opts Options) error\n```\nPostDataReadingsWithOptions uploads data readings to the NGTS backend. The TSG ID is included in the upload path to identify the tenant service group.\n\n```go\ntype NGTSServiceAccountCredentials struct {\n\t// ClientID is the service account client ID\n\tClientID string `json:\"client_id,omitempty\"`\n\t// PrivateKeyFile is the path to the private key file paired to\n\t// the public key in the service account\n\tPrivateKeyFile string `json:\"private_key_file,omitempty\"`\n}\n```\nNGTSServiceAccountCredentials holds the service account authentication credentials for NGTS.\n\n```go\nfunc (c *NGTSServiceAccountCredentials) LoadClientIDIfNeeded() error\n```\nLoadClientIDIfNeeded attempts to load the ClientID from a file if it is not already set. It looks for a \"clientID\" file in the same directory as the PrivateKeyFile. For compatibility with the venafi-kubernetes-agent chart, it also supports \"clientId\" (lowercase 'd'). If both files exist, \"clientID\" takes precedence. This allows the ClientID to be provided either as a direct value or via a Kubernetes secret.\n\n```go\nfunc (c *NGTSServiceAccountCredentials) Validate() error\n```\nValidate checks that the NGTS service account credentials are valid.\n\n```go\ntype OAuthClient struct {\n\t// contains filtered or unexported fields\n}\n```\nThe OAuthClient type is a Client implementation used to upload data readings to the Jetstack Secure platform using OAuth as its authentication method.\n\n```go\nfunc NewOAuthClient(agentMetadata *api.AgentMetadata, credentials *OAuthCredentials, baseURL string) (*OAuthClient, error)\n```\nNewOAuthClient returns a new instance of the OAuthClient type that will perform HTTP requests using OAuth to provide authentication tokens to the backend API.\n\n```go\nfunc (c *OAuthClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, opts Options) error\n```\n\n```go\ntype OAuthCredentials struct {\n\t// UserID is the ID or email for the user or service account.\n\tUserID string `json:\"user_id\"`\n\t// UserSecret is the secret for the user or service account.\n\tUserSecret string `json:\"user_secret\"`\n\t// The following fields are optional as the default behaviour\n\t// is to use the equivalent variables defined at package level\n\t// and injected at build time.\n\t// ClientID is the oauth2 client ID.\n\tClientID string `json:\"client_id,omitempty\"`\n\t// ClientSecret is the oauth2 client secret.\n\tClientSecret string `json:\"client_secret,omitempty\"`\n\t// AuthServerDomain is the domain for the auth server.\n\tAuthServerDomain string `json:\"auth_server_domain,omitempty\"`\n}\n```\nOAuthCredentials defines the format of the credentials.json file.\n\n```go\nfunc ParseOAuthCredentials(data []byte) (*OAuthCredentials, error)\n```\nPerforms validations. Since it may return a multierror.Error, remember to use multierror.Prefix(err, \"context: \") rather than fmt.Errorf(\"context: %w\", err) when wrapping the error.\n\n```go\nfunc (c *OAuthCredentials) IsClientSet() (ok bool, why string)\n```\nIsClientSet returns whether the client credentials are set or not. \\`why\\` is only returned when \\`ok\\` is false.\n\n```go\nfunc (c *OAuthCredentials) Validate() error\n```\n\n```go\ntype Options struct {\n\t// Only used with Jetstack Secure.\n\tOrgID string\n\n\t// Only used with Jetstack Secure.\n\tClusterID string\n\n\t// Used for Venafi Cloud and MachineHub mode.\n\tClusterName string\n\n\t// Used for Venafi Cloud and MachineHub mode.\n\tClusterDescription string\n\n\t// ClaimableCerts controls whether discovered certs can be claimed by other tenants.\n\t// true = certs are left unassigned, available for any tenant to claim.\n\t// false (default) = certs are owned by this cluster's tenant.\n\tClaimableCerts bool\n}\n```\nOptions is the struct describing additional information pertinent to an agent that isn't a data reading These fields will then be uploaded together with data readings.\n\n```go\ntype VenConnClient struct {\n\n\t// Used to make HTTP requests to Venafi Cloud. This field is public for\n\t// testing purposes so that we can configure trusted CAs; there should be a\n\t// way to do that without messing with the client directly (e.g., a flag to\n\t// pass a custom CA?), but it's not there yet.\n\tClient *http.Client\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewVenConnClient(restcfg *rest.Config, agentMetadata *api.AgentMetadata, installNS, venConnName, venConnNS string, trustedCAs *x509.CertPool) (*VenConnClient, error)\n```\nNewVenConnClient lets you make requests to the Venafi Cloud backend using the given VenafiConnection resource.\n\nYou need to call Start to start watching the VenafiConnection resource. If you don't, the client will be unable to find the VenafiConnection that you are referring to as its client-go cache will remain empty.\n\nThe http.Client is used for Venafi and Vault, not for Kubernetes. The \\`installNS\\` is the namespace in which the agent is running in and cannot be empty. \\`venConnName\\` and \\`venConnNS\\` must not be empty either. The passed \\`restcfg\\` is not mutated. \\`trustedCAs\\` is only used for connecting to Venafi Cloud and Vault and can be left nil.\n\n```go\nfunc (c *VenConnClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, opts Options) error\n```\n\\`opts.ClusterName\\` and \\`opts.ClusterDescription\\` are the only values used from the Options struct. OrgID and ClusterID are not used in Venafi Cloud.\n\n```go\nfunc (c *VenConnClient) Start(ctx context.Context) error\n```\nStart starts watching VenafiConnections. This function will return soon after the context is closed, or if an error occurs.\n\n```go\ntype VenafiCloudClient struct {\n\n\t// Made public for testing purposes.\n\tClient *http.Client\n\t// contains filtered or unexported fields\n}\n```\nThe VenafiCloudClient type is a Client implementation used to upload data readings to the Venafi Cloud platform using service account authentication as its authentication method.\n\nThis form of authentication follows the Private Key JWT standard found at [https://oauth.net/private-key-jwt](https://oauth.net/private-key-jwt), which is a combination of two RFCs: \\* RFC 7521 (Assertion Framework) \\* RFC 7523 (JWT Profile for Client Authentication)\n\n```go\nfunc NewVenafiCloudClient(agentMetadata *api.AgentMetadata, credentials *VenafiSvcAccountCredentials, baseURL string, uploaderID string, uploadPath string) (*VenafiCloudClient, error)\n```\nNewVenafiCloudClient returns a new instance of the VenafiCloudClient type that will perform HTTP requests using a bearer token to authenticate to the backend API.\n\n```go\nfunc (c *VenafiCloudClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, opts Options) error\n```\nPostDataReadingsWithOptions uploads the slice of api.DataReading to the Venafi Cloud backend to be processed. The Options are then passed as URL params in the request\n\n```go\ntype VenafiSvcAccountCredentials struct {\n\t// ClientID is the service account client ID\n\tClientID string `json:\"client_id,omitempty\"`\n\t// PrivateKeyFile is the path to the private key file paired to\n\t// the public key in the service account\n\tPrivateKeyFile string `json:\"private_key_file,omitempty\"`\n}\n```\n\n```go\nfunc ParseVenafiCredentials(data []byte) (*VenafiSvcAccountCredentials, error)\n```\nParseVenafiCredentials reads credentials into a VenafiSvcAccountCredentials struct. Performs validations.\n\n```go\nfunc (c *VenafiSvcAccountCredentials) IsClientSet() (ok bool, why string)\n```\nIsClientSet returns whether the client credentials are set or not. \\`why\\` is only returned when \\`ok\\` is false.\n\n```go\nfunc (c *VenafiSvcAccountCredentials) Validate() error\n```\n\n","path":"github.com/jetstack/preflight/pkg/client","name":"client","synopsis":"","isRedistributable":true}
