Skip to content

Commit db92f72

Browse files
committed
kyle comments + add test
1 parent f1727d0 commit db92f72

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

provisionerd/provisionerd.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ func (p *Server) runJob(ctx context.Context, job *proto.AcquiredJob) {
452452
}
453453
}
454454

455+
// ReadmeFile is the location we look for to extract documentation from template
456+
// versions.
455457
const ReadmeFile = "README.md"
456458

457459
func (p *Server) runReadmeParse(ctx context.Context, job *proto.AcquiredJob) {
@@ -467,7 +469,7 @@ func (p *Server) runReadmeParse(ctx context.Context, job *proto.AcquiredJob) {
467469
JobId: job.GetJobId(),
468470
Logs: []*proto.Log{{
469471
Source: proto.LogSource_PROVISIONER_DAEMON,
470-
Level: sdkproto.LogLevel_INFO,
472+
Level: sdkproto.LogLevel_DEBUG,
471473
Stage: "No README.md provided",
472474
CreatedAt: time.Now().UTC().UnixMilli(),
473475
}},
@@ -484,7 +486,7 @@ func (p *Server) runReadmeParse(ctx context.Context, job *proto.AcquiredJob) {
484486
Logs: []*proto.Log{{
485487
Source: proto.LogSource_PROVISIONER_DAEMON,
486488
Level: sdkproto.LogLevel_INFO,
487-
Stage: "README.md detected",
489+
Stage: "Adding README.md...",
488490
CreatedAt: time.Now().UTC().UnixMilli(),
489491
}},
490492
Readme: fi,

provisionerd/provisionerd_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ func TestProvisionerd(t *testing.T) {
214214
didLog atomic.Bool
215215
didAcquireJob atomic.Bool
216216
didDryRun atomic.Bool
217+
didReadme atomic.Bool
217218
completeChan = make(chan struct{})
218219
completeOnce sync.Once
219220
)
@@ -230,7 +231,8 @@ func TestProvisionerd(t *testing.T) {
230231
JobId: "test",
231232
Provisioner: "someprovisioner",
232233
TemplateSourceArchive: createTar(t, map[string]string{
233-
"test.txt": "content",
234+
"test.txt": "content",
235+
provisionerd.ReadmeFile: "# A cool template 😎",
234236
}),
235237
Type: &proto.AcquiredJob_TemplateImport_{
236238
TemplateImport: &proto.AcquiredJob_TemplateImport{
@@ -240,9 +242,12 @@ func TestProvisionerd(t *testing.T) {
240242
}, nil
241243
},
242244
updateJob: func(ctx context.Context, update *proto.UpdateJobRequest) (*proto.UpdateJobResponse, error) {
243-
if len(update.Logs) != 0 {
245+
if len(update.Logs) > 0 {
244246
didLog.Store(true)
245247
}
248+
if len(update.Readme) > 0 {
249+
didReadme.Store(true)
250+
}
246251
return &proto.UpdateJobResponse{}, nil
247252
},
248253
completeJob: func(ctx context.Context, job *proto.CompletedJob) (*proto.Empty, error) {

0 commit comments

Comments
 (0)