Skip to content

Commit

Permalink
Don't create empty devworkspace-gitconfig maps
Browse files Browse the repository at this point in the history
Don't create a gitconfig map if there are on git-related
configmaps/secrets defined.

Signed-off-by: Angel Misevski <[email protected]>
  • Loading branch information
amisevsk committed Dec 16, 2021
1 parent 23def31 commit d24da23
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/provision/workspace/automount/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func GetAutoMountConfigMapSubpathVolumeMounts(mountPath string, cm corev1.Config
workspaceVolumeMounts = append(workspaceVolumeMounts, corev1.VolumeMount{
Name: common.AutoMountConfigMapVolumeName(cm.Name),
ReadOnly: true,
MountPath: mountPath,
MountPath: path.Join(mountPath, configmapKey),
SubPath: configmapKey,
})
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/provision/workspace/automount/git-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func provisionGitConfig(api sync.ClusterAPI, namespace string, userMountPath str
return podAdditions, nil
}

if gitconfig == "" {
// Nothing to store in configmap, so don't create one
return nil, nil
}
configMapPodAdditions, err := mountGitConfigMap(gitCredentialsConfigMapName, namespace, api, gitconfig)
if err != nil {
return configMapPodAdditions, err
Expand Down
6 changes: 4 additions & 2 deletions pkg/provision/workspace/automount/git-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ func provisionGitConfiguration(api sync.ClusterAPI, namespace string) (*v1alpha1
return podAdditions, err
}

podAdditions.Volumes = append(podAdditions.Volumes, gitConfigAdditions.Volumes...)
podAdditions.VolumeMounts = append(podAdditions.VolumeMounts, gitConfigAdditions.VolumeMounts...)
if gitConfigAdditions != nil {
podAdditions.Volumes = append(podAdditions.Volumes, gitConfigAdditions.Volumes...)
podAdditions.VolumeMounts = append(podAdditions.VolumeMounts, gitConfigAdditions.VolumeMounts...)
}

// Grab the credentials additions
if len(credentials) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/provision/workspace/automount/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func GetAutoMountSecretSubpathVolumeMounts(mountPath string, secret corev1.Secre
workspaceVolumeMounts = append(workspaceVolumeMounts, corev1.VolumeMount{
Name: common.AutoMountSecretVolumeName(secret.Name),
ReadOnly: true,
MountPath: mountPath,
MountPath: path.Join(mountPath, secretKey),
SubPath: secretKey,
})
}
Expand Down

0 comments on commit d24da23

Please sign in to comment.