generated from crossplane/provider-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sss add zone deployment strategies for AUTO, zone_1 zone_2 zone_3
- Loading branch information
1 parent
1d20bd4
commit 06b85c5
Showing
11 changed files
with
118 additions
and
32 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package serverset | ||
|
||
import "fmt" | ||
|
||
// ZoneDeploymentOptions is used to pass the zone and index to the ZoneStrategy | ||
type ZoneDeploymentOptions struct { | ||
// Zone needed for whateverIsSet | ||
Zone string | ||
// Index is needed for eachServerInAZone | ||
Index int | ||
} | ||
|
||
// ZoneStrategy is an interface that returns the zone for a server based on the ZoneDeploymentOptions | ||
type ZoneStrategy interface { | ||
GetZone(ZoneDeploymentOptions) string | ||
} | ||
|
||
// eachServerInAZone is a ZoneStrategy that returns ZONE_2 for odd and ZONE_1 for even index | ||
type eachServerInAZone struct { | ||
} | ||
|
||
// GetZone returns ZONE_2 for odd and ZONE_1 for even index | ||
func (e eachServerInAZone) GetZone(so ZoneDeploymentOptions) string { | ||
return fmt.Sprintf("ZONE_%d", so.Index%2+1) | ||
} | ||
|
||
// whateverIsSet is a ZoneStrategy that returns the zone set in the ZoneDeploymentOptions | ||
type whateverIsSet struct { | ||
} | ||
|
||
// GetZone returns the zone set in the ZoneDeploymentOptions | ||
func (w whateverIsSet) GetZone(so ZoneDeploymentOptions) string { | ||
return so.Zone | ||
} | ||
|
||
// NewZoneDeploymentByType returns a ZoneStrategy based on the zone string | ||
func NewZoneDeploymentByType(zone string) ZoneStrategy { | ||
if zone == "" || zone == "ZONES" { | ||
return eachServerInAZone{} | ||
} | ||
return whateverIsSet{} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,6 +381,10 @@ spec: | |
type: | ||
enum: | ||
- ZONES | ||
- AUTO | ||
- ZONE_1 | ||
- ZONE_2 | ||
- ZONE_3 | ||
type: string | ||
required: | ||
- type | ||
|