Skip to content

Commit

Permalink
add support for GOOGLE_APPLICATION_CREDENTIALS env variable (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
jto authored May 12, 2021
1 parent dc1212d commit c6d8ff7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/flink/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type gcsDownloader struct{}
func (gcsDownloader) Container(artifacts []string) corev1.Container {
cmd := strings.Join([]string{
fmt.Sprintf("mkdir -p %s", defaultJarLibPath),
`if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS; fi`,
fmt.Sprintf("gsutil -m cp %s %s", strings.Join(artifacts[:], " "), defaultJarLibPath),
}, " && ")

Expand Down Expand Up @@ -203,7 +204,7 @@ func (fc *FlinkCluster) updateJobSpec(taskCtx FlinkTaskContext) error {

groupBy := GroupByScheme(taskCtx.Job.GetJarFiles())
if len(groupBy) == 0 {
// use jflye artifacts as fallback only
// use jflyte artifacts as fallback only
urls := make([]string, len(taskCtx.Job.GetJflyte().GetArtifacts()))
for i, a := range taskCtx.Job.GetJflyte().GetArtifacts() {
urls[i] = a.Location
Expand Down
1 change: 1 addition & 0 deletions pkg/flink/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func TestBuildFlinkClusterSpecJobCommand(t *testing.T) {
args := []string{
"-c",
"mkdir -p /jars/lib && " +
`if [ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS; fi && ` +
"gsutil -m cp" +
" gs://bucket/artifact0.jar" +
" gs://bucket/artifact1.jar" +
Expand Down

0 comments on commit c6d8ff7

Please sign in to comment.