diff --git a/overlord/state/notices.go b/overlord/state/notices.go index 800ff48f5c9..01535ad7a4a 100644 --- a/overlord/state/notices.go +++ b/overlord/state/notices.go @@ -205,11 +205,20 @@ const ( // Recorded by "snap run" command when it is inhibited from running a // a snap due an ongoing refresh. SnapRunInhibitNotice NoticeType = "snap-run-inhibit" + + // Recorded whenever a request prompt is created or resolved. The key for + // interfaces-requests-prompt notices is the request prompt ID. + InterfacesRequestsPromptNotice NoticeType = "interfaces-requests-prompt" + + // Recorded whenever a request rule is created, modified, deleted, or + // expired. The key for interfaces-requests-rule-update notices is the + // rule ID. + InterfacesRequestsRuleUpdateNotice NoticeType = "interfaces-requests-rule-update" ) func (t NoticeType) Valid() bool { switch t { - case ChangeUpdateNotice, WarningNotice, RefreshInhibitNotice, SnapRunInhibitNotice: + case ChangeUpdateNotice, WarningNotice, RefreshInhibitNotice, SnapRunInhibitNotice, InterfacesRequestsPromptNotice, InterfacesRequestsRuleUpdateNotice: return true } return false diff --git a/overlord/state/notices_test.go b/overlord/state/notices_test.go index bcbc00dc0db..b3d22e12ec5 100644 --- a/overlord/state/notices_test.go +++ b/overlord/state/notices_test.go @@ -282,6 +282,8 @@ func (s *noticesSuite) TestNoticesFilterType(c *C) { addNotice(c, st, nil, state.RefreshInhibitNotice, "-", nil) time.Sleep(time.Microsecond) + addNotice(c, st, nil, state.InterfacesRequestsPromptNotice, "443", nil) + time.Sleep(time.Microsecond) addNotice(c, st, nil, state.ChangeUpdateNotice, "123", nil) time.Sleep(time.Microsecond) addNotice(c, st, nil, state.WarningNotice, "Warning 1!", nil) @@ -292,11 +294,11 @@ func (s *noticesSuite) TestNoticesFilterType(c *C) { // No filter notices := st.Notices(nil) - c.Assert(notices, HasLen, 5) + c.Assert(notices, HasLen, 6) // No types notices = st.Notices(&state.NoticeFilter{}) - c.Assert(notices, HasLen, 5) + c.Assert(notices, HasLen, 6) // One type notices = st.Notices(&state.NoticeFilter{Types: []state.NoticeType{state.WarningNotice}}) @@ -310,14 +312,6 @@ func (s *noticesSuite) TestNoticesFilterType(c *C) { c.Check(n["type"], Equals, "warning") c.Check(n["key"], Equals, "Warning 2!") - // Another type - notices = st.Notices(&state.NoticeFilter{Types: []state.NoticeType{state.ChangeUpdateNotice}}) - c.Assert(notices, HasLen, 1) - n = noticeToMap(c, notices[0]) - c.Check(n["user-id"], Equals, nil) - c.Check(n["type"], Equals, "change-update") - c.Check(n["key"], Equals, "123") - // Another type notices = st.Notices(&state.NoticeFilter{Types: []state.NoticeType{state.RefreshInhibitNotice}}) c.Assert(notices, HasLen, 1) @@ -337,13 +331,13 @@ func (s *noticesSuite) TestNoticesFilterType(c *C) { // Multiple types notices = st.Notices(&state.NoticeFilter{Types: []state.NoticeType{ state.ChangeUpdateNotice, - state.RefreshInhibitNotice, + state.InterfacesRequestsPromptNotice, }}) c.Assert(notices, HasLen, 2) n = noticeToMap(c, notices[0]) c.Check(n["user-id"], Equals, nil) - c.Check(n["type"], Equals, "refresh-inhibit") - c.Check(n["key"], Equals, "-") + c.Check(n["type"], Equals, "interfaces-requests-prompt") + c.Check(n["key"], Equals, "443") n = noticeToMap(c, notices[1]) c.Check(n["user-id"], Equals, nil) c.Check(n["type"], Equals, "change-update")