Skip to content

Commit 630a849

Browse files
authored
gen-config: remove validations at the config generation stage (#479)
Remove the cache validations in the DYM config generation. At that stage, we should assume files already exist, as they have already been fetched by the `run` command. Removing the validation allows users to call `boe gen-config --extension example-go` (and other composer extensions) when the cache is empty because they never ran before and the composer extension is not there. Signed-off-by: Ignasi Barrera <ignasi@tetrate.io>
1 parent 1b6e10a commit 630a849

2 files changed

Lines changed: 0 additions & 29 deletions

File tree

cli/internal/envoy/extension.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,21 +262,12 @@ func (d DynamicModuleFilterGenerator) GenerateFilterConfig(manifest *extensions.
262262
func (c ComposerFilterGenerator) GenerateFilterConfig(manifest *extensions.Manifest, dirs *xdg.Directories, config string) (*ExtensionResources, error) {
263263
c.Logger.Info("generating composer filter config for extension", "name", manifest.Name, "config", config)
264264

265-
cachedComposerPath := extensions.LocalCacheComposerLib(dirs, manifest.ComposerVersion)
266-
if _, err := os.Stat(cachedComposerPath); os.IsNotExist(err) {
267-
// TODO(wbpcode): Download the composer binary from the URL specified in the manifest.
268-
return nil, fmt.Errorf("composer binary not found at %s", cachedComposerPath)
269-
}
270-
271265
var pluginURL string
272266
if manifest.Remote && manifest.SourceRegistry != "" {
273267
// For remote extensions, use oci:// URL so config is portable.
274268
pluginURL = "oci://" + extensions.RepositoryName(manifest.SourceRegistry, manifest.Name) + ":" + manifest.SourceTag
275269
} else {
276270
cachedPluginPath := extensions.LocalCacheExtension(dirs, manifest)
277-
if _, err := os.Stat(cachedPluginPath); os.IsNotExist(err) {
278-
return nil, fmt.Errorf("go plugin binary not found at %s", cachedPluginPath)
279-
}
280271
pluginURL = "file://" + cachedPluginPath
281272
}
282273

cli/internal/envoy/extension_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package envoy
77

88
import (
99
"fmt"
10-
"os"
1110
"path/filepath"
1211
"testing"
1312
"time"
@@ -468,25 +467,6 @@ func TestComposerFilterGenerator(t *testing.T) {
468467
Remote: true,
469468
}
470469

471-
// Case 1: Composer binary missing
472-
_, err := GenerateFilterConfig(logger, manifest, dirs, "")
473-
require.ErrorContains(t, err, "composer binary not found")
474-
475-
// Create Composer binary
476-
composerPath := extensions.LocalCacheComposerDir(dirs, manifest.ComposerVersion)
477-
require.NoError(t, os.MkdirAll(composerPath, 0o750))
478-
require.NoError(t, os.WriteFile(filepath.Join(composerPath, "libcomposer.so"), []byte("fake binary"), 0o600))
479-
480-
// Case 2: Plugin binary missing
481-
_, err = GenerateFilterConfig(logger, manifest, dirs, "")
482-
require.ErrorContains(t, err, "go plugin binary not found")
483-
484-
// Create Plugin binary
485-
pluginPath := filepath.Join(dirs.DataHome, "extensions", "goplugin", manifest.Name, manifest.Version)
486-
require.NoError(t, os.MkdirAll(pluginPath, 0o750))
487-
require.NoError(t, os.WriteFile(filepath.Join(pluginPath, "plugin.so"), []byte("fake binary"), 0o600))
488-
489-
// Case 3: Success without config
490470
got, err := GenerateFilterConfig(logger, manifest, dirs, "")
491471
require.NoError(t, err)
492472

0 commit comments

Comments
 (0)