Skip to content

Commit

Permalink
quick fix
Browse files Browse the repository at this point in the history
Signed-off-by: David Fridrich <fridrich.david19@gmail.com>
  • Loading branch information
gauron99 committed Aug 27, 2024
1 parent eba5c03 commit d095a39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 35 deletions.
26 changes: 0 additions & 26 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,29 +868,3 @@ func isDigested(v string) (validDigest bool, err error) {
validDigest = true
return
}

// processImageName processes the image name for deployment. It ensures that
// image string is validated if --image was given and ensures that proper
// fields of Function structure are populated if needed.
// Returns a Function structure(1), bool indicating if image was given with
// digest(2) and error(3)
func processImageName(f fn.Function, configImage string) (fn.Function, bool, error) {
var (
digested bool
err error
)

// check if --image was provided with a digest. 'digested' bool indicates if
// image contains a digest or not (image is "digested").
digested, err = isDigested(configImage)
// image is digested, no need to process further || error occurred
if digested || err != nil {
return f, digested, err
}

// assign valid, undigested image as deployed image before any other changes.
// This can be overridden when build&push=enabled with freshly built image
// OR directly deployed when build&push=disabled as is.
f.Deploy.Image = configImage
return f, digested, err
}
19 changes: 10 additions & 9 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ func runRun(cmd *cobra.Command, newClient ClientFactory) (err error) {
// If requesting to run via the container, build the container if it is
// either out-of-date or a build was explicitly requested.
if cfg.Container {
var (
digested bool
justBuilt bool
)
var digested bool

buildOptions, err := cfg.buildOptions()
if err != nil {
Expand All @@ -193,20 +190,24 @@ func runRun(cmd *cobra.Command, newClient ClientFactory) (err error) {
if err != nil {
return err
}
if !digested {
// assign valid undigested image
f.Build.Image = cfg.Image
}
}

if digested {
// run cmd takes f.Build.Image - see newContainerConfig in docker/runner.go
// it doesnt get saved, just runtime image
f.Build.Image = cfg.Image
} else {
if f, justBuilt, err = build(cmd, cfg.Build, f, client, buildOptions); err != nil {

if f, _, err = build(cmd, cfg.Build, f, client, buildOptions); err != nil {
return err
}
if !justBuilt && !digested {
f.Build.Image = cfg.Image
}
}
} else { // dont run digested image without a container
} else {
// dont run digested image without a container
if cfg.Image != "" {
digested, err := isDigested(cfg.Image)
if err != nil {
Expand Down

0 comments on commit d095a39

Please sign in to comment.