Remove auth trial command for cloud commands

This commit is contained in:
abhisek 2024-10-05 08:56:24 +05:30
parent debe15e572
commit c0e915cfaa
No known key found for this signature in database
GPG Key ID: CB92A4990C02A88F
3 changed files with 6 additions and 32 deletions

32
auth.go
View File

@ -2,7 +2,6 @@ package main
import (
"errors"
"fmt"
"os"
"github.com/AlecAivazis/survey/v2"
@ -16,7 +15,6 @@ import (
var (
authInsightApiBaseUrl string
authControlPlaneApiBaseUrl string
authTrialEmail string
authCommunity bool
)
@ -34,7 +32,6 @@ func newAuthCommand() *cobra.Command {
cmd.AddCommand(configureAuthCommand())
cmd.AddCommand(verifyAuthCommand())
cmd.AddCommand(trialsRegisterCommand())
return cmd
}
@ -101,32 +98,3 @@ func verifyAuthCommand() *cobra.Command {
return cmd
}
func trialsRegisterCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "trial",
RunE: func(cmd *cobra.Command, args []string) error {
client := auth.NewTrialRegistrationClient(auth.TrialConfig{
Email: authTrialEmail,
ControlPlaneApiUrl: authControlPlaneApiBaseUrl,
})
res, err := client.Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
fmt.Printf("Trial registration successful with Id:%s\n", res.Id)
fmt.Printf("Check your email (%s) for API key and usage instructions\n", authTrialEmail)
fmt.Printf("The trial API key will expire on %s\n", res.ExpiresAt.String())
return nil
},
}
cmd.Flags().StringVarP(&authTrialEmail, "email", "", "",
"Email address to use for sending trial API key")
return cmd
}

View File

@ -23,6 +23,10 @@ func Verify(config *VerifyConfig) error {
return nil
}
if ApiKey() == "" {
return fmt.Errorf("API key is not set")
}
logger.Infof("Verifying auth token using Control Plane: %s", config.ControlPlaneApiUrl)
client, err := cpv1.NewClientWithResponses(config.ControlPlaneApiUrl)

View File

@ -155,6 +155,7 @@ func NewSyncReporter(config SyncReporterConfig) (Reporter, error) {
logger.Debugf("Report Sync: Creating tool session for project: %s, version: %s",
config.ProjectName, config.ProjectVersion)
// Refactor this into a common session creator function
toolServiceClient := controltowerv1grpc.NewToolServiceClient(config.ClientConnection)
toolSessionRes, err := toolServiceClient.CreateToolSession(context.Background(),
&controltowerv1.CreateToolSessionRequest{
@ -205,6 +206,7 @@ func (s *syncReporter) AddManifest(manifest *models.PackageManifest) {
logger.Debugf("Report Sync: Creating tool session for project: %s, version: %s",
projectName, projectVersion)
// Refactor this into a common session creator function
toolServiceClient := controltowerv1grpc.NewToolServiceClient(s.client)
toolSessionRes, err := toolServiceClient.CreateToolSession(context.Background(),
&controltowerv1.CreateToolSessionRequest{