Skip to content

Commit

Permalink
Remove Grafana Cloud install scripts. (#3485)
Browse files Browse the repository at this point in the history
Not needed anymore now that we use a different install mechanism in
Grafana Cloud.
  • Loading branch information
cristiangreco authored Apr 6, 2023
1 parent 8ce1122 commit 11f9010
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 506 deletions.
60 changes: 1 addition & 59 deletions cmd/grafana-agentctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ package main
import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"path/filepath"
goruntime "runtime"
"sort"
"strings"
"syscall"
"time"

"gopkg.in/yaml.v2"

"github.com/grafana/agent/pkg/client/grafanacloud"
"github.com/grafana/agent/pkg/config"
"github.com/grafana/agent/pkg/logs"
"github.com/olekukonko/tablewriter"
Expand Down Expand Up @@ -55,7 +51,7 @@ import (
)

func main() {
var cmd = &cobra.Command{
cmd := &cobra.Command{
Use: "agentctl",
Short: "Tools for interacting with the Grafana Agent",
Version: version.Print("agentctl"),
Expand All @@ -69,7 +65,6 @@ func main() {
targetStatsCmd(),
samplesCmd(),
operatorDetachCmd(),
cloudConfigCmd(),
templateDryRunCmd(),
testLogs(),
)
Expand Down Expand Up @@ -436,59 +431,6 @@ func filterAgentOwners(refs []meta_v1.OwnerReference) (filtered []meta_v1.OwnerR
return
}

func cloudConfigCmd() *cobra.Command {
var (
stackID string
apiURL string
apiKey string
platforms string
)

cmd := &cobra.Command{
Use: "cloud-config",
Short: "Retrieves the cloud config for the Grafana Agent",
Long: `cloud-config connects to Grafana Cloud and retrieves the generated
config that may be used with this agent.`,
Args: cobra.ExactArgs(0),

// Hidden, this is only expected to be used by scripts.
Hidden: true,

RunE: func(_ *cobra.Command, args []string) error {
if stackID == "" {
return fmt.Errorf("--stack must be provided")
}
if apiKey == "" {
return fmt.Errorf("--api-key must be provided")
}

// setting timeout 2x as the default HTTP transport timeout (30s)
httpClient := &http.Client{
Timeout: time.Minute,
}
cli := grafanacloud.NewClient(httpClient, apiKey, apiURL)

cfg, err := cli.AgentConfig(context.Background(), stackID, platforms)
if err != nil {
fmt.Fprintf(os.Stderr, "could not retrieve agent cloud config: %s\n", err)
os.Exit(1)
}

fmt.Println(cfg)
return nil
},
}

cmd.Flags().StringVarP(&stackID, "stack", "u", "", "stack ID to get a config for")
cmd.Flags().StringVarP(&apiKey, "api-key", "p", "", "API key to authenticate against Grafana Cloud's API with")
cmd.Flags().StringVarP(&apiURL, "api-url", "e", "", "Grafana Cloud's API url")
cmd.Flags().StringVar(&platforms, "platforms", goruntime.GOOS, "comma-separated list of Platforms/OSes")
must(cmd.MarkFlagRequired("stack"))
must(cmd.MarkFlagRequired("api-key"))

return cmd
}

func templateDryRunCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "template-parse [directory]",
Expand Down
86 changes: 0 additions & 86 deletions pkg/client/grafanacloud/client.go

This file was deleted.

136 changes: 0 additions & 136 deletions pkg/client/grafanacloud/client_test.go

This file was deleted.

Loading

0 comments on commit 11f9010

Please sign in to comment.