-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APIGOV-22850 - one api service instance per stage (#486)
* APIGOV-22850 - only keep latest instance per stage * APIGOV-22850 - handle migration to remove all but latest instance * APIGOV-22850 - get previous revsion instance when updating * APIGOV-22850 - add migration config settings * APIGOV-22850 - rename component in logger * APIGOV-22850 - fix test * APIGOV-22850 - use mutex for test * APIGOV-22850 - test config property * APIGOV-22850 - fix lint * APIGOV-22850 - test apisi migration module * APIGOV-22850 - fix data race in test * APIGOV-22850 - use proper url for updates to instance * APIGOV-22850 - use CreateOrUpdate method * APIGOV-22850 - set migration flags as complete on new services * APIGOV-22850 - fix test
- Loading branch information
1 parent
5ed2279
commit 683c7ed
Showing
22 changed files
with
652 additions
and
127 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
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
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,24 @@ | ||
package apic | ||
|
||
import ( | ||
"fmt" | ||
|
||
v1 "github.com/Axway/agent-sdk/pkg/apic/apiserver/models/api/v1" | ||
"github.com/Axway/agent-sdk/pkg/apic/definitions" | ||
"github.com/Axway/agent-sdk/pkg/util" | ||
) | ||
|
||
func addSpecHashToResource(h v1.Interface) error { | ||
ri, err := h.AsInstance() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
hashInt, err := util.ComputeHash(ri.Spec) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
util.SetAgentDetailsKey(h, definitions.AttrSpecHash, fmt.Sprintf("%v", hashInt)) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package config | ||
|
||
import "github.com/Axway/agent-sdk/pkg/cmd/properties" | ||
|
||
// MigrationConfig - Interface for migration settings config | ||
type MigrationConfig interface { | ||
ShouldCleanInstances() bool | ||
validate() | ||
} | ||
|
||
// MigrationSettings - | ||
type MigrationSettings struct { | ||
CleanInstances bool | ||
} | ||
|
||
func newMigrationConfig() MigrationConfig { | ||
return &MigrationSettings{ | ||
CleanInstances: false, | ||
} | ||
} | ||
|
||
func newTestMigrationConfig() MigrationConfig { | ||
return &MigrationSettings{ | ||
CleanInstances: true, | ||
} | ||
} | ||
|
||
func (m *MigrationSettings) validate() { | ||
} | ||
|
||
// ShouldCleanInstances - returns the value fo CleanInstances | ||
func (m *MigrationSettings) ShouldCleanInstances() bool { | ||
return m.CleanInstances | ||
} | ||
|
||
const ( | ||
pathCleanInstances = "central.migration.cleanInstances" | ||
) | ||
|
||
// AddMigrationConfigProperties - Adds the command properties needed for Migration Config | ||
func AddMigrationConfigProperties(props properties.Properties) { | ||
props.AddBoolProperty(pathCleanInstances, false, "Set this to clean all but latest instance, per stage, within an API Service") | ||
} | ||
|
||
// ParseMigrationConfig - Parses the Migration Config values from the command line | ||
func ParseMigrationConfig(props properties.Properties) MigrationConfig { | ||
migrationConfig := newMigrationConfig() | ||
migrationSettings := migrationConfig.(*MigrationSettings) | ||
|
||
migrationSettings.CleanInstances = props.BoolPropertyValue(pathCleanInstances) | ||
|
||
return migrationSettings | ||
} |
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,13 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMigrationConfig(t *testing.T) { | ||
defConf := newMigrationConfig() | ||
|
||
assert.False(t, defConf.ShouldCleanInstances()) | ||
} |
Oops, something went wrong.