Skip to content

Commit

Permalink
Merge pull request #4 from icgc-argo/rc/1.0.1
Browse files Browse the repository at this point in the history
Rc/1.0.1
  • Loading branch information
rtisma authored Oct 21, 2020
2 parents 0fee69e + da6f6b5 commit d48281d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1
26 changes: 11 additions & 15 deletions cmd/webhook-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,35 @@ type EmptyDirData struct {
EmptyDir interface{} `json:"emptyDir"`
}

func buildEmptyDirDatas() []EmptyDirData{
var emptyDirData = EmptyDirData{ Name: scratchVolumeName, EmptyDir: struct {}{}}
var emptyDirDatas []EmptyDirData
return append(emptyDirDatas, emptyDirData)
func buildEmptyDirData() EmptyDirData{
return EmptyDirData{ Name: scratchVolumeName, EmptyDir: struct {}{}}
}

func buildEmptyDirVolumeMounts() []corev1.VolumeMount{
var volumeMount = corev1.VolumeMount{Name: scratchVolumeName, MountPath: scratchDirName}
var volumeMounts []corev1.VolumeMount
return append(volumeMounts, volumeMount)
func buildEmptyDirVolumeMount() corev1.VolumeMount{
return corev1.VolumeMount{Name: scratchVolumeName, MountPath: scratchDirName}
}

// Adds the correct Json Patch to the patches variable for the volumes section
func appendEmptyDirPatch(patches []patchOperation) []patchOperation {
var emptyDirDatas = buildEmptyDirDatas()
var emptyDirData = buildEmptyDirData()
patches = append(patches, patchOperation{
Op: "add",
Path: "/spec/volumes",
Value: emptyDirDatas,
Path: "/spec/volumes/0",
Value: emptyDirData,
})
return patches
}

// Adds the correct Json Patch to the patches variable for the container volume mounts section
func appendVolumeMountPatch(patches []patchOperation, containerPos int, volumeMountPos int,
containerVolumeMount *corev1.VolumeMount) []patchOperation{
var emptyDirVolumeMounts = buildEmptyDirVolumeMounts()
var emptyDirVolumeMount = buildEmptyDirVolumeMount()

if containerVolumeMount == nil{
patches = append(patches, patchOperation{
Op: "add",
Path: "/spec/containers/"+strconv.Itoa(containerPos)+"/volumeMounts",
Value: emptyDirVolumeMounts,
Path: "/spec/containers/"+strconv.Itoa(containerPos)+"/volumeMounts/0",
Value: emptyDirVolumeMount,
})

} else {
Expand All @@ -91,7 +87,7 @@ func appendVolumeMountPatch(patches []patchOperation, containerPos int, volumeMo
patches = append(patches, patchOperation{
Op: "replace",
Path: "/spec/containers/"+strconv.Itoa(containerPos)+"/volumeMounts/"+strconv.Itoa(volumeMountPos),
Value: emptyDirVolumeMounts,
Value: emptyDirVolumeMount,
})
} else {
log.Println("Container volume mount ",scratchVolumeName," already exists, and NOT overriding ")
Expand Down

0 comments on commit d48281d

Please sign in to comment.