mirror of
https://github.com/containers/podman.git
synced 2025-12-09 23:27:09 +08:00
Merge pull request #15842 from ashley-cui/seclabels
Add labels to secrets
This commit is contained in:
@@ -7,9 +7,6 @@
|
||||
t POST secrets/create Name=mysecret Data=c2VjcmV0 200\
|
||||
.ID~.* \
|
||||
|
||||
# secret create unsupported labels
|
||||
t POST secrets/create Name=mysecret Data=c2VjcmV0 Labels='{"fail":"fail"}' 400
|
||||
|
||||
# secret create name already in use
|
||||
t POST secrets/create Name=mysecret Data=c2VjcmV0 409
|
||||
|
||||
@@ -59,8 +56,15 @@ t GET libpod/secrets/json?filters='garb1age}' 500 \
|
||||
t GET libpod/secrets/json?filters='{"label":["testl' 500 \
|
||||
.cause="unexpected end of JSON input"
|
||||
|
||||
# secret with labels
|
||||
t POST secrets/create Name=labeledsecret Data=c2VjcmV0 Labels='{"foo":"bar"}' 200
|
||||
t GET secrets/labeledsecret 200 \
|
||||
.Spec.Labels.foo=bar
|
||||
|
||||
# secret rm
|
||||
t DELETE secrets/mysecret 204
|
||||
t DELETE secrets/labeledsecret 204
|
||||
|
||||
# secret rm non-existent secret
|
||||
t DELETE secrets/bogus 404
|
||||
|
||||
|
||||
@@ -310,4 +310,41 @@ var _ = Describe("Podman secret", func() {
|
||||
Expect(inspect.OutputToString()).To(Equal(secrID))
|
||||
})
|
||||
|
||||
It("podman secret with labels", func() {
|
||||
secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
|
||||
err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
session := podmanTest.Podman([]string{"secret", "create", "--label", "foo=bar", "a", secretFilePath})
|
||||
session.WaitWithDefaultTimeout()
|
||||
secrID := session.OutputToString()
|
||||
Expect(session).Should(Exit(0))
|
||||
|
||||
inspect := podmanTest.Podman([]string{"secret", "inspect", "--format", "{{.Spec.Labels}}", secrID})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect).Should(Exit(0))
|
||||
Expect(inspect.OutputToString()).To(ContainSubstring("foo:bar"))
|
||||
|
||||
session = podmanTest.Podman([]string{"secret", "create", "--label", "foo=bar", "--label", "a:b", "b", secretFilePath})
|
||||
session.WaitWithDefaultTimeout()
|
||||
secrID = session.OutputToString()
|
||||
Expect(session).Should(Exit(0))
|
||||
|
||||
inspect = podmanTest.Podman([]string{"secret", "inspect", "--format", "{{.Spec.Labels}}", secrID})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect).Should(Exit(0))
|
||||
Expect(inspect.OutputToString()).To(ContainSubstring("foo:bar"))
|
||||
Expect(inspect.OutputToString()).To(ContainSubstring("a:b"))
|
||||
|
||||
session = podmanTest.Podman([]string{"secret", "create", "c", secretFilePath})
|
||||
session.WaitWithDefaultTimeout()
|
||||
secrID = session.OutputToString()
|
||||
Expect(session).Should(Exit(0))
|
||||
|
||||
inspect = podmanTest.Podman([]string{"secret", "inspect", "--format", "{{.Spec.Labels}}", secrID})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect).Should(Exit(0))
|
||||
Expect(inspect.OutputToString()).To(Equal("map[]"))
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user