Skip to content

Commit

Permalink
Merge pull request #472 from DopplerHQ/andre/inheritance-2
Browse files Browse the repository at this point in the history
chore: Rename ProjectSlug/ConfigName to Project/Config in descriptor model
  • Loading branch information
apazzolini authored Dec 10, 2024
2 parents d67deaf + 3fbeb97 commit fa039ff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,9 +1093,9 @@ func UpdateConfigInherits(host string, verifyTLS bool, apiKey string, project st
for _, cd := range configDescriptors {
parts := strings.Split(cd, ".")
if len(parts) != 2 {
return models.ConfigInfo{}, Error{Message: "Config descriptors must match the format \"projectSlug.configName\""}
return models.ConfigInfo{}, Error{Message: "Config descriptors must match the format \"project.config\""}
}
inheritsObj = append(inheritsObj, models.ConfigDescriptor{ProjectSlug: parts[0], ConfigName: parts[1]})
inheritsObj = append(inheritsObj, models.ConfigDescriptor{Project: parts[0], Config: parts[1]})
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/models/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ type WatchSecrets struct {
}

type ConfigDescriptor struct {
ProjectSlug string `json:"projectSlug"`
ConfigName string `json:"configName"`
Project string `json:"project"`
Config string `json:"config"`
}
4 changes: 2 additions & 2 deletions pkg/models/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ func ParseConfigInfo(info map[string]interface{}) ConfigInfo {
inherits := info["inherits"].([]interface{})
for _, i := range inherits {
descriptorMap := i.(map[string]interface{})
configInfo.Inherits = append(configInfo.Inherits, ConfigDescriptor{ProjectSlug: descriptorMap["projectSlug"].(string), ConfigName: descriptorMap["configName"].(string)})
configInfo.Inherits = append(configInfo.Inherits, ConfigDescriptor{Project: descriptorMap["project"].(string), Config: descriptorMap["config"].(string)})
}
}
if info["inheritedBy"] != nil {
configInfo.InheritedBy = []ConfigDescriptor{}
inheritedBy := info["inheritedBy"].([]interface{})
for _, i := range inheritedBy {
descriptorMap := i.(map[string]interface{})
configInfo.InheritedBy = append(configInfo.InheritedBy, ConfigDescriptor{ProjectSlug: descriptorMap["projectSlug"].(string), ConfigName: descriptorMap["configName"].(string)})
configInfo.InheritedBy = append(configInfo.InheritedBy, ConfigDescriptor{Project: descriptorMap["project"].(string), Config: descriptorMap["config"].(string)})
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/printer/enclave.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ func ConfigInfo(info models.ConfigInfo, jsonFlag bool) {
if info.Inheritable {
inheritsHeader = "inherited by"
for _, inheritedBy := range info.InheritedBy {
inheritsStrings = append(inheritsStrings, fmt.Sprintf("%s.%s", inheritedBy.ProjectSlug, inheritedBy.ConfigName))
inheritsStrings = append(inheritsStrings, fmt.Sprintf("%s.%s", inheritedBy.Project, inheritedBy.Config))
}
} else {
inheritsHeader = "inherits"
for _, inherits := range info.Inherits {
inheritsStrings = append(inheritsStrings, fmt.Sprintf("%s.%s", inherits.ProjectSlug, inherits.ConfigName))
inheritsStrings = append(inheritsStrings, fmt.Sprintf("%s.%s", inherits.Project, inherits.Config))
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ func ConfigsInfo(info []models.ConfigInfo, jsonFlag bool) {
for _, configInfo := range info {
var inheritsStrings []string
for _, inherits := range configInfo.Inherits {
inheritsStrings = append(inheritsStrings, fmt.Sprintf("%s.%s", inherits.ProjectSlug, inherits.ConfigName))
inheritsStrings = append(inheritsStrings, fmt.Sprintf("%s.%s", inherits.Project, inherits.Config))
}

var inheritsString string
Expand Down

0 comments on commit fa039ff

Please sign in to comment.