Documentation
¶
Overview ¶
Package services contains logic related to HTTP and CLI clients.
Index ¶
- Constants
- type Clients
- type Gcloud
- func (g *Gcloud) ConfigGetValue(ctx context.Context, property string) (string, error)
- func (g *Gcloud) ContainerClustersGetCredentials(ctx context.Context, clusterName, clusterLocation, clusterProject string) error
- func (g *Gcloud) ContainerClustersGetCredentialsGoClient(ctx context.Context, clusterName, clusterLocation, clusterProject string) error
- type GcloudService
- type GcsService
- type Gsutil
- type Kubectl
- type KubectlService
- type OS
- func (o *OS) MkdirAll(ctx context.Context, dirname string, perm os.FileMode) error
- func (o *OS) ReadDir(ctx context.Context, dirname string) ([]os.FileInfo, error)
- func (o *OS) ReadFile(ctx context.Context, filename string) ([]byte, error)
- func (o *OS) RemoveAll(ctx context.Context, path string) error
- func (o *OS) Stat(ctx context.Context, filename string) (os.FileInfo, error)
- func (o *OS) TempDir(ctx context.Context, dir, pattern string) (string, error)
- func (o *OS) WriteFile(ctx context.Context, filename string, data []byte, perm os.FileMode) error
- type OSService
- type Remote
- type RemoteService
Constants ¶
const GsutilExec = "gsutil"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clients ¶
type Clients struct { Gcloud GcloudService Kubectl KubectlService OS OSService Remote RemoteService GCS GcsService }
Clients is a wrapper around HTTP clients and CLIs.
type Gcloud ¶
type Gcloud struct {
// contains filtered or unexported fields
}
Gcloud implements the GcloudService interface.
func NewGcloudGoClient ¶
NewGcloudGoClient returns a new Gcloud object.
func (*Gcloud) ConfigGetValue ¶
ConfigGetValue calls `gcloud config get-value <property>` and returns stdout.
func (*Gcloud) ContainerClustersGetCredentials ¶
func (*Gcloud) ContainerClustersGetCredentialsGoClient ¶
func (g *Gcloud) ContainerClustersGetCredentialsGoClient(ctx context.Context, clusterName, clusterLocation, clusterProject string) error
ContainerClustersGetCredentialsGoClient uses the go client libraries to get cluster credentials and generate the kubeconfig file for kubectl. The kubectl authenticates using the accessToken instead of the google-gke-auth-plugin (which depends on gcloud).
type GcloudService ¶
type GcloudService interface { ContainerClustersGetCredentials(ctx context.Context, clusterName, clusterLocation, clusterProject string) error ContainerClustersGetCredentialsGoClient(ctx context.Context, clusterName, clusterLocation, clusterProject string) error ConfigGetValue(ctx context.Context, property string) (string, error) }
GcloudService is an interface for gcloud operations.
type GcsService ¶
GcsService is an interface for interacting with Google Cloud Storage
type Gsutil ¶
type Gsutil struct {
// contains filtered or unexported fields
}
Gsutil implements the GcsService interface
type Kubectl ¶
type Kubectl struct {
// contains filtered or unexported fields
}
Kubectl implements the KubectlService interface. The service account that is calling this must have permission to access the cluster. e.g., to run on GCB: gcloud projects add-iam-policy-binding <project-id> --member=serviceAccount:<project-number>@cloudbuild.gserviceaccount.com --role=roles/container.admin
func NewKubectl ¶
NewKubectl returns a new Kubectl object.
func (*Kubectl) ApplyFromString ¶
ApplyFromString calls `kubectl apply -f - -n <namespace> < ${configString}`.
type KubectlService ¶
type KubectlService interface { Apply(ctx context.Context, filename, namespace string) error ApplyFromString(ctx context.Context, configString, namespace string) error Get(ctx context.Context, kind, name, namespace, format string, ignoreNotFound bool) (string, error) }
KubectlService is an interface for kubectl operations.
type OS ¶
type OS struct{}
OS implements the OSService interface.
func (*OS) MkdirAll ¶
MkdirAll creates a directory dirname, including all parent directories if they do not exist.
type OSService ¶
type OSService interface { Stat(ctx context.Context, filename string) (os.FileInfo, error) ReadDir(ctx context.Context, dirname string) ([]os.FileInfo, error) ReadFile(ctx context.Context, filename string) ([]byte, error) WriteFile(ctx context.Context, filename string, data []byte, perm os.FileMode) error MkdirAll(ctx context.Context, dirname string, perm os.FileMode) error RemoveAll(ctx context.Context, dir string) error TempDir(ctx context.Context, dir, pattern string) (string, error) }
OSService is an interface for os operations.