Fix file permissions to support volumes

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-08-15 20:25:35 -04:00
parent f4da014907
commit 23ed3ba4c4
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
7 changed files with 148 additions and 18 deletions

View file

@ -17,4 +17,4 @@ limitations under the License.
package file
// ReadWriteByUser defines linux permission to read and write files for the owner user
const ReadWriteByUser = 0660
const ReadWriteByUser = 0700

View file

@ -16,6 +16,12 @@ limitations under the License.
package file
import (
"os"
"github.com/pkg/errors"
)
const (
// AuthDirectory default directory used to store files
// to authenticate request
@ -34,3 +40,25 @@ var (
AuthDirectory,
}
)
// CreateRequiredDirectories verifies if the required directories to
// start the ingress controller exist and creates the missing ones.
func CreateRequiredDirectories() error {
for _, directory := range directories {
_, err := os.Stat(directory)
if err != nil {
if os.IsNotExist(err) {
err = os.MkdirAll(directory, ReadWriteByUser)
if err != nil {
return errors.Wrapf(err, "creating directory '%v'", directory)
}
continue
}
return errors.Wrapf(err, "checking directory %v", directory)
}
}
return nil
}