Fix file permissions to support volumes
This commit is contained in:
parent
f4da014907
commit
23ed3ba4c4
7 changed files with 148 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue