forked from kata-containers/kata-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kata-monitor: use regexp to check if runtime is kata containers
To support a few common configurations for Kata, including: - `io.containerd.kata.v2` - `io.containerd.kata-qemu.v2` - `io.containerd.kata-clh.v2` `kata-monintor` changes to use regexp instead of direct string comparison. Fixes: kata-containers#957 Signed-off-by: bin liu <[email protected]>
- Loading branch information
Showing
5 changed files
with
43 additions
and
6 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 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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
// Copyright (c) 2020 Ant Financial | ||
// Copyright (c) 2020 Ant Group | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
package types | ||
|
||
const ( | ||
KataRuntimeName = "io.containerd.kata.v2" | ||
DefaultKataRuntimeName = "io.containerd.kata.v2" | ||
KataRuntimeNameRegexp = `io\.containerd\.kata.*\.v2` | ||
ContainerdRuntimeTaskPath = "io.containerd.runtime.v2.task" | ||
) |
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,30 @@ | ||
// Copyright (c) 2020 Ant Group | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
package types | ||
|
||
import ( | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestKataRuntimeNameRegexp(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
runtimeNameRegexp, err := regexp.Compile(KataRuntimeNameRegexp) | ||
assert.NoError(err) | ||
|
||
// valid Kata containers name | ||
assert.Equal(true, runtimeNameRegexp.MatchString("io.containerd.kata.v2")) | ||
assert.Equal(true, runtimeNameRegexp.MatchString("io.containerd.kataclh.v2")) | ||
assert.Equal(true, runtimeNameRegexp.MatchString("io.containerd.kata-clh.v2")) | ||
assert.Equal(true, runtimeNameRegexp.MatchString("io.containerd.kata.1.2.3-clh.4.v2")) | ||
|
||
// invalid Kata containers name | ||
assert.Equal(false, runtimeNameRegexp.MatchString("io2containerd.kata.v2")) | ||
assert.Equal(false, runtimeNameRegexp.MatchString("io.c3ontainerd.kata.v2")) | ||
assert.Equal(false, runtimeNameRegexp.MatchString("io.containerd.runc.v1")) | ||
} |