diff --git a/pkg/splunk/client/gcpbucketclient.go b/pkg/splunk/client/gcpbucketclient.go index a5c0683f1..86b5570d7 100644 --- a/pkg/splunk/client/gcpbucketclient.go +++ b/pkg/splunk/client/gcpbucketclient.go @@ -18,7 +18,6 @@ package client import ( "context" "strings" - //"encoding/json" "io" "os" @@ -119,12 +118,6 @@ func InitGCSClient(ctx context.Context, gcpCredentials string) (GCSClientInterfa if len(gcpCredentials) == 0 { client, err = storage.NewClient(ctx) } else { - //var creds google.Credentials - //err = json.Unmarshal([]byte(gcpCredentials), &creds) - //if err != nil { - // scopedLog.Error(err, "Secret key.json value is not parsable") - // return nil, err - //} client, err = storage.NewClient(ctx, option.WithCredentialsJSON([]byte(gcpCredentials))) } @@ -132,19 +125,6 @@ func InitGCSClient(ctx context.Context, gcpCredentials string) (GCSClientInterfa scopedLog.Error(err, "Failed to initialize a GCS client.") return nil, err } - // Test if the client can access buckets - //buckets := client.Buckets(ctx, "") - //for { - // bucketAttrs, err := buckets.Next() - // if err == iterator.Done { - // break - // } - // if err != nil { - // scopedLog.Error(err, "Failed to list buckets.") - // return nil, err - // } - // scopedLog.Info("Found bucket", "BucketName", bucketAttrs.Name) - //} scopedLog.Info("GCS Client initialization successful.") return &GCSClientWrapper{Client: client}, nil @@ -200,6 +180,10 @@ func (gcsClient *GCSClient) GetAppsList(ctx context.Context) (RemoteDataListResp var objects []*RemoteObject maxKeys := 4000 // Limit the number of objects manually + if strings.HasSuffix(gcsClient.StartAfter, "/") { + startAfterFound = true + } + for count := 0; count < maxKeys; { objAttrs, err := it.Next() if err == iterator.Done { @@ -212,11 +196,10 @@ func (gcsClient *GCSClient) GetAppsList(ctx context.Context) (RemoteDataListResp // Implement "StartAfter" logic to skip objects until the desired one is found if !startAfterFound { - if strings.HasPrefix(objAttrs.Name, gcsClient.StartAfter) { + if objAttrs.Name == gcsClient.StartAfter { startAfterFound = true // Start adding objects after this point - } else { - continue - } + } + continue } // Map GCS object attributes to RemoteObject diff --git a/test/testenv/appframework_utils.go b/test/testenv/appframework_utils.go index 5f94711c7..1a96660f4 100644 --- a/test/testenv/appframework_utils.go +++ b/test/testenv/appframework_utils.go @@ -403,8 +403,6 @@ func GenerateAppFrameworkSpec(ctx context.Context, testenvInstance *TestCaseEnv, return appFrameworkSpec } - - // WaitforPhaseChange Wait for 2 mins or when phase change on is seen on a CR for any particular app func WaitforPhaseChange(ctx context.Context, deployment *Deployment, testenvInstance *TestCaseEnv, name string, crKind string, appSourceName string, appList []string) { startTime := time.Now() diff --git a/test/testenv/gcputils.go b/test/testenv/gcputils.go index 4d7f40787..609c236e4 100644 --- a/test/testenv/gcputils.go +++ b/test/testenv/gcputils.go @@ -59,7 +59,7 @@ func NewGCPClient() (*GCPClient, error) { ctx := context.Background() var client *storage.Client encodedString := os.Getenv("GCP_SERVICE_ACCOUNT_KEY") - gcpCredentials, err := base64.StdEncoding.DecodeString(encodedString) + gcpCredentials, err := base64.StdEncoding.DecodeString(encodedString) if err != nil { logf.Log.Error(err, "Error decoding GCP service account key") return nil, err @@ -391,8 +391,6 @@ func UploadFilesToGCP(bucketName, gcpTestDir string, appList []string, uploadDir return uploadedFiles, nil } - - // DisableAppsToGCP untars apps, modifies their config files to disable them, re-tars, and uploads the disabled versions to GCP func DisableAppsToGCP(downloadDir string, appFileList []string, gcpTestDir string) ([]string, error) { // Create directories for untarred and disabled apps