File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 6
6
"net/http"
7
7
8
8
"github.com/go-chi/chi"
9
- "github.com/imdario/mergo"
10
9
"github.com/netlify/git-gateway/conf"
11
10
"github.com/netlify/git-gateway/models"
12
11
"github.com/pborman/uuid"
@@ -93,9 +92,7 @@ func (a *API) UpdateInstance(w http.ResponseWriter, r *http.Request) error {
93
92
}
94
93
95
94
if params .BaseConfig != nil {
96
- if err := mergo .MergeWithOverwrite (i .BaseConfig , params .BaseConfig ); err != nil {
97
- return internalServerError ("Error merging instance configurations" ).WithInternalError (err )
98
- }
95
+ i .BaseConfig = mergeConfig (i .BaseConfig , params .BaseConfig )
99
96
}
100
97
101
98
if err := a .db .UpdateInstance (i ); err != nil {
@@ -115,3 +112,20 @@ func (a *API) DeleteInstance(w http.ResponseWriter, r *http.Request) error {
115
112
w .WriteHeader (http .StatusNoContent )
116
113
return nil
117
114
}
115
+
116
+ func mergeConfig (baseConfig * conf.Configuration , newConfig * conf.Configuration ) * conf.Configuration {
117
+ if newConfig .GitHub .AccessToken != "" {
118
+ baseConfig .GitHub .AccessToken = newConfig .GitHub .AccessToken
119
+ }
120
+
121
+ if newConfig .GitHub .Endpoint != "" {
122
+ baseConfig .GitHub .Endpoint = newConfig .GitHub .Endpoint
123
+ }
124
+
125
+ if newConfig .GitHub .Repo != "" {
126
+ baseConfig .GitHub .Repo = newConfig .GitHub .Repo
127
+ }
128
+
129
+ baseConfig .Roles = newConfig .Roles
130
+ return baseConfig
131
+ }
You can’t perform that action at this time.
0 commit comments