Skip to content

Commit

Permalink
tests for azure, aws and gcs
Browse files Browse the repository at this point in the history
  • Loading branch information
AdheipSingh committed Dec 23, 2024
1 parent 0c34817 commit 437576f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 32 deletions.
68 changes: 48 additions & 20 deletions pkg/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ func waterFall(verbose bool) {
Verbose: verbose,
}

if err := deployRelease(config); err != nil {
log.Fatalf("Failed to deploy parseable, err: %v", err)
}

if err := updateInstallerConfigMap(common.InstallerEntry{
Name: pbInfo.Name,
Namespace: pbInfo.Namespace,
Expand All @@ -119,9 +123,7 @@ func waterFall(verbose bool) {
}); err != nil {
log.Fatalf("Failed to update parseable installer file, err: %v", err)
}
if err := deployRelease(config); err != nil {
log.Fatalf("Failed to deploy parseable, err: %v", err)
}

printSuccessBanner(*pbInfo, config.Version)

}
Expand Down Expand Up @@ -228,6 +230,8 @@ func applyParseableSecret(ps *ParseableInfo, store ObjectStore, objectStoreConfi
secretManifest = getParseableSecretGcs(ps, objectStoreConfig)
}

fmt.Println(secretManifest)

// apply the Kubernetes Secret
if err := applyManifest(secretManifest); err != nil {
return fmt.Errorf("failed to create and apply secret: %w", err)
Expand All @@ -247,7 +251,6 @@ metadata:
namespace: %s
type: Opaque
data:
- addr
azr.access_key: %s
azr.account: %s
azr.container: %s
Expand All @@ -260,7 +263,7 @@ data:
`,
ps.Namespace,
base64.StdEncoding.EncodeToString([]byte(objectStore.BlobStore.AccessKey)),
base64.StdEncoding.EncodeToString([]byte(objectStore.BlobStore.AccountName)),
base64.StdEncoding.EncodeToString([]byte(objectStore.BlobStore.StorageAccountName)),
base64.StdEncoding.EncodeToString([]byte(objectStore.BlobStore.Container)),
base64.StdEncoding.EncodeToString([]byte(objectStore.BlobStore.URL)),
base64.StdEncoding.EncodeToString([]byte(ps.Username)),
Expand Down Expand Up @@ -462,12 +465,18 @@ func promptStoreConfigs(store ObjectStore, chartValues []string, plan Plan) (Obj
switch store {
case S3Store:
storeValues.S3Store = S3{
URL: promptForInput(common.Yellow + " Enter S3 URL: " + common.Reset),
AccessKey: promptForInput(common.Yellow + " Enter S3 Access Key: " + common.Reset),
SecretKey: promptForInput(common.Yellow + " Enter S3 Secret Key: " + common.Reset),
Bucket: promptForInput(common.Yellow + " Enter S3 Bucket: " + common.Reset),
Region: promptForInput(common.Yellow + " Enter S3 Region: " + common.Reset),
Region: promptForInputWithDefault(common.Yellow+" Enter S3 Region (default: us-east-1): "+common.Reset, "us-east-1"),
AccessKey: promptForInputWithDefault(common.Yellow+" Enter S3 Access Key: "+common.Reset, ""),
SecretKey: promptForInputWithDefault(common.Yellow+" Enter S3 Secret Key: "+common.Reset, ""),
Bucket: promptForInputWithDefault(common.Yellow+" Enter S3 Bucket: "+common.Reset, ""),
}

// Dynamically construct the URL after Region is set
storeValues.S3Store.URL = promptForInputWithDefault(
common.Yellow+" Enter S3 URL (default: https://s3."+storeValues.S3Store.Region+".amazonaws.com): "+common.Reset,
"https://s3."+storeValues.S3Store.Region+".amazonaws.com",
)

sc, err := promptStorageClass()
if err != nil {
log.Fatalf("Failed to prompt for storage class: %v", err)
Expand All @@ -491,9 +500,21 @@ func promptStoreConfigs(store ObjectStore, chartValues []string, plan Plan) (Obj
log.Fatalf("Failed to prompt for storage class: %v", err)
}
storeValues.BlobStore = Blob{
URL: promptForInput(common.Yellow + " Enter Blob URL: " + common.Reset),
Container: promptForInput(common.Yellow + " Enter Blob Container: " + common.Reset),
StorageAccountName: promptForInputWithDefault(common.Yellow+" Enter Blob Storage Account Name: "+common.Reset, ""),
Container: promptForInputWithDefault(common.Yellow+" Enter Blob Container: "+common.Reset, ""),
// ClientID: promptForInputWithDefault(common.Yellow+" Enter Client ID: "+common.Reset, ""),
// ClientSecret: promptForInputWithDefault(common.Yellow+" Enter Client Secret: "+common.Reset, ""),
// TenantID: promptForInputWithDefault(common.Yellow+" Enter Tenant ID: "+common.Reset, ""),
AccessKey: promptForInputWithDefault(common.Yellow+" Enter Access Keys: "+common.Reset, ""),
}

// Dynamically construct the URL after Region is set
storeValues.BlobStore.URL = promptForInputWithDefault(
common.Yellow+
" Enter Blob URL (default: https://"+storeValues.BlobStore.StorageAccountName+".blob.core.windows.net): "+
common.Reset,
"https://"+storeValues.BlobStore.StorageAccountName+".blob.core.windows.net")

storeValues.StorageClass = sc
storeValues.ObjectStore = BlobStore
chartValues = append(chartValues, "parseable.store="+string(BlobStore))
Expand All @@ -512,12 +533,13 @@ func promptStoreConfigs(store ObjectStore, chartValues []string, plan Plan) (Obj
log.Fatalf("Failed to prompt for storage class: %v", err)
}
storeValues.GCSStore = GCS{
URL: promptForInput(common.Yellow + " Enter GCS URL: " + common.Reset),
AccessKey: promptForInput(common.Yellow + " Enter GCS Access Key: " + common.Reset),
SecretKey: promptForInput(common.Yellow + " Enter GCS Secret Key: " + common.Reset),
Bucket: promptForInput(common.Yellow + " Enter GCS Bucket: " + common.Reset),
Region: promptForInput(common.Yellow + " Enter GCS Region: " + common.Reset),
Bucket: promptForInputWithDefault(common.Yellow+" Enter GCS Bucket: "+common.Reset, ""),
Region: promptForInputWithDefault(common.Yellow+" Enter GCS Region (default: us-east1): "+common.Reset, "us-east1"),
URL: promptForInputWithDefault(common.Yellow+" Enter GCS URL (default: https://storage.googleapis.com):", "https://storage.googleapis.com"),
AccessKey: promptForInputWithDefault(common.Yellow+" Enter GCS Access Key: "+common.Reset, ""),
SecretKey: promptForInputWithDefault(common.Yellow+" Enter GCS Secret Key: "+common.Reset, ""),
}

storeValues.StorageClass = sc
storeValues.ObjectStore = GcsStore
chartValues = append(chartValues, "parseable.store="+string(GcsStore))
Expand Down Expand Up @@ -628,12 +650,18 @@ func getGVR(config *rest.Config, obj *unstructured.Unstructured) (schema.GroupVe
return mapping.Resource, nil
}

// Helper function to prompt for individual input values
func promptForInput(label string) string {
// Helper function to prompt for input with a default value
func promptForInputWithDefault(label, defaultValue string) string {
fmt.Print(label)
reader := bufio.NewReader(os.Stdin)
input, _ := reader.ReadString('\n')
return strings.TrimSpace(input)
input = strings.TrimSpace(input)

// Use default if input is empty
if input == "" {
return defaultValue
}
return input
}

// printBanner displays a welcome banner
Expand Down
11 changes: 7 additions & 4 deletions pkg/installer/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ type GCS struct {

// Blob contains configuration details for an Azure Blob Storage backend.
type Blob struct {
AccessKey string // Access key for authentication.
AccountName string // Account name for Azure Blob Storage.
Container string // Container name in the Azure Blob store.
URL string // URL of the Azure Blob store.
AccessKey string // Access key for authentication.
StorageAccountName string // Account name for Azure Blob Storage.
Container string // Container name in the Azure Blob store.
ClientID string // Client ID to authenticate.
ClientSecret string // Client Secret to authenticate.
TenantID string // TenantID
URL string // URL of the Azure Blob store.
}
20 changes: 12 additions & 8 deletions pkg/installer/plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@ func promptUserPlanSelection() (Plan, error) {
Details: `
--------- Plan Details ----------
{{ "Plan:" | faint }} {{ .Name }}
{{ "Ingestion Speed:" | faint }} {{ .IngestionSpeed }}
{{ "Per Day Ingestion:" | faint }} {{ .PerDayIngestion }}
{{ "Query Performance:" | faint }} {{ .QueryPerformance }}
{{ "CPU & Memory:" | faint }} {{ .CPUAndMemorySpecs }}`,
{{ "Ingestion Speed:" | faint }} {{ .IngestionSpeed }}
{{ "Per Day Ingestion:" | faint }} {{ .PerDayIngestion }}
{{ "Query Performance:" | faint }} {{ .QueryPerformance }}
{{ "CPU & Memory:" | faint }} {{ .CPUAndMemorySpecs }}`,
}

// Add a note about the default plan in the label
label := fmt.Sprintf(common.Yellow + "Select deployment type:")

prompt := promptui.Select{
Label: fmt.Sprintf(common.Yellow + "Select deployment type"),
Label: label,
Items: planList,
Templates: templates,
}
Expand All @@ -97,13 +100,14 @@ func promptUserPlanSelection() (Plan, error) {
return Plan{}, fmt.Errorf("failed to select deployment type: %w", err)
}

selectedPlan := planList[index]
fmt.Printf(
common.Cyan+" Ingestion Speed: %s\n"+
common.Cyan+" Per Day Ingestion: %s\n"+
common.Cyan+" Query Performance: %s\n"+
common.Cyan+" CPU & Memory: %s\n"+
common.Reset, planList[index].IngestionSpeed, planList[index].PerDayIngestion,
planList[index].QueryPerformance, planList[index].CPUAndMemorySpecs)
common.Reset, selectedPlan.IngestionSpeed, selectedPlan.PerDayIngestion,
selectedPlan.QueryPerformance, selectedPlan.CPUAndMemorySpecs)

return planList[index], nil
return selectedPlan, nil
}

0 comments on commit 437576f

Please sign in to comment.