ewilde / terraform-provider-openfaas

Terraform OpenFaaS provider
Mozilla Public License 2.0
47 stars 8 forks source link

Support Terraform 0.12 #2

Closed ameier38 closed 4 years ago

ameier38 commented 5 years ago

Could you please add support for Terraform 0.12?

Ref: https://www.terraform.io/docs/extend/terraform-0.12-compatibility.html

I think the only change is removing Gopkg.lock, and Gopkg.toml and then running the commands from the above link:

go get github.com/hashicorp/terraform@v0.12.0
go mod tidy
go mod vendor

Happy to create a PR for this.

ewilde commented 5 years ago

@ameier38 happy for you to prep the PR for the upgrade :+1:

ameier38 commented 5 years ago

Thanks, should have something in the next day or so.

ameier38 commented 5 years ago

Would like to first update the OpenFaaS api so that all of the function information is returned from /system/function. This would help ensure that the provider plays well with Kubernetes and handles changes to secrets and env variables. I have a stub started for the 0.12 upgrade and it looks like it would be pretty straight forward.

orefalo commented 5 years ago

Any updates on this?

orefalo commented 5 years ago

Well for anyone else asking, got around this provider by enabling openfaas operators. You can then deploy regular k8s yml for functions and leverage terraform-provider-kubernetes-yaml

mkimberley commented 4 years ago

I'd be more than happy to take a look at this issue and see if I can get it closed off?

ewilde commented 4 years ago

@mkimberley go for it. Should be straight forward ive done a couple following https://www.terraform.io/docs/extend/terraform-0.12-compatibility.html

Much appreciated

Terraform by HashiCorp
Terraform 0.12 Compatibility for Providers - Terraform by HashiCorp
Compatibility with Terraform 0.12 requires some changes to existing provider codebases.
mkimberley commented 4 years ago

I've started working on this one, Terraform's upgrade was simple enough, but I'm getting build issues as the OpenFaas project code base has moved on a little, changing the way auth and function calls are handled. Hopefully I'll get this cracked and get a PR submitted. Very much new to all of this! :)

alexellis commented 4 years ago

You might want to ask for help on Slack with that. It would be good to have this up to date 👍

@ewilde are you still maintaining this project?

ewilde commented 4 years ago

@alexellis yes I’m still maintaining this project

mkimberley commented 4 years ago

@ewilde - I wonder if you can help, I have done the majority of the changes now to support terraform 0.12 and openfaas 0.18.0 but I'm struggling with authentication issues (I'm very new to OpenFaas, and not overly familiar with how it handles auth)

I've pushed my recent changes: https://github.com/mkimberley/terraform-provider-openfaas

Go tests fail with the following:

2020/02/25 11:15:44 [DEBUG] returning provider schema
=== RUN   TestAccDataSourceOpenFaaSFunction_basic
--- FAIL: TestAccDataSourceOpenFaaSFunction_basic (0.05s)
    testing.go:568: Step 0 error: errors during apply:

        Error: error deploying function testaccopenfaasfunction-basic-a7spwfz6m7 status code 401 reason unauthorized access, run "faas-cli login" to setup authentication for this server

          on /tmp/tf-test953499142/main.tf line 1:
          (source code not available)

=== RUN   TestAccOpenFaaSFunction_importBasic
--- FAIL: TestAccOpenFaaSFunction_importBasic (0.01s)
    testing.go:568: Step 0 error: errors during apply:

        Error: error deploying function testaccopenfaasfunction-basic-w2h9ls23cv status code 401 reason unauthorized access, run "faas-cli login" to setup authentication for this server

          on /tmp/tf-test117854504/main.tf line 1:
          (source code not available)

=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestAccResourceOpenFaaSFunction_basic
--- FAIL: TestAccResourceOpenFaaSFunction_basic (0.02s)
    testing.go:568: Step 0 error: errors during apply:

        Error: error deploying function testaccopenfaasfunction-basic-8x4438v2xi status code 401 reason unauthorized access, run "faas-cli login" to setup authentication for this server

          on /tmp/tf-test288393370/main.tf line 1:
          (source code not available)

FAIL
exit status 1
FAIL    github.com/mkimberley/terraform-provider-openfaas/openfaas  0.099s

And the way I'm approaching the provider authentication presently (which is what I think is wrong) is:

func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    log.Printf("[DEBUG] configuring provider")
    config := Config{
        GatewayURI:      d.Get("uri").(string),
        TLSInsecure:     d.Get("tls_insecure").(bool),
        GatewayUserName: d.Get("user_name").(string),
        GatewayPassword: d.Get("password").(string),
        ProxyNameSpace:  d.Get("namespace").(string),
    }

    if config.GatewayUserName != "" && config.GatewayPassword != "" {
        token := openfaas_config.EncodeAuth(config.GatewayUserName, config.GatewayPassword)
        openfaas_config.UpdateAuthConfig(config.GatewayURI, token, "basic")
    }

    return config, nil
}

Just wondering if you can point me in the correct direction to work from next

Cheers! Almost there!

GitHub
mkimberley/terraform-provider-openfaas
Terraform OpenFaaS provider . Contribute to mkimberley/terraform-provider-openfaas development by creating an account on GitHub.
ewilde commented 4 years ago

@mkimberley Thank you I’ll take a look

ewilde commented 4 years ago

@mkimberley i've added support for terraform 0.12 with this release https://github.com/ewilde/terraform-provider-openfaas/releases/tag/v0.3.0

I would really appreciate if you could verify it works for your use case. I've tested it with the examples and integration tests and it works fine

GitHub
ewilde/terraform-provider-openfaas
Terraform OpenFaaS provider . Contribute to ewilde/terraform-provider-openfaas development by creating an account on GitHub.
ewilde commented 4 years ago

4 fixes this problem, feel free to open a new issue if you find any other problems

orefalo commented 4 years ago

Thanks a bunch, will give it a try and report any issues

mkimberley commented 4 years ago

Tested and working as expected, Thanks @ewilde !