Skip to content

Commit 1b83f0b

Browse files
authored
feat: improved error on remote deploy without local source (knative#2885)
1 parent 9c992c9 commit 1b83f0b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cmd/deploy.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,24 @@ func runDeploy(cmd *cobra.Command, newClient ClientFactory) (err error) {
244244
if f, err = fn.NewFunction(cfg.Path); err != nil {
245245
return
246246
}
247-
if !f.Initialized() {
248-
return fn.NewErrNotInitialized(f.Root)
249-
}
250247
if f, err = cfg.Configure(f); err != nil { // Updates f with deploy cfg
251248
return
252249
}
253250
cmd.SetContext(cfg.WithValues(cmd.Context())) // Some optional settings are passed via context
254251

252+
if !f.Initialized() {
253+
if !cfg.Remote || f.Build.Git.URL == "" {
254+
// Only error if this is not a fully remote build
255+
return fn.NewErrNotInitialized(f.Root)
256+
} else {
257+
// TODO: this case is not supported because the pipeline
258+
// implementation requires the function's name, which is in the
259+
// remote repository. We should inspect the remote repository.
260+
// For now, give a more helpful error.
261+
return errors.New("please ensure the function's source is also available locally")
262+
}
263+
}
264+
255265
changingNamespace := func(f fn.Function) bool {
256266
// We're changing namespace if:
257267
return f.Deploy.Namespace != "" && // it's already deployed

0 commit comments

Comments
 (0)