Skip to content

Commit ad366ec

Browse files
authored
fix: do not rpmspec analyze specs by default in package builds (#390)
Aligns the local-spec case with what we're presently doing with the upstream-spec case.
1 parent 6d5a156 commit ad366ec

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

internal/providers/sourceproviders/localcontentsprovider.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ import (
1919
)
2020

2121
// FetchLocalComponent retrieves the `.spec` file and any sidecar files for the specified component
22-
// from the local filesystem, placing the fetched files in the provided directory.
22+
// from the local filesystem, placing the fetched files in the provided directory. If
23+
// dynamicallyResolveRequiredFiles is true, any files referenced by the spec's *contents* but
24+
// that are not located alongside the spec will also be resolved and copied to the destination.
2325
func FetchLocalComponent(
2426
dryRunnable opctx.DryRunnable, eventListener opctx.EventListener,
2527
fs opctx.FS, component components.Component, destDirPath string,
28+
dynamicallyResolveRequiredFiles bool,
2629
) error {
2730
if dryRunnable == nil {
2831
return errors.New("dry runnable cannot be nil")
@@ -61,10 +64,12 @@ func FetchLocalComponent(
6164
}
6265

6366
// Resolve and copy any required files that may be stored separately
64-
err = copyRequiredFiles(dryRunnable, fs, eventListener, component, sourceDirPath, destDirPath)
65-
if err != nil {
66-
return fmt.Errorf("failed to copy required files for component %#q:\n%w",
67-
component.GetName(), err)
67+
if dynamicallyResolveRequiredFiles {
68+
err = copyRequiredFiles(dryRunnable, fs, eventListener, component, sourceDirPath, destDirPath)
69+
if err != nil {
70+
return fmt.Errorf("failed to copy required files for component %#q:\n%w",
71+
component.GetName(), err)
72+
}
6873
}
6974

7075
return nil

internal/providers/sourceproviders/localcontentsprovider_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func TestFetchLocalComponent_NoRequiredFiles(t *testing.T) {
111111
testParams.env.EventListener,
112112
testParams.env.FS(),
113113
testParams.component, testOutputDir,
114+
true,
114115
)
115116
require.NoError(t, err)
116117

@@ -145,6 +146,7 @@ func TestFetchLocalComponent_RequiredFileMissing(t *testing.T) {
145146
testParams.env.FS(),
146147
testParams.component,
147148
testOutputDir,
149+
true,
148150
)
149151
require.Error(t, err)
150152
require.Contains(t, err.Error(), "required-file.txt")
@@ -170,6 +172,7 @@ func TestFetchLocalComponent_RequiredFilePresent(t *testing.T) {
170172
testParams.env.FS(),
171173
testParams.component,
172174
testOutputDir,
175+
true,
173176
)
174177
require.NoError(t, err)
175178

@@ -204,6 +207,7 @@ func TestFetchLocalComponent_MissingSpec(t *testing.T) {
204207
testParams.env.FS(),
205208
testParams.component,
206209
testOutputDir,
210+
true,
207211
)
208212
require.Error(t, err)
209213
}

internal/providers/sourceproviders/sourcemanager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ func (m *sourceManager) FetchComponent(ctx context.Context, component components
168168

169169
// Handle local components
170170
if sourceType == projectconfig.SpecSourceTypeLocal {
171-
err := FetchLocalComponent(m.dryRunnable, m.eventListener, m.fs, component, destDirPath)
171+
// NOTE: For now we are *not* dynamically resolving required files by parsing the spec.
172+
err := FetchLocalComponent(m.dryRunnable, m.eventListener, m.fs, component, destDirPath, false)
172173
if err != nil {
173174
return fmt.Errorf("failed to fetch local component %#q:\n%w",
174175
component.GetName(), err)

0 commit comments

Comments
 (0)