Skip to content

Commit 8eaf281

Browse files
committed
Reduce duplicated code
The getMissingTemplates call was performed within an if/else but was identical so could be moved up one level higher. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent c5f6294 commit 8eaf281

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

commands/publish.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ func runPublish(cmd *cobra.Command, args []string) error {
147147
cwd, _ := os.Getwd()
148148
templatesPath := filepath.Join(cwd, TemplateDirectory)
149149

150-
if len(services.StackConfiguration.TemplateConfigs) > 0 && !disableStackPull {
151-
missingTemplates, err := getMissingTemplates(services.Functions, templatesPath)
152-
if err != nil {
153-
return fmt.Errorf("error accessing existing templates folder: %s", err.Error())
154-
}
150+
missingTemplates, err := getMissingTemplates(services.Functions, templatesPath)
151+
if err != nil {
152+
return fmt.Errorf("error accessing existing templates folder: %s", err.Error())
153+
}
155154

155+
if len(services.StackConfiguration.TemplateConfigs) > 0 && !disableStackPull {
156156
if err := pullStackTemplates(missingTemplates, services.StackConfiguration.TemplateConfigs, cmd); err != nil {
157157
return fmt.Errorf("error pulling templates: %s", err.Error())
158158
}
@@ -163,18 +163,11 @@ func runPublish(cmd *cobra.Command, args []string) error {
163163
// When the configuration.templates section is empty, it's only possible to pull from the store
164164
// this store can be overridden by a flag or environment variable
165165

166-
missingTemplates, err := getMissingTemplates(services.Functions, templatesPath)
167-
if err != nil {
168-
return fmt.Errorf("error accessing existing templates folder: %s", err.Error())
169-
}
170-
171166
for _, missingTemplate := range missingTemplates {
172-
173167
if err := runTemplateStorePull(cmd, []string{missingTemplate}); err != nil {
174168
return fmt.Errorf("error pulling template: %s", err.Error())
175169
}
176170
}
177-
178171
}
179172

180173
if resetQemu {

versioncontrol/parse.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ func ParsePinnedRemote(repoURL string) (remoteURL, refName string) {
5252

5353
atIndex := strings.LastIndex(repoURL, pinCharacter)
5454
if atIndex > 0 {
55-
5655
remoteURL, refName, _ = strings.Cut(repoURL, pinCharacter)
57-
58-
// refName = repoURL[atIndex+len(pinCharacter):]
59-
// remoteURL = repoURL[:atIndex]
6056
}
6157

6258
if !IsGitRemote(remoteURL) {

0 commit comments

Comments
 (0)