File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
cmd/metal-api/internal/datastore/migrations Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ package migrations
2
+
3
+ import (
4
+ r "gopkg.in/rethinkdb/rethinkdb-go.v6"
5
+
6
+ "github.com/metal-stack/metal-api/cmd/metal-api/internal/datastore"
7
+ )
8
+
9
+ func init () {
10
+ datastore .MustRegisterMigration (datastore.Migration {
11
+ Name : "set allocation succeeded to true for allocated machines (#210)" ,
12
+ Version : 3 ,
13
+ Up : func (db * r.Term , session r.QueryExecutor , rs * datastore.RethinkStore ) error {
14
+ ms , err := rs .ListMachines ()
15
+ if err != nil {
16
+ return err
17
+ }
18
+
19
+ for i := range ms {
20
+ old := ms [i ]
21
+ if old .Allocation == nil || old .Allocation .ConsolePassword == "" {
22
+ // these machines have never succeeded finalize-allocation
23
+ continue
24
+ }
25
+
26
+ n := old
27
+ n .Allocation .Succeeded = true
28
+ err = rs .UpdateMachine (& old , & n )
29
+ if err != nil {
30
+ return err
31
+ }
32
+ }
33
+ return nil
34
+ },
35
+ })
36
+ }
You can’t perform that action at this time.
0 commit comments