-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a scaler based on number of objects in a GCP Storage bucket (#2648)
Signed-off-by: Ram Cohen <[email protected]> Co-authored-by: Zbynek Roubalik <[email protected]>
- Loading branch information
Showing
9 changed files
with
565 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package scalers | ||
|
||
import ( | ||
"fmt" | ||
|
||
kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" | ||
) | ||
|
||
type gcpAuthorizationMetadata struct { | ||
GoogleApplicationCredentials string | ||
GoogleApplicationCredentialsFile string | ||
podIdentityOwner bool | ||
podIdentityProviderEnabled bool | ||
} | ||
|
||
func getGcpAuthorization(config *ScalerConfig, resolvedEnv map[string]string) (*gcpAuthorizationMetadata, error) { | ||
metadata := config.TriggerMetadata | ||
authParams := config.AuthParams | ||
meta := gcpAuthorizationMetadata{} | ||
if metadata["identityOwner"] == "operator" { | ||
meta.podIdentityOwner = false | ||
} else if metadata["identityOwner"] == "" || metadata["identityOwner"] == "pod" { | ||
meta.podIdentityOwner = true | ||
switch { | ||
case config.PodIdentity == kedav1alpha1.PodIdentityProviderGCP: | ||
// do nothing, rely on underneath metadata google | ||
meta.podIdentityProviderEnabled = true | ||
case authParams["GoogleApplicationCredentials"] != "": | ||
meta.GoogleApplicationCredentials = authParams["GoogleApplicationCredentials"] | ||
default: | ||
switch { | ||
case metadata["credentialsFromEnv"] != "": | ||
meta.GoogleApplicationCredentials = resolvedEnv[metadata["credentialsFromEnv"]] | ||
case metadata["credentialsFromEnvFile"] != "": | ||
meta.GoogleApplicationCredentialsFile = resolvedEnv[metadata["credentialsFromEnvFile"]] | ||
default: | ||
return nil, fmt.Errorf("GoogleApplicationCredentials not found") | ||
} | ||
} | ||
} | ||
return &meta, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.