Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb248f12

Browse files
authored
chore: rename notification banners to announcement banners (#13419)
1 parentde8149f commitb248f12

File tree

42 files changed

+355
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+355
-349
lines changed

‎agent/agent.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func New(options Options) Agent {
176176
ignorePorts:options.IgnorePorts,
177177
portCacheDuration:options.PortCacheDuration,
178178
reportMetadataInterval:options.ReportMetadataInterval,
179-
notificationBannersRefreshInterval:options.ServiceBannerRefreshInterval,
179+
announcementBannersRefreshInterval:options.ServiceBannerRefreshInterval,
180180
sshMaxTimeout:options.SSHMaxTimeout,
181181
subsystems:options.Subsystems,
182182
addresses:options.Addresses,
@@ -193,7 +193,7 @@ func New(options Options) Agent {
193193
// that gets closed on disconnection. This is used to wait for graceful disconnection from the
194194
// coordinator during shut down.
195195
close(a.coordDisconnected)
196-
a.notificationBanners.Store(new([]codersdk.BannerConfig))
196+
a.announcementBanners.Store(new([]codersdk.BannerConfig))
197197
a.sessionToken.Store(new(string))
198198
a.init()
199199
returna
@@ -234,8 +234,8 @@ type agent struct {
234234
manifest atomic.Pointer[agentsdk.Manifest]// manifest is atomic because values can change after reconnection.
235235
reportMetadataInterval time.Duration
236236
scriptRunner*agentscripts.Runner
237-
notificationBanners atomic.Pointer[[]codersdk.BannerConfig]//notificationBanners is atomic because it is periodically updated.
238-
notificationBannersRefreshInterval time.Duration
237+
announcementBanners atomic.Pointer[[]codersdk.BannerConfig]//announcementBanners is atomic because it is periodically updated.
238+
announcementBannersRefreshInterval time.Duration
239239
sessionToken atomic.Pointer[string]
240240
sshServer*agentssh.Server
241241
sshMaxTimeout time.Duration
@@ -274,7 +274,7 @@ func (a *agent) init() {
274274
sshSrv,err:=agentssh.NewServer(a.hardCtx,a.logger.Named("ssh-server"),a.prometheusRegistry,a.filesystem,&agentssh.Config{
275275
MaxTimeout:a.sshMaxTimeout,
276276
MOTDFile:func()string {returna.manifest.Load().MOTDFile },
277-
NotificationBanners:func()*[]codersdk.BannerConfig {returna.notificationBanners.Load() },
277+
AnnouncementBanners:func()*[]codersdk.BannerConfig {returna.announcementBanners.Load() },
278278
UpdateEnv:a.updateCommandEnv,
279279
WorkingDirectory:func()string {returna.manifest.Load().Directory },
280280
})
@@ -709,26 +709,26 @@ func (a *agent) setLifecycle(state codersdk.WorkspaceAgentLifecycle) {
709709
// (and must be done before the session actually starts).
710710
func (a*agent)fetchServiceBannerLoop(ctx context.Context,conn drpc.Conn)error {
711711
aAPI:=proto.NewDRPCAgentClient(conn)
712-
ticker:=time.NewTicker(a.notificationBannersRefreshInterval)
712+
ticker:=time.NewTicker(a.announcementBannersRefreshInterval)
713713
deferticker.Stop()
714714
for {
715715
select {
716716
case<-ctx.Done():
717717
returnctx.Err()
718718
case<-ticker.C:
719-
bannersProto,err:=aAPI.GetNotificationBanners(ctx,&proto.GetNotificationBannersRequest{})
719+
bannersProto,err:=aAPI.GetAnnouncementBanners(ctx,&proto.GetAnnouncementBannersRequest{})
720720
iferr!=nil {
721721
ifctx.Err()!=nil {
722722
returnctx.Err()
723723
}
724724
a.logger.Error(ctx,"failed to update notification banners",slog.Error(err))
725725
returnerr
726726
}
727-
banners:=make([]codersdk.BannerConfig,0,len(bannersProto.NotificationBanners))
728-
for_,bannerProto:=rangebannersProto.NotificationBanners {
727+
banners:=make([]codersdk.BannerConfig,0,len(bannersProto.AnnouncementBanners))
728+
for_,bannerProto:=rangebannersProto.AnnouncementBanners {
729729
banners=append(banners,agentsdk.BannerConfigFromProto(bannerProto))
730730
}
731-
a.notificationBanners.Store(&banners)
731+
a.announcementBanners.Store(&banners)
732732
}
733733
}
734734
}
@@ -763,15 +763,15 @@ func (a *agent) run() (retErr error) {
763763
connMan.start("init notification banners",gracefulShutdownBehaviorStop,
764764
func(ctx context.Context,conn drpc.Conn)error {
765765
aAPI:=proto.NewDRPCAgentClient(conn)
766-
bannersProto,err:=aAPI.GetNotificationBanners(ctx,&proto.GetNotificationBannersRequest{})
766+
bannersProto,err:=aAPI.GetAnnouncementBanners(ctx,&proto.GetAnnouncementBannersRequest{})
767767
iferr!=nil {
768768
returnxerrors.Errorf("fetch service banner: %w",err)
769769
}
770-
banners:=make([]codersdk.BannerConfig,0,len(bannersProto.NotificationBanners))
771-
for_,bannerProto:=rangebannersProto.NotificationBanners {
770+
banners:=make([]codersdk.BannerConfig,0,len(bannersProto.AnnouncementBanners))
771+
for_,bannerProto:=rangebannersProto.AnnouncementBanners {
772772
banners=append(banners,agentsdk.BannerConfigFromProto(bannerProto))
773773
}
774-
a.notificationBanners.Store(&banners)
774+
a.announcementBanners.Store(&banners)
775775
returnnil
776776
},
777777
)

‎agent/agent_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) {
614614
// Set new banner func and wait for the agent to call it to update the
615615
// banner.
616616
ready:=make(chanstruct{},2)
617-
client.SetNotificationBannersFunc(func() ([]codersdk.BannerConfig,error) {
617+
client.SetAnnouncementBannersFunc(func() ([]codersdk.BannerConfig,error) {
618618
select {
619619
caseready<-struct{}{}:
620620
default:
@@ -2200,7 +2200,7 @@ func setupSSHSession(
22002200
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
22012201
defercancel()
22022202
opts=append(opts,func(c*agenttest.Client,o*agent.Options) {
2203-
c.SetNotificationBannersFunc(func() ([]codersdk.BannerConfig,error) {
2203+
c.SetAnnouncementBannersFunc(func() ([]codersdk.BannerConfig,error) {
22042204
return []codersdk.BannerConfig{banner},nil
22052205
})
22062206
})

‎agent/agentssh/agentssh.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type Config struct {
6363
// file will be displayed to the user upon login.
6464
MOTDFilefunc()string
6565
// ServiceBanner returns the configuration for the Coder service banner.
66-
NotificationBannersfunc()*[]codersdk.BannerConfig
66+
AnnouncementBannersfunc()*[]codersdk.BannerConfig
6767
// UpdateEnv updates the environment variables for the command to be
6868
// executed. It can be used to add, modify or replace environment variables.
6969
UpdateEnvfunc(current []string) (updated []string,errerror)
@@ -123,8 +123,8 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
123123
ifconfig.MOTDFile==nil {
124124
config.MOTDFile=func()string {return"" }
125125
}
126-
ifconfig.NotificationBanners==nil {
127-
config.NotificationBanners=func()*[]codersdk.BannerConfig {return&[]codersdk.BannerConfig{} }
126+
ifconfig.AnnouncementBanners==nil {
127+
config.AnnouncementBanners=func()*[]codersdk.BannerConfig {return&[]codersdk.BannerConfig{} }
128128
}
129129
ifconfig.WorkingDirectory==nil {
130130
config.WorkingDirectory=func()string {
@@ -441,13 +441,13 @@ func (s *Server) startPTYSession(logger slog.Logger, session ptySession, magicTy
441441
session.DisablePTYEmulation()
442442

443443
ifisLoginShell(session.RawCommand()) {
444-
banners:=s.config.NotificationBanners()
444+
banners:=s.config.AnnouncementBanners()
445445
ifbanners!=nil {
446446
for_,banner:=range*banners {
447-
err:=showNotificationBanner(session,banner)
447+
err:=showAnnouncementBanner(session,banner)
448448
iferr!=nil {
449-
logger.Error(ctx,"agent failed to showservice banner",slog.Error(err))
450-
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel,"yes","notification_banner").Add(1)
449+
logger.Error(ctx,"agent failed to showannouncement banner",slog.Error(err))
450+
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel,"yes","announcement_banner").Add(1)
451451
break
452452
}
453453
}
@@ -894,9 +894,9 @@ func isQuietLogin(fs afero.Fs, rawCommand string) bool {
894894
returnerr==nil
895895
}
896896

897-
//showNotificationBanner will write the service banner if enabled and not blank
897+
//showAnnouncementBanner will write the service banner if enabled and not blank
898898
// along with a blank line for spacing.
899-
funcshowNotificationBanner(session io.Writer,banner codersdk.BannerConfig)error {
899+
funcshowAnnouncementBanner(session io.Writer,banner codersdk.BannerConfig)error {
900900
ifbanner.Enabled&&banner.Message!="" {
901901
// The banner supports Markdown so we might want to parse it but Markdown is
902902
// still fairly readable in its raw form.

‎agent/agenttest/client.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ func (c *Client) GetStartupLogs() []agentsdk.Log {
138138
returnc.logs
139139
}
140140

141-
func (c*Client)SetNotificationBannersFunc(ffunc() ([]codersdk.ServiceBannerConfig,error)) {
142-
c.fakeAgentAPI.SetNotificationBannersFunc(f)
141+
func (c*Client)SetAnnouncementBannersFunc(ffunc() ([]codersdk.BannerConfig,error)) {
142+
c.fakeAgentAPI.SetAnnouncementBannersFunc(f)
143143
}
144144

145145
func (c*Client)PushDERPMapUpdate(update*tailcfg.DERPMap)error {
@@ -171,7 +171,7 @@ type FakeAgentAPI struct {
171171
lifecycleStates []codersdk.WorkspaceAgentLifecycle
172172
metadatamap[string]agentsdk.Metadata
173173

174-
getNotificationBannersFuncfunc() ([]codersdk.BannerConfig,error)
174+
getAnnouncementBannersFuncfunc() ([]codersdk.BannerConfig,error)
175175
}
176176

177177
func (f*FakeAgentAPI)GetManifest(context.Context,*agentproto.GetManifestRequest) (*agentproto.Manifest,error) {
@@ -182,28 +182,28 @@ func (*FakeAgentAPI) GetServiceBanner(context.Context, *agentproto.GetServiceBan
182182
return&agentproto.ServiceBanner{},nil
183183
}
184184

185-
func (f*FakeAgentAPI)SetNotificationBannersFunc(fnfunc() ([]codersdk.BannerConfig,error)) {
185+
func (f*FakeAgentAPI)SetAnnouncementBannersFunc(fnfunc() ([]codersdk.BannerConfig,error)) {
186186
f.Lock()
187187
deferf.Unlock()
188-
f.getNotificationBannersFunc=fn
188+
f.getAnnouncementBannersFunc=fn
189189
f.logger.Info(context.Background(),"updated notification banners")
190190
}
191191

192-
func (f*FakeAgentAPI)GetNotificationBanners(context.Context,*agentproto.GetNotificationBannersRequest) (*agentproto.GetNotificationBannersResponse,error) {
192+
func (f*FakeAgentAPI)GetAnnouncementBanners(context.Context,*agentproto.GetAnnouncementBannersRequest) (*agentproto.GetAnnouncementBannersResponse,error) {
193193
f.Lock()
194194
deferf.Unlock()
195-
iff.getNotificationBannersFunc==nil {
196-
return&agentproto.GetNotificationBannersResponse{NotificationBanners: []*agentproto.BannerConfig{}},nil
195+
iff.getAnnouncementBannersFunc==nil {
196+
return&agentproto.GetAnnouncementBannersResponse{AnnouncementBanners: []*agentproto.BannerConfig{}},nil
197197
}
198-
banners,err:=f.getNotificationBannersFunc()
198+
banners,err:=f.getAnnouncementBannersFunc()
199199
iferr!=nil {
200200
returnnil,err
201201
}
202202
bannersProto:=make([]*agentproto.BannerConfig,0,len(banners))
203203
for_,banner:=rangebanners {
204204
bannersProto=append(bannersProto,agentsdk.ProtoFromBannerConfig(banner))
205205
}
206-
return&agentproto.GetNotificationBannersResponse{NotificationBanners:bannersProto},nil
206+
return&agentproto.GetAnnouncementBannersResponse{AnnouncementBanners:bannersProto},nil
207207
}
208208

209209
func (f*FakeAgentAPI)UpdateStats(ctx context.Context,req*agentproto.UpdateStatsRequest) (*agentproto.UpdateStatsResponse,error) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp