gke

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: Apache-2.0 Imports: 24 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContainersClient  *container.ClusterManagerClient // handle GKE Clusters
	NetworksClient    *compute.NetworksClient         // handle GCE Networks
	SubnetworksClient *compute.SubnetworksClient      // handle GCE Subnets
	FirewallsClient   *compute.FirewallsClient        // handle GCE Firewalls

)
View Source
var GkeCmd = &cobra.Command{
	Use:   "gke",
	Short: "Manage resources on Google Kubernetes Engine (GKE)",
	Long:  `This command allows you to manage resources on GKE.`,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {

		if projectID == "" {
			projectID = os.Getenv("GCP_PROJECT_ID")
			if projectID == "" {
				return fmt.Errorf("missing project")
			}
		}

		authFile, err := cmd.Flags().GetString("auth-file")
		if err != nil {
			return err
		}
		ctx := context.Background()

		opts := []option.ClientOption{}
		if authFile != "" {
			opts = append(opts, option.WithCredentialsFile(authFile))
		}

		containerClient, err := container.NewClusterManagerClient(ctx, opts...)
		if err != nil {
			return err
		}
		ContainersClient = containerClient

		networksClient, err := compute.NewNetworksRESTClient(ctx, opts...)
		if err != nil {
			return err
		}
		NetworksClient = networksClient

		subnetworksClient, err := compute.NewSubnetworksRESTClient(ctx, opts...)
		if err != nil {
			return err
		}
		SubnetworksClient = subnetworksClient

		firewallsClient, err := compute.NewFirewallsRESTClient(ctx, opts...)
		if err != nil {
			return fmt.Errorf("NewFirewallsClient: %w", err)
		}
		FirewallsClient = firewallsClient

		return nil
	},
	PersistentPostRun: func(cmd *cobra.Command, args []string) {
		if ContainersClient != nil {
			ContainersClient.Close()
		}
		if NetworksClient != nil {
			NetworksClient.Close()
		}
		if SubnetworksClient != nil {
			SubnetworksClient.Close()
		}
		if FirewallsClient != nil {
			FirewallsClient.Close()
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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