Skip to content

Commit cb6c77d

Browse files
committed
add storage-image command line option and script test
1 parent 826e482 commit cb6c77d

File tree

6 files changed

+60
-3
lines changed

6 files changed

+60
-3
lines changed

cmd/dependabot/internal/cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var (
3131
updaterImage string
3232
proxyImage string
3333
collectorImage string
34+
storageImage string
3435
)
3536

3637
// rootCmd represents the base command when called without any subcommands
@@ -59,4 +60,5 @@ func init() {
5960
rootCmd.PersistentFlags().StringVar(&updaterImage, "updater-image", "", "container image to use for the updater")
6061
rootCmd.PersistentFlags().StringVar(&proxyImage, "proxy-image", infra.ProxyImageName, "container image to use for the proxy")
6162
rootCmd.PersistentFlags().StringVar(&collectorImage, "collector-image", infra.CollectorImageName, "container image to use for the OpenTelemetry collector")
63+
rootCmd.PersistentFlags().StringVar(&storageImage, "storage-image", infra.StorageImageName, "container image to use for the storage service")
6264
}

cmd/dependabot/internal/cmd/test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func NewTestCommand() *cobra.Command {
5050
ProxyCertPath: flags.proxyCertPath,
5151
ProxyImage: proxyImage,
5252
PullImages: flags.pullImages,
53+
StorageImage: storageImage,
5354
Timeout: flags.timeout,
5455
UpdaterImage: updaterImage,
5556
Volumes: flags.volumes,

cmd/dependabot/internal/cmd/update.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func NewUpdateCommand() *cobra.Command {
9696
ProxyCertPath: flags.proxyCertPath,
9797
ProxyImage: proxyImage,
9898
PullImages: flags.pullImages,
99+
StorageImage: storageImage,
99100
Timeout: flags.timeout,
100101
UpdaterImage: updaterImage,
101102
Volumes: flags.volumes,

internal/infra/run.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ type RunParams struct {
6868
CollectorImage string
6969
// CollectorConfigPath is the path to the OpenTelemetry collector configuration file
7070
CollectorConfigPath string
71+
// StorageImage is the image to use for the storage service
72+
StorageImage string
7173
// Writer is where API calls will be written to
7274
Writer io.Writer
7375
InputName string
@@ -369,6 +371,11 @@ func runContainers(ctx context.Context, params RunParams) (err error) {
369371
if err != nil {
370372
return err
371373
}
374+
375+
err = pullImage(ctx, cli, params.StorageImage)
376+
if err != nil {
377+
return err
378+
}
372379
}
373380

374381
networks, err := NewNetworks(ctx, cli)

internal/infra/updater.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const (
4343
caseInsensitiveContainerRoot = "/nocase"
4444
caseInsensitiveRepoContentsPath = "/nocase/repo"
4545

46-
storageImageName = "ghcr.io/dependabot/dependabot-storage"
46+
StorageImageName = "ghcr.io/dependabot/dependabot-storage"
4747
storageUser = "dpduser"
4848
storagePass = "dpdpass"
4949
)
@@ -102,7 +102,7 @@ func NewUpdater(ctx context.Context, cli *client.Client, net *Networks, params *
102102
storageContainerID := ""
103103
storageVolumes := []string{}
104104
if params.Job.UseCaseInsensitiveFileSystem() {
105-
storageContainerID, storageVolumes, err = createStorageVolumes(hostCfg, ctx, cli, net)
105+
storageContainerID, storageVolumes, err = createStorageVolumes(hostCfg, ctx, cli, net, params.StorageImage)
106106
if err != nil {
107107
return nil, fmt.Errorf("failed to create storage volumes: %w", err)
108108
}
@@ -141,7 +141,7 @@ func NewUpdater(ctx context.Context, cli *client.Client, net *Networks, params *
141141
return updater, nil
142142
}
143143

144-
func createStorageVolumes(hostCfg *container.HostConfig, ctx context.Context, cli *client.Client, net *Networks) (storageContainerID string, volumeNames []string, err error) {
144+
func createStorageVolumes(hostCfg *container.HostConfig, ctx context.Context, cli *client.Client, net *Networks, storageImageName string) (storageContainerID string, volumeNames []string, err error) {
145145
log.Printf("Preparing case insensitive filesystem")
146146

147147
// create container hosting the storage

testdata/scripts/smb-mount.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Build the dummy Dockerfile
2+
exec docker build -qt dummy-nocase-updater .
3+
4+
# Run the dependabot command
5+
dependabot update -f job.yml --updater-image dummy-nocase-updater
6+
7+
# assert the dummy is working
8+
stderr 'case-insensitive value is set'
9+
10+
exec docker rmi -f dummy-nocase-updater
11+
12+
-- Dockerfile --
13+
FROM ubuntu:22.04
14+
15+
RUN useradd dependabot
16+
17+
COPY --chown=dependabot --chmod=755 update-ca-certificates /usr/bin/update-ca-certificates
18+
COPY --chown=dependabot --chmod=755 run bin/run
19+
20+
-- update-ca-certificates --
21+
#!/usr/bin/env bash
22+
23+
echo "Updated those certificates for ya"
24+
25+
-- run --
26+
#!/usr/bin/env bash
27+
28+
if [ "$1" = "fetch_files" ]; then
29+
exit 0
30+
fi
31+
32+
if [ "$DEPENDABOT_CASE_INSENSITIVE_REPO_CONTENTS_PATH" != "" ]; then
33+
echo "case-insensitive value is set"
34+
else
35+
echo "case-insensitive value is not set"
36+
fi
37+
38+
-- job.yml --
39+
job:
40+
experiments:
41+
use_case_insensitive_filesystem: true
42+
source:
43+
provider: github
44+
repo: test/repo
45+
directory: /
46+
package-manager: nuget

0 commit comments

Comments
 (0)