vmware-archive / code-stream-cli

VMware vRealize Automation Code Stream CLI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get pipelines empty, get execution fails with panic: interface conversion: interface is nil, not error

pafcioooo opened this issue · comments

commented

I have carried out setup of cs-cli against vra 8.4:

  • using docker image
  • using a separate administration user for a connection (checked in GUI he has access to pipelines)

Now running commands gives:

  • cs-cli get pipeline
./cs-cli get pipeline
 "WARN [0000] No results found"

picture757-3

  • ./cs-cli get execution
./cs-cli get execution
panic: interface conversion: interface is nil, not error
goroutine 1 [running]

picture278-1

Hi @pafcioooo - can you please run cs-cli version and show the output?

commented

@sammcgeown here is output from two different platforms:

  • code-stream-cli_0.1.4_Windows_x86_64 downloaded from releases page.
C:\Downloads\code-stream-cli_0.1.4_Windows_x86_64>cs-cli version
*** cs-cli ***
Build version : dev
Build date    : unknown
Build commit  : none
Built by      : unknown
$ ./cs-cli version
*** cs-cli ***
Build version : dev
Build date    : unknown
Build commit  : none
Built by      : unknown

@pafcioooo I'm having real trouble replicating your issue, can you post a redacted copy of your .cs-cli.yaml (or the config file you're using?) Also can you try running your commands with the --debug flag enabled to see if anything else comes up? Thanks

commented

@sammcgeown, here you go:

  • My cs-cli.yaml ready for being publsihed at github
        currenttargetname: gdn-vra01-na
        target:
          gdn-vra01-na:
            accesstoken: ""
            domain: vmw.ala.com
            password: <password>
            server: gdn-vra01-na.vmw.ala.com
            username: p.user-adm
  • Running some tests with the debug option

        Microsoft Windows [Version 10.0.14393]
          (c) 2016 Microsoft Corporation. All rights reserved.
    
          C:\Users\p.user-adm>cd Downloads\code-stream-cli_0.1.4_Windows_x86_64
    
          C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.4_Windows_x86_64>cs-cli version
          *** cs-cli ***
          Build version : dev
          Build date    : unknown
          Build commit  : none
          Built by      : unknown
    
          C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.4_Windows_x86_64>cs-cli --debug version
          time="2021-05-14T18:15:13+02:00" level=info msg="Debug logging enabled"
          time="2021-05-14T18:15:13+02:00" level=info msg="Using config: C:\\Users\\p.user-adm\\.cs-cli.yaml Target: gdn-vra01-na"
          *** cs-cli ***
          Build version : dev
          Build date    : unknown
          Build commit  : none
          Built by      : unknown
    
          C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.4_Windows_x86_64>cs-cli --debug get pipeline
          time="2021-05-14T19:23:42+02:00" level=info msg="Debug logging enabled"
          time="2021-05-14T19:23:42+02:00" level=info msg="Using config: C:\\Users\\p.user-adm\\.cs-cli.yaml Target: gdn-vra01-na"
          time="2021-05-14T19:23:42+02:00" level=debug msg="Access Token Expired"
          time="2021-05-14T19:23:42+02:00" level=debug msg="Authenticating vRA"
          time="2021-05-14T19:23:43+02:00" level=debug msg="https://gdn-vra01-na.vmw.ala.com/pipeline/api/pipelines?apiVersion=2019-10-17"
          time="2021-05-14T19:23:43+02:00" level=info msg="Unable to get Code Stream Pipelines:  "
          time="2021-05-14T19:23:43+02:00" level=warning msg="No results found"
          +----+------+---------+-------------+
          | ID | NAME | PROJECT | DESCRIPTION |
          +----+------+---------+-------------+
          +----+------+---------+-------------+
    
          C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.4_Windows_x86_64>cs-cli get execution
          panic: interface conversion: interface is nil, not error
    
          goroutine 1 [running]:
          github.com/vmware/code-stream-cli/cmd.getExecutions(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8000107, 0x0, ...)
                  /home/runner/work/code-stream-cli/code-stream-cli/cmd/api-func-executions.go:42 +0x806
          github.com/vmware/code-stream-cli/cmd.glob..func19(0x162dec0, 0x167ec00, 0x0, 0x0)
                  /home/runner/work/code-stream-cli/code-stream-cli/cmd/execution.go:37 +0x105
          github.com/spf13/cobra.(*Command).execute(0x162dec0, 0x167ec00, 0x0, 0x0, 0x162dec0, 0x167ec00)
                  /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2
          github.com/spf13/cobra.(*Command).ExecuteC(0x162f2c0, 0xe0670b, 0xc0000180b8, 0xe1b801)
                  /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
          github.com/spf13/cobra.(*Command).Execute(...)
                  /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
          github.com/vmware/code-stream-cli/cmd.Execute()
                  /home/runner/work/code-stream-cli/code-stream-cli/cmd/root.go:65 +0x38
          main.main()
                  /home/runner/work/code-stream-cli/code-stream-cli/cs-cli.go:10 +0x27
    
          C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.4_Windows_x86_64>cs-cli config get-target
          gdn-vra01-na
    
          C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.4_Windows_x86_64>cs-cli --debug get pipeline
          time="2021-05-14T19:31:02+02:00" level=info msg="Debug logging enabled"
          time="2021-05-14T19:31:02+02:00" level=info msg="Using config: C:\\Users\\p.user-adm\\.cs-cli.yaml Target: gdn-vra01-na"
          time="2021-05-14T19:31:02+02:00" level=debug msg="Access Token Expired"
          time="2021-05-14T19:31:02+02:00" level=debug msg="Authenticating vRA"
          time="2021-05-14T19:31:03+02:00" level=debug msg="https://gdn-vra01-na.vmw.ala.com/pipeline/api/pipelines?apiVersion=2019-10-17"
          time="2021-05-14T19:31:03+02:00" level=info msg="Unable to get Code Stream Pipelines:  "
          time="2021-05-14T19:31:03+02:00" level=warning msg="No results found"
          +----+------+---------+-------------+
          | ID | NAME | PROJECT | DESCRIPTION |
          +----+------+---------+-------------+
          +----+------+---------+-------------+
    
          C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.4_Windows_x86_64>
    
    
    
  • I can access https://gdn-vra01-na.vmw.ala.com/pipeline/api/pipelines?apiVersion=2019-10-17 with a browser (Firefox) without any authentication but it shows just empty page

@pafcioooo_ I'm still not able to replicate these errors

  • Do you see the Access Token being generated in the .cs-cli.yaml file? (I am assuming you just redacted it?)
  • Is the SSL certificate self-signed, or signed by a CA and trusted by your Windows machine? (I don't think it's this, we would see another error, but I am grasping at straws here!)

Edit: I've found why the execution is throwing an error rather than returning an error message, which should be resolved in 0.1.5. There's also an --ignoreCertificateWarnings flag added to the CLI (though as I said, I don't think that's the issue).

Can you try with the new version please?

❯ cs-cli version
*** cs-cli ***
Build version : 0.1.5
Build date    : 2021-05-17T09:15:09Z
Build commit  : 207fa286fffec72ce014eadc38faa52d2463d063
Built by      : goreleaser
❯ cs-cli
Command line interface for VMware vRealize Automation Code Stream

Usage:
  cs-cli [command]

Available Commands:
  config      Modify the configuration of cs-cli
  create      Create resources in Code Stream
  delete      Delete resources in Code Stream
  get         Get resources in Code Stream
  help        Help about any command
  update      Update resources in Code Stream
  version     Print the current version information

Flags:
      --config string               config file (default is $HOME/.cs-cli.yaml)
      --debug                       Enable debug logging
  -h, --help                        help for cs-cli
      --ignoreCertificateWarnings   Disable HTTPS Certificate Validation

Use "cs-cli [command] --help" for more information about a command.
commented

@sammcgeown,
Access token has not been redacted by me, it has been generated with the first command use. Please notice that it is being generated empty, as you see it.
SSL certificated is self signed, but it has been added to certificate storage, and as you will see in command history dump below it gives the same output.

Version 0.1.5 still can not display pipelines but displays version numbers now.

C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.5_Windows_x86_64.tar>cs-cli config get-target
gdn-vra01-na

C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.5_Windows_x86_64.tar>cs-cli get pipeline
time="2021-05-17T12:49:56+02:00" level=warning msg="No results found"
+----+------+---------+-------------+
| ID | NAME | PROJECT | DESCRIPTION |
+----+------+---------+-------------+
+----+------+---------+-------------+

C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.5_Windows_x86_64.tar>cs-cli --debug get pipeline
time="2021-05-17T12:50:04+02:00" level=info msg="Debug logging enabled"
time="2021-05-17T12:50:04+02:00" level=info msg="Using config: C:\\Users\\p.user-adm\\.cs-cli.yaml Target: gdn-vra01-na"
time="2021-05-17T12:50:04+02:00" level=debug msg="Access Token Expired"
time="2021-05-17T12:50:04+02:00" level=debug msg="Authenticating vRA"
time="2021-05-17T12:50:05+02:00" level=debug msg="https://gdn-vra01-na.vmw.ala.com/pipeline/api/pipelines?apiVersion=2019-10-17"
time="2021-05-17T12:50:05+02:00" level=info msg="Unable to get Code Stream Pipelines:  "
time="2021-05-17T12:50:05+02:00" level=warning msg="No results found"
+----+------+---------+-------------+
| ID | NAME | PROJECT | DESCRIPTION |
+----+------+---------+-------------+
+----+------+---------+-------------+

C:\Users\p.user-adm\Downloads\code-stream-cli_0.1.5_Windows_x86_64.tar>cs-cli --debug --ignoreCertificateWarnings get pipeline
time="2021-05-17T12:50:39+02:00" level=info msg="Debug logging enabled"
time="2021-05-17T12:50:39+02:00" level=info msg="Using config: C:\\Users\\p.user-adm\\.cs-cli.yaml Target: gdn-vra01-na"
time="2021-05-17T12:50:39+02:00" level=debug msg="Access Token Expired"
time="2021-05-17T12:50:39+02:00" level=debug msg="Authenticating vRA"
time="2021-05-17T12:50:40+02:00" level=debug msg="https://gdn-vra01-na.vmw.ala.com/pipeline/api/pipelines?apiVersion=2019-10-17"
time="2021-05-17T12:50:40+02:00" level=info msg="Unable to get Code Stream Pipelines:  "
time="2021-05-17T12:50:40+02:00" level=warning msg="No results found"
+----+------+---------+-------------+
| ID | NAME | PROJECT | DESCRIPTION |
+----+------+---------+-------------+
+----+------+---------+-------------+

C:\Users\pawel.orzechowski\Downloads\code-stream-cli_0.1.5_Windows_x86_64.tar>cs-cli version
*** cs-cli ***
Build version : 0.1.5
Build date    : 2021-05-17T09:15:09Z
Build commit  : 207fa286fffec72ce014eadc38faa52d2463d063
Built by      : goreleaser

C:\Users\pawel.orzechowski\Downloads\code-stream-cli_0.1.5_Windows_x86_64.tar>

Thanks

Pawel

OK - I'm getting somewhere now, I can replicate the issue. The authentication API changed for 8.4 and I need to tweak the login methods. I will make the changes and let you know when it's fixed!

@pafcioooo - the latest build v0.1.6 should have fixed this, can you test and let me know?

commented

@sammcgeown, I have tested it, and now it works like a charm 👍
Thanks 🙂

Great - I'll close this issue then - thanks for your patience while I figured that one out!