openfaas / faas-cli

Official CLI for OpenFaaS
https://www.openfaas.com/
Other
798 stars 224 forks source link

Image tag generation not working with generate command #829

Closed mcguiresm closed 4 years ago

mcguiresm commented 4 years ago

Expected Behaviour

faas-cli generate -f hello-world.yml --tag branch --api=serving.knative.dev/v1alpha1

---
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: hello-world
spec:
  runLatest:
    configuration:
      revisionTemplate:
        spec:
          container:
            image: hello-world:latest-master-8703b39

Current Behaviour

faas-cli generate -f hello-world.yml --tag branch --api=serving.knative.dev/v1alpha1

---
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: hello-world
spec:
  runLatest:
    configuration:
      revisionTemplate:
        spec:
          container:
            image: hello-world:latest

Possible Solution

Quick test of adding schema.BuildImageName() from generateCRDYAML() in generateknativev1alphaServicingCRDYAML() and modifying Image: to use the result from schema.BuildImageName() worked correctly. If that seems appropriate and there are no pitfalls I can submit a PR.

Steps to Reproduce (for bugs)

  1. $ mkdir hello-world
  2. $ cd hello-world
  3. $ faas-cli new hello-world --lang csharp
  4. $ faas-cli generate -f hello-world.yml --tag branch --api=serving.knative.dev/v1alpha1

Context

Trying to leverage OpenFaaS developer experience with KNative serving feature set due to existing setup.

Your Environment

Server: Docker Engine - Community Engine: Version: 19.03.12 API version: 1.40 (minimum version 1.12) Go version: go1.13.10 Git commit: 48a66213fe Built: Mon Jun 22 15:49:27 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: v1.2.13 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683



* Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?
No
* Operating System and version (e.g. Linux, Windows, MacOS):
MacOS
* Link to your project or a code example to reproduce issue:
alexellis commented 4 years ago

Hi @mcguiresm - glad you are finding OpenFaaS useful to your Knative deployment.

Would you be willing to work on this feature?

Alex

alexellis commented 4 years ago

/set title: Image tag generation not working with generate command

alexellis commented 4 years ago

I suspect this might also affect the OpenFaaS generation command, which we use for our own CRD for use with the operator.

@utsavanand2 can you look into this please?

mcguiresm commented 4 years ago

Hey @alexellis - absolutely.

alexellis commented 4 years ago

This appears to work fine for our own CRD generation:

faas-cli generate -f stack.yml  --filter url-ping --tag=sha
---
apiVersion: openfaas.com/v1alpha2
kind: Function
metadata:
  name: url-ping
spec:
  name: url-ping
  image: alexellis/faas-url-ping:0.2-c12d57c
alexellis commented 4 years ago

I have a fix for this issue as I haven't heard from you since you agreed to work on a week ago.

./faas-cli generate --filter url-ping -f stack.yml --tag=sha --api serving.knative.dev/v1alpha1
---
apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: url-ping
  namespace: openfaas-fn
spec:
  runLatest:
    configuration:
      revisionTemplate:
        spec:
          container:
            image: alexellis/faas-url-ping:0.2-c12d57c
mcguiresm commented 4 years ago

Hey @alexellis - Sorry about that, week got away from me. That is what I ended up doing in testing as well and seemed to work.