-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make additional announcable cidrs configurable per tenant super network
- Loading branch information
Showing
11 changed files
with
256 additions
and
110 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
cmd/metal-api/internal/datastore/migrations/06_additional_announcable_cidrs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package migrations | ||
|
||
import ( | ||
r "gopkg.in/rethinkdb/rethinkdb-go.v6" | ||
|
||
"github.com/metal-stack/metal-api/cmd/metal-api/internal/datastore" | ||
) | ||
|
||
func init() { | ||
datastore.MustRegisterMigration(datastore.Migration{ | ||
Name: "migrate super tenant networks to contain additionannouncablecidrs", | ||
Version: 6, | ||
Up: func(db *r.Term, session r.QueryExecutor, rs *datastore.RethinkStore) error { | ||
nws, err := rs.ListNetworks() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, old := range nws { | ||
if !old.PrivateSuper { | ||
continue | ||
} | ||
new := old | ||
|
||
if len(old.AdditionalAnnouncableCIDRs) == 0 { | ||
new.AdditionalAnnouncableCIDRs = []string{ | ||
// This was the previous hard coded default in metal-core | ||
"10.240.0.0/12", | ||
} | ||
} | ||
|
||
err = rs.UpdateNetwork(&old, &new) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.