Skip to content

Commit 3dc2572

Browse files
Replace --images.pull by --images.no-pull
This avoid exposing people to the unexpected special treatment of boolean flags that prevent you from doing e.g `-p false`.
1 parent 7d84772 commit 3dc2572

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

pkg/diambra/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ type EnvConfig struct {
7575

7676
AppArgs AppArgs
7777

78-
Scale int
79-
AutoRemove bool
80-
AgentImage string
81-
PullImage bool
78+
Scale int
79+
AutoRemove bool
80+
AgentImage string
81+
NoPullImage bool
8282

8383
RomsPath string
8484
CredPath string
@@ -149,7 +149,7 @@ func (c *EnvConfig) AddFlags(flags *pflag.FlagSet) {
149149

150150
// Flags that apply to both agent and env
151151
flags.BoolVarP(&c.Interactive, "interactive", "i", true, "Open stdin for interactions with arena and agent")
152-
flags.BoolVarP(&c.PullImage, "images.pull", "p", true, "(Always) pull image before running")
152+
flags.BoolVarP(&c.NoPullImage, "images.no-pull", "n", false, "Do not try to pull image before running")
153153

154154
// Flags to configure env container
155155
flags.IntVarP(&c.Scale, "env.scale", "s", 1, "Number of environments to run")
@@ -164,7 +164,7 @@ func (c *EnvConfig) AddFlags(flags *pflag.FlagSet) {
164164
// Flags to configure engine in env container
165165
flags.BoolVarP(&c.AppArgs.Render, "engine.render", "g", false, "Render graphics server side")
166166
flags.BoolVarP(&c.AppArgs.LockFPS, "engine.lockfps", "l", false, "Lock FPS")
167-
flags.BoolVarP(&c.AppArgs.Sound, "engine.sound", "n", false, "Enable sound")
167+
flags.BoolVar(&c.AppArgs.Sound, "engine.sound", false, "Enable sound")
168168

169169
// Agent flags
170170
flags.StringVarP(&c.AgentImage, "agent.image", "a", "", "Run given agent command in container")

pkg/diambra/diambra.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (d *Diambra) start(envId int, first bool) error {
139139
return fmt.Errorf("couldn't create env container: %w", err)
140140
}
141141

142-
if first && d.config.PullImage {
142+
if first && !d.config.NoPullImage {
143143
if err := d.Runner.Pull(ec, d.config.Output); err != nil {
144144
return err
145145
}
@@ -308,7 +308,7 @@ func (e *Diambra) RunAgentImage(image string, args []string) error {
308308
}
309309

310310
func (e *Diambra) RunAgentContainer(c *container.Container) (int, error) {
311-
if e.config.PullImage {
311+
if !e.config.NoPullImage {
312312
if err := e.Runner.Pull(c, e.config.Output); err != nil {
313313
return 1, err
314314
}

pkg/diambra/diambra_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestDiambra(t *testing.T) {
6969
Scale: 1,
7070
AutoRemove: false,
7171
AgentImage: "",
72-
PullImage: false,
72+
NoPullImage: false,
7373
RomsPath: os.TempDir(),
7474
CredPath: filepath.Join(os.TempDir(), "credfile"),
7575
Image: "",

0 commit comments

Comments
 (0)