-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(security): Fix redis start issue #2863 Now redis starts with conf file with credentials and thus insecure gap is removed - Refactor security-bootstrap-redis to absorbed into security-bootstrapper as one of command - Remove security-bootstrap-redis binary build - Redis db server starts with config file with credentials - Update snaps Closes: #2863 Signed-off-by: Jim Wang <[email protected]> Change the redis.conf file permission to 0600 Make chown for redis' conf to redis:redis 999:1000 as part of redis' uid and gid creation Add doc's url and detailed explanation for redis' conf EdgeX is currently using Remove the change ownership from golang code and only do the change ownership inside the docker's entrypoint script because snap doesn't work with chow to a non-existing userId. Signed-off-by: Jim Wang <[email protected]> * feat(snap): add patch contnets patch -p1 < ./0001-fix-snap-update-the-snap-optimization-patch.patch.txt patching file snap/local/patches/0001-optimize-build-for-pipeline-CI-check.patch Signed-off-by: Jim Wang <[email protected]>
- Loading branch information
1 parent
9ee6a91
commit cb6997b
Showing
22 changed files
with
578 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/******************************************************************************* | ||
* Copyright 2021 Intel Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
*******************************************************************************/ | ||
|
||
package helper | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
// MarkComplete creates a doneFile file | ||
func MarkComplete(dirPath, doneFile string) error { | ||
doneFilePath := filepath.Join(dirPath, doneFile) | ||
if !checkIfFileExists(doneFilePath) { | ||
if err := writeFile(doneFilePath); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// CreateDirectoryIfNotExists makes a directory if not exists yet | ||
func CreateDirectoryIfNotExists(dirName string) (err error) { | ||
if _, err = os.Stat(dirName); err == nil { | ||
// already exists, skip | ||
return nil | ||
} else if os.IsNotExist(err) { | ||
// dirName not exists yet, create it | ||
err = os.MkdirAll(dirName, os.ModePerm) | ||
} | ||
|
||
return | ||
} | ||
|
||
func checkIfFileExists(fileName string) bool { | ||
fileInfo, statErr := os.Stat(fileName) | ||
if os.IsNotExist(statErr) { | ||
return false | ||
} | ||
return !fileInfo.IsDir() | ||
} | ||
|
||
func writeFile(aFileName string) error { | ||
timestamp := []byte(strconv.FormatInt(time.Now().Unix(), 10)) | ||
return ioutil.WriteFile(aFileName, timestamp, 0400) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/******************************************************************************* | ||
* Copyright 2021 Intel Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
* | ||
*******************************************************************************/ | ||
|
||
package helper | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMarkComplete(t *testing.T) { | ||
testDir := "testDir" | ||
doneFile := "testDone" | ||
|
||
defer (cleanupDir(testDir))() | ||
|
||
err := os.MkdirAll(testDir, os.ModePerm) | ||
require.NoError(t, err) | ||
|
||
err = MarkComplete(testDir, doneFile) | ||
require.NoError(t, err) | ||
|
||
require.FileExists(t, filepath.Join(testDir, doneFile)) | ||
} | ||
|
||
func TestCreateDirectoryIfNotExists(t *testing.T) { | ||
testDir := "testDirNew" | ||
require.NoDirExists(t, testDir) | ||
defer (cleanupDir(testDir))() | ||
|
||
err := CreateDirectoryIfNotExists(testDir) | ||
require.NoError(t, err) | ||
require.DirExists(t, testDir) | ||
|
||
testPreCreatedDir := "pre-created-dir" | ||
defer (cleanupDir(testPreCreatedDir))() | ||
|
||
err = os.MkdirAll(testPreCreatedDir, os.ModePerm) | ||
require.NoError(t, err) | ||
err = CreateDirectoryIfNotExists(testPreCreatedDir) | ||
require.NoError(t, err) | ||
require.DirExists(t, testPreCreatedDir) | ||
} | ||
|
||
// cleanupDir deletes all files in the directory and files in the directory | ||
func cleanupDir(dir string) func() { | ||
return func() { | ||
_ = os.RemoveAll(dir) | ||
} | ||
} |
Oops, something went wrong.