|
7 | 7 | "errors" |
8 | 8 | "fmt" |
9 | 9 | "net/http" |
10 | | - "reflect" |
11 | 10 | "regexp" |
12 | | - "sort" |
13 | 11 | "strconv" |
14 | 12 | "strings" |
15 | 13 | "text/template" |
@@ -165,7 +163,15 @@ func (c *ServiceClient) getRevisionsIfUpdating(serviceBody *ServiceBody) ([]*man |
165 | 163 |
|
166 | 164 | // checkAndUpdateExistingRevision checks if a revision with the same hash exists and updates tags if needed |
167 | 165 | func (c *ServiceClient) checkAndUpdateExistingRevision(serviceBody *ServiceBody, apiServiceRevisions []*management.APIServiceRevision) (bool, error) { |
| 166 | + // attempt to use the stripped spec hash |
168 | 167 | revName, found := serviceBody.specHashes[serviceBody.specHash] |
| 168 | + if !found && serviceBody.originalSpecHash != "" { |
| 169 | + // check if the original spec hash matches an existing revision, |
| 170 | + // this is to cover the case where the spec content has not changed since the last publish, |
| 171 | + // but the hash has changed due to non-content related changes (e.g. stripping servers) |
| 172 | + revName, found = serviceBody.specHashes[serviceBody.originalSpecHash] |
| 173 | + } |
| 174 | + |
169 | 175 | if !found { |
170 | 176 | return false, nil |
171 | 177 | } |
@@ -205,19 +211,15 @@ func (c *ServiceClient) checkAndUpdateExistingRevision(serviceBody *ServiceBody, |
205 | 211 | // different, return the updated tags |
206 | 212 | func (c *ServiceClient) getUpdatedTagKeys(serviceBodyTags map[string]interface{}, revisionTags []string) []string { |
207 | 213 | // Extract values from map and convert to []string |
208 | | - var mapValues []string |
| 214 | + mapValues := []string{} |
209 | 215 | for _, v := range serviceBodyTags { |
210 | 216 | if strVal, ok := v.(string); ok { |
211 | 217 | mapValues = append(mapValues, strVal) |
212 | 218 | } |
213 | 219 | } |
214 | 220 |
|
215 | | - // Sort both slices to allow unordered comparison |
216 | | - sort.Strings(mapValues) |
217 | | - sort.Strings(revisionTags) |
218 | | - |
219 | 221 | // Compare |
220 | | - if reflect.DeepEqual(mapValues, revisionTags) { |
| 222 | + if util.StringSlicesEqualUnordered(mapValues, revisionTags) { |
221 | 223 | return []string{} // return empty string slice if equal |
222 | 224 | } |
223 | 225 |
|
|
0 commit comments