Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import scala.collection.mutable
import scala.io.{Codec, Source}
import scala.jdk.CollectionConverters._

import io.fabric8.kubernetes.api.model.{ConfigMap, ConfigMapBuilder, KeyToPath}
import io.fabric8.kubernetes.api.model.{ConfigMap, ConfigMapBuilder, KeyToPath, KeyToPathBuilder}

import org.apache.spark.SparkConf
import org.apache.spark.annotation.{DeveloperApi, Since, Stable}
Expand Down Expand Up @@ -113,7 +113,11 @@ object KubernetesClientUtils extends Logging {
confFilesMap.map {
case (fileName: String, _: String) =>
val filePermissionMode = 420 // 420 is decimal for octal literal 0644.
new KeyToPath(fileName, filePermissionMode, fileName)
new KeyToPathBuilder()
.withKey(fileName)
.withMode(filePermissionMode)
.withPath(fileName)
.build()
}.toList.sortBy(x => x.getKey) // List is sorted to make mocking based tests work
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ class ClientSuite extends SparkFunSuite with BeforeAndAfter {
.endVolumeMount()
.build()

private val KEY_TO_PATH =
new KeyToPath(SPARK_CONF_FILE_NAME, 420, SPARK_CONF_FILE_NAME)
private def keyToPath(key: String): KeyToPath =
new KeyToPathBuilder().withKey(key).withMode(420).withPath(key).build()

private val KEY_TO_PATH = keyToPath(SPARK_CONF_FILE_NAME)

private def fullExpectedPod(keyToPaths: List[KeyToPath] = List(KEY_TO_PATH)) =
new PodBuilder(BUILT_DRIVER_POD)
Expand Down Expand Up @@ -306,7 +308,7 @@ class ClientSuite extends SparkFunSuite with BeforeAndAfter {

val (sparkConf: SparkConf, expectedConfFiles: Seq[String]) = testSetup

val expectedKeyToPaths = (expectedConfFiles.map(x => new KeyToPath(x, 420, x)).toList ++
val expectedKeyToPaths = (expectedConfFiles.map(keyToPath).toList ++
List(KEY_TO_PATH)).sortBy(x => x.getKey)

when(podsWithNamespace.resource(fullExpectedPod(expectedKeyToPaths)))
Expand Down