Documentation ¶
Index ¶
- func GetBuildClient(p *KfParams) build.BuildV1alpha1Interface
- func GetDynamicClient(p *KfParams) dynamic.Interface
- func GetKfClient(p *KfParams) kf.KfV1alpha1Interface
- func GetKubernetes(p *KfParams) k8sclient.Interface
- func GetSecretClient(p *KfParams) secrets.ClientInterface
- func GetServiceCatalogClient(p *KfParams) servicecatalogclient.Interface
- func GetServingClient(p *KfParams) serving.ServingV1alpha1Interface
- func GetSvcatApp(p *KfParams) services.SClientFactory
- func NewLoggingRoundTripper(params *KfParams, wrapped http.RoundTripper) http.RoundTripper
- func NewLoggingRoundTripperWithStream(params *KfParams, wrapped http.RoundTripper, out io.Writer) http.RoundTripper
- func Write(cfgPath string, config *KfParams) error
- type KfParams
- type LoggingRoundTripper
- type WrapperFunc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBuildClient ¶
func GetBuildClient(p *KfParams) build.BuildV1alpha1Interface
GetBuildClient returns a Build interface.
func GetDynamicClient ¶
GetDynamicClient gets a dynamic Kubernetes client. Dynamic clients can work on any type of Kubernetes object, but only support the common fields.
Dynamic clients can be used to get alternative representations of objects like tables, or traverse multiple types of object in a single pass e.g. to construct a tree based on OwnerReferences.
func GetKfClient ¶
func GetKfClient(p *KfParams) kf.KfV1alpha1Interface
GetKfClient returns a kf client.
func GetKubernetes ¶
GetKubernetes returns a K8s client.
func GetSecretClient ¶
func GetSecretClient(p *KfParams) secrets.ClientInterface
GetServingClient returns a secrets Client.
func GetServiceCatalogClient ¶
func GetServiceCatalogClient(p *KfParams) servicecatalogclient.Interface
GetServiceCatalogClient returns a ServiceCatalogClient.
func GetServingClient ¶
func GetServingClient(p *KfParams) serving.ServingV1alpha1Interface
GetServingClient returns a Serving interface.
func GetSvcatApp ¶
func GetSvcatApp(p *KfParams) services.SClientFactory
GetSvcatApp returns a SvcatClient.
func NewLoggingRoundTripper ¶
func NewLoggingRoundTripper(params *KfParams, wrapped http.RoundTripper) http.RoundTripper
NewLoggingRoundTripper creates a new logger that logs to stderr that wraps an inner RoundTripper.
func NewLoggingRoundTripperWithStream ¶
func NewLoggingRoundTripperWithStream(params *KfParams, wrapped http.RoundTripper, out io.Writer) http.RoundTripper
NewLoggingRoundTripperWithStream creates a new logger that logs to the given stream that wraps an inner RoundTripper.
func Write ¶
Write writes the current configuration to the path specified by the user or the default path.
Example ¶
dir, err := ioutil.TempDir("", "kfcfg") if err != nil { panic(err) } defer os.RemoveAll(dir) configFile := path.Join(dir, "kf.yaml") { toWrite := &KfParams{ Namespace: "my-namespace", } if err := Write(configFile, toWrite); err != nil { panic(err) } } { toRead, err := NewKfParamsFromFile(configFile) if err != nil { panic(err) } fmt.Println("Read namespace:", toRead.Namespace) }
Output: Read namespace: my-namespace
Types ¶
type KfParams ¶
type KfParams struct { // Config holds the path to the configuration. // This field isn't serialized when the config is saved. Config string `json:"-"` // Namespace holds the namespace kf should connect to by default. Namespace string `json:"space"` // KubeCfgFile holds the path to the kubeconfig. KubeCfgFile string `json:"kubeconfig"` // LogHTTP enables HTTP tracing for all Kubernetes calls. LogHTTP bool `json:"logHTTP"` // TargetSpace caches the space specified by Namespace to prevent it from // being computed multiple times. // Prefer using GetSpaceOrDefault instead of accessing this value directly. TargetSpace *v1alpha1.Space `json:"-"` }
KfParams stores everything needed to interact with the user and Knative.
func Load ¶
Load reads the config at the given path (or the default config path if not provided), and merges the values with the defaults and overrides.
func NewDefaultKfParams ¶
func NewDefaultKfParams() *KfParams
NewDefaultKfParams creates a KfParams with default values.
func NewKfParamsFromFile ¶
NewKfParamsFromFile reads the config from the specified config path or the default path. If the path is the default and the file doesn't yet exist, then this function does nothing.
func (*KfParams) GetTargetSpaceOrDefault ¶
GetTargetSpaceOrDefault gets the space specified by Namespace or a default space with minimal configuration.
This function caches a space once retrieved in CurrentSpace.
Example ¶
target := &v1alpha1.Space{} target.Name = "cached-target" p := &KfParams{ TargetSpace: target, } space, err := p.GetTargetSpaceOrDefault() fmt.Println("Space:", space.Name) fmt.Println("Error:", err)
Output: Space: cached-target Error: <nil>
func (*KfParams) SetTargetSpaceToDefault ¶
func (p *KfParams) SetTargetSpaceToDefault()
SetTargetSpaceToDefault sets TargetSpace to the default, overwriting any existing values.
Example ¶
defaultSpace := &v1alpha1.Space{} defaultSpace.SetDefaults(context.Background()) p := &KfParams{} p.SetTargetSpaceToDefault() fmt.Printf("Set to default: %v\n", reflect.DeepEqual(p.TargetSpace, defaultSpace))
Output: Set to default: true
type LoggingRoundTripper ¶
type LoggingRoundTripper struct {
// contains filtered or unexported fields
}
LoggingRoundTripper logs HTTP requests.
type WrapperFunc ¶
type WrapperFunc func(http.RoundTripper) http.RoundTripper
WrapperFunc wraps an http.RoundTripper when a new transport is created for a client, allowing per connection behavior to be injected.
func LoggingRoundTripperWrapper ¶
func LoggingRoundTripperWrapper(params *KfParams) WrapperFunc
LoggingRoundTripperWrapper returns a WrapperFunc that logs values to stderr if params.LogHTTP is true.