Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support enable secure-by-default #5751

Merged
merged 6 commits into from
Nov 25, 2024

Conversation

golibali
Copy link
Contributor

@golibali golibali commented Oct 29, 2024

Support enabling secure-by-default on allready created non secure-by-default clusters. It can be set only to true.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Output from acceptance testing:

$ make testacc TEST=./ibm/service/kubernetes TESTARGS='-run=TestAccIBMContainerVPCClusterEnableSecureByDefault'

--- PASS: TestAccIBMContainerVPCClusterEnableSecureByDefault (4748.07s)
PASS
ok      github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/kubernetes      4748.258s

@golibali
Copy link
Contributor Author

golibali commented Oct 29, 2024

/on-hold - need to wait until the IBMCloud API backend is out in all prod region.

Type: schema.TypeBool,
Optional: true,
Description: "Enable Secure-by-default on existing clusters (note: can be used on existing clusters)",
ValidateFunc: func(i interface{}, s string) (warnings []string, errors []error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we are checking if its type bool or value can be true or false since we defined it as bool type will not it implictly take only true/false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, the first check is not needed. I'll remove it

if err := ClusterClient.VPCs().SetOutboundTrafficProtection(clusterID, outbound_traffic_protection, Env); err != nil {
return err
if d.HasChange(DisableOutboundTrafficProtectionFlag) {
outbound_traffic_protection := !d.Get(DisableOutboundTrafficProtectionFlag).(bool)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we are storing opposite value of DisableOutboundTrafficProtectionFlag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a legacy stuff, I didn't change the functionality here. On the other hand if I'm right the DisableOutboundTrafficProtectionFlag was introduced first, and after that in an upcoming change the opposite value of this was needed. It's a bit wierd, but this is how it's working.

go.mod Outdated
@@ -245,3 +245,5 @@ exclude (
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/client-go v12.0.0+incompatible
)

replace github.com/IBM-Cloud/bluemix-go => github.com/golibali/bluemix-go v0.0.0-20241025125601-938969bd5ada
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we do replace for local or fork code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove this. I used it until my bluemix change was not merged.

@@ -609,6 +626,10 @@ func resourceIBMContainerVpcClusterCreate(d *schema.ResourceData, meta interface

disableOutboundTrafficProtection := d.Get(DisableOutboundTrafficProtectionFlag).(bool)

if _, ok := d.GetOk(EnableSecureByDefaultFlag); ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this logic to CustomizeDiff implementation so we can validate during plan itself .

https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/customizing-differences

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I'll move it to there

}

if d.HasChange(EnableSecureByDefaultFlag) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we enable we can disable it back also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, I can follow you.
This resource flag can be set to only true. Basically an allready created cluster where this flag was not set, it can be set to true, but after that it can't be set to any other value. The validation for the "only true" is where the flag is described:

@golibali golibali marked this pull request as ready for review November 20, 2024 15:19
@golibali
Copy link
Contributor Author

test rerun:

$ make testacc TEST=./ibm/service/kubernetes TESTARGS='-run=TestAccIBMContainerVPCClusterEnableSecureByDefault'
--- PASS: TestAccIBMContainerVPCClusterEnableSecureByDefault (5796.58s)
PASS
ok      github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/kubernetes      5796.670s

@hkantare hkantare merged commit 7a2b13c into IBM-Cloud:master Nov 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants