Skip to content

Commit ca31f73

Browse files
authored
fix: setup global config in init docker command (#1800)
Fixes #1795
1 parent 96b73c5 commit ca31f73

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

internal/librarian/release_init.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,12 @@ func (r *initRunner) runInitCommand(ctx context.Context, outputDir string) error
120120
}
121121

122122
initRequest := &docker.ReleaseInitRequest{
123-
Cfg: r.cfg,
124-
State: r.state,
125-
LibraryID: r.cfg.Library,
126-
LibraryVersion: r.cfg.LibraryVersion,
127-
Output: outputDir,
123+
Cfg: r.cfg,
124+
State: r.state,
125+
LibrarianConfig: r.librarianConfig,
126+
LibraryID: r.cfg.Library,
127+
LibraryVersion: r.cfg.LibraryVersion,
128+
Output: outputDir,
128129
}
129130

130131
if err := r.containerClient.ReleaseInit(ctx, initRequest); err != nil {
@@ -220,6 +221,10 @@ func getChangeType(commit *conventionalcommits.ConventionalCommit) string {
220221
// cleanAndCopyGlobalAllowlist cleans the files listed in global allowlist in
221222
// repoDir, excluding read-only files and copies global files from outputDir.
222223
func cleanAndCopyGlobalAllowlist(cfg *config.LibrarianConfig, repoDir, outputDir string) error {
224+
if cfg == nil {
225+
slog.Info("librarian config is not setup, skip copying global allowlist")
226+
return nil
227+
}
223228
for _, globalFile := range cfg.GlobalFilesAllowlist {
224229
if globalFile.Permissions == config.PermissionReadOnly {
225230
continue

internal/librarian/release_init_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,42 @@ func TestInitRun(t *testing.T) {
123123
"dir2/file3.txt": "",
124124
},
125125
},
126+
{
127+
name: "run release init command without librarian config",
128+
runner: &initRunner{
129+
workRoot: filepath.Join(t.TempDir(), "work-root"),
130+
containerClient: &mockContainerClient{},
131+
cfg: &config.Config{
132+
Library: "example-id",
133+
},
134+
state: &config.LibrarianState{
135+
Libraries: []*config.LibraryState{
136+
{
137+
ID: "another-example-id",
138+
SourceRoots: []string{
139+
"dir3",
140+
"dir4",
141+
},
142+
},
143+
{
144+
ID: "example-id",
145+
SourceRoots: []string{
146+
"dir1",
147+
"dir2",
148+
},
149+
},
150+
},
151+
},
152+
repo: &MockRepository{
153+
Dir: filepath.Join(t.TempDir(), "repo"),
154+
},
155+
},
156+
files: map[string]string{
157+
"file1.txt": "",
158+
"dir1/file2.txt": "",
159+
"dir2/file3.txt": "",
160+
},
161+
},
126162
{
127163
name: "run release init command for all libraries",
128164
runner: &initRunner{

0 commit comments

Comments
 (0)