Skip to content

Commit

Permalink
fix: rename api query (#305) (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-codefresh authored Apr 10, 2024
1 parent e25125e commit dcc1723
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions changelog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Features
- fix: rename API query according to Codefresh API update
12 changes: 6 additions & 6 deletions pkg/codefresh/api_graphql_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ type CodefreshGraphQLRequests struct {
}

type CodefreshGraphQLInterface interface {
GetApplicationConfiguration(app *metav1.ObjectMeta) (*ApplicationConfiguration, error)
GetPromotionTemplate(app *metav1.ObjectMeta) (*PromotionTemplate, error)
}

// GetApplicationConfiguration method to get application configuration
func (r *CodefreshGraphQLRequests) GetApplicationConfiguration(app *metav1.ObjectMeta) (*ApplicationConfiguration, error) {
// GetPromotionTemplate method to get application configuration
func (r *CodefreshGraphQLRequests) GetPromotionTemplate(app *metav1.ObjectMeta) (*PromotionTemplate, error) {
type ResponseData struct {
ApplicationConfigurationByRuntime ApplicationConfiguration `json:"applicationConfigurationByRuntime"`
PromotionTemplateByRuntime PromotionTemplate `json:"promotionTemplateByRuntime"`
}

query := GraphQLQuery{
Query: `
query ($applicationMetadata: Object!) {
applicationConfigurationByRuntime(applicationMetadata: $applicationMetadata) {
promotionTemplateByRuntime(applicationMetadata: $applicationMetadata) {
versionSource {
file
jsonPath
Expand All @@ -46,7 +46,7 @@ func (r *CodefreshGraphQLRequests) GetApplicationConfiguration(app *metav1.Objec
return nil, err
}

return &responseData.ApplicationConfigurationByRuntime, nil
return &responseData.PromotionTemplateByRuntime, nil
}

func NewCodefreshGraphQLRequests(client CodefreshClientInterface) CodefreshGraphQLInterface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/codefresh/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ type VersionSource struct {
JsonPath string `json:"jsonPath"`
}

type ApplicationConfiguration struct {
type PromotionTemplate struct {
VersionSource VersionSource `json:"versionSource"`
}
4 changes: 2 additions & 2 deletions pkg/version_config_manager/version_config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type VersionConfig struct {
}

func (v *VersionConfigManager) GetVersionConfig(app *metav1.ObjectMeta) (*VersionConfig, error) {
var appConfig *codefresh.ApplicationConfiguration
var appConfig *codefresh.PromotionTemplate

// Get from cache
appConfig, err := v.cache.GetCfAppConfig(app.Namespace, app.Name)
Expand All @@ -31,7 +31,7 @@ func (v *VersionConfigManager) GetVersionConfig(app *metav1.ObjectMeta) (*Versio
}

// Get from Codefresh API
appConfig, err = v.requests.GetApplicationConfiguration(app)
appConfig, err = v.requests.GetPromotionTemplate(app)
if err != nil {
log.Infof("Failed to get application config from API: %v", err)
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions reposerver/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,12 @@ func CfAppConfigCacheKey(namespace, name string) string {
return fmt.Sprintf("cf_app_config:%s:%s", namespace, name)
}

func (c *Cache) GetCfAppConfig(namespace, name string) (*codefresh.ApplicationConfiguration, error) {
item := &codefresh.ApplicationConfiguration{}
func (c *Cache) GetCfAppConfig(namespace, name string) (*codefresh.PromotionTemplate, error) {
item := &codefresh.PromotionTemplate{}
return item, c.cache.GetItem(CfAppConfigCacheKey(namespace, name), item)
}

func (c *Cache) SetCfAppConfig(namespace, name string, item *codefresh.ApplicationConfiguration) error {
func (c *Cache) SetCfAppConfig(namespace, name string, item *codefresh.PromotionTemplate) error {
return c.cache.SetItem(CfAppConfigCacheKey(namespace, name), item, c.cfAppConfigCacheExpiration, false)
}

Expand Down

0 comments on commit dcc1723

Please sign in to comment.