@@ -120,32 +120,23 @@ def _get_or_create_config(self):
120120 """
121121 dryccfile to config
122122 """
123- config_values , config_values_ref , changed_fields , replace_groups = [], {}, set (), set ()
123+ if not self .dryccfile :
124+ return self .app .release_set .filter (failed = False ).latest ().config
125+ # create config from dryccfile
126+ values , values_ref = [], {}
124127 for group , envs in self .dryccfile .get ('config' , {}).items ():
125128 for key , value in envs .items ():
126- replace_groups .add (group )
127- config_values .append ({"name" : key , "group" : group , "value" : value })
128- changed_fields .update (["values" , "values_refs" ])
129-
130- replace_ptypes = set ()
129+ values .append ({"name" : key , "group" : group , "value" : value })
131130 for pipeline in self .dryccfile .get ('pipeline' , {}).values ():
132131 if 'env' in pipeline or 'config' in pipeline :
133132 for key , value in pipeline .get ('env' , {}).items ():
134- config_values .append ({"name" : key , "ptype" : pipeline ['ptype' ], "value" : value })
133+ values .append ({"name" : key , "ptype" : pipeline ['ptype' ], "value" : value })
135134 for config_ref in pipeline .get ('config' , []):
136- if pipeline ['ptype' ] not in config_values_ref :
137- config_values_ref [pipeline ['ptype' ]] = [config_ref ]
135+ if pipeline ['ptype' ] not in values_ref :
136+ values_ref [pipeline ['ptype' ]] = [config_ref ]
138137 else :
139- config_values_ref [pipeline ['ptype' ]].append (config_ref )
140- replace_ptypes .add (pipeline ['ptype' ])
141- changed_fields .update (["values" , "values_refs" ])
142-
143- old_config = self .app .release_set .filter (failed = False ).latest ().config
144- if not changed_fields :
145- return old_config
138+ values_ref [pipeline ['ptype' ]].append (config_ref )
146139 config = Config (
147- owner = self .owner , app = self .app , values = config_values , values_refs = config_values_ref )
148- config .merge_field ("values" , old_config , replace_ptypes , replace_groups )
149- config .merge_field ("values_refs" , old_config , replace_ptypes )
150- config .save (ignore_update_fields = changed_fields )
140+ owner = self .owner , app = self .app , values = values , values_refs = values_ref )
141+ config .save (ignore_update_fields = ["values" , "values_refs" ])
151142 return config
0 commit comments