Skip to content

Conversation

@raghavanandan
Copy link
Contributor

No description provided.

@raghavanandan raghavanandan self-assigned this Sep 12, 2023
@raghavanandan raghavanandan changed the title [SSPROD-29925] - Add components to schema [SSPROD-29925] - Add features and components to schema Sep 13, 2023
@cgeers
Copy link
Contributor

cgeers commented Sep 15, 2023

I'm not sure why we changed from camelCase to snake_case on the metadata keys. The HTTP API, as defined in swagger expects camel and I suspect will reject snake. If we want snake case in the resource definition, we'll have to convert. This should be straightforward, but unless I missed it, isn't yet done.

cc: @raghavanandan @ravinadhruve10

}

func cloudauthAccountFromResourceData(data *schema.ResourceData) *v2.CloudauthAccountSecure {
components := []*cloudauth.AccountComponent{}
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be refactored. It's grown quite a bit.


featureMap = convertSchemaSetToMap(featureData.(*schema.Set))

for name, value := range featureMap {
Copy link
Contributor

Choose a reason for hiding this comment

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

most of the cases have similar implementation, can we try to refactor and make it more readable?


for key, value := range resourceComponent {

if value != nil && value.(string) != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a seperate function

Copy link
Contributor

@ravinadhruve10 ravinadhruve10 left a comment

Choose a reason for hiding this comment

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

Change LGTM. Thanks @raghavanandan , this is awesome!


if err != nil {
return err
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

@raghavanandan Liked the method descriptions you've added!!

Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need to return this back since it is computed?

Copy link
Contributor

@cgeers cgeers left a comment

Choose a reason for hiding this comment

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

this branch builds so I'm going to merge it and deal with any remaining items as additional follow ons.

@cgeers cgeers merged commit f2b30f6 into feature/api-only-secure-onboarding Sep 20, 2023
@cgeers cgeers deleted the SSPROD-29925 branch September 20, 2023 17:16
sarangard pushed a commit that referenced this pull request Oct 13, 2023
* [SSPROD-29309] - Create a resource for GCP API-only onboarding (#407)

* SSPROD-29308: Implement CloudAccount client v2 for Secure

Change summary:
-----------------
Adding a new CloudAccount client v2 for making Secure BE
(cloudauth) APIs to support API-only onboarding support.

* SSPROD-29308: Update the CloudAccountSecureV2 model object

* SSPROD-29308: Use cloudauth proto objects and rename client file

* SSPROD-29308: Add cloudauth pb.go files copy

* SSPROD-29308: Remove not required protorepo module

* Initial draft of resource

* go fmt file

* Use declared functions

* Rename and add resource

* Remove unused file

* Reformat files

* Add alias field

* Rebase and add toResourceData function

* Implement CRUD operations in resource

* Add enabled field

* Change type for provider type

* Remove unused proto import

* Remove setId to empty

* Change account_id to id

---------

Co-authored-by: Ravina Dhruve <ravina.dhruve@sysdig.com>
Co-authored-by: Raghav Anandan <raghav.anandan@raghav.anandan>

* SSPROD-29926: Support Provider_Type enum for Cloudauth Account

Change summary:
----------------
1. Fixed and added support for Provider_type enum in the Cloudaccount API.
   Using encoding/protojson for marshaling/unmarshaling in the cloudauth
   account client (instead of the common encoding/json based functions
   used by all clients). Updated the CloudauthAccountSecure model definition
   to support the same.
2. Made the 'id' field as computed and optional, instead of required.
3. Updated the 'cloud_provider_type' to be string instead of int.

Testing done:
--------------
- Validated create, read & delete CloudAccount operations via Terraform on staging.
- Validated that incorrect provider_type is not allowed.

* [SSPROD-29925] - Add features and components to schema (#410)

* Add components to schema

* Test component type

* Add components to schema

* fix(cloudauth): update native types

* feat(cloudauth): features & components

* fix(cloudauth): update resource data

* fix(cloudauth): adjust required fields

* Fix schema field names

* Set features as optional

* Convert schema set to map

* Check for value before switch case

* Populate features only if value is not nil

* Setaccount features using function

* Refactor fromResourceData function

* Parse and populate Service Prinicipal Private Key in metadata

---------

Co-authored-by: Raghav Anandan <raghav.anandan@raghav.anandan>
Co-authored-by: Christopher Geers <christopher.geers@sysdig.com>
Co-authored-by: Ravina Dhruve <ravina.dhruve@sysdig.com>

* SSPROD-29302: Provider support for organization resource

* SSPROD-29302: Add comment

* SSPROD-29302: using proto def

* SSPROD-29302: Local copy of pb code

* SSPROD-29302: Temp disable Validation

* SSPROD-29302: Changes in response to new Cloudauth account

* SSPROD-29302: fmt

* TF destroy fix (#414)

* TF destroy logs

* Return map

* Fix destroy blockers for features and components

* Add features to map dynamically

* Refine logic

* Define consts for schema keys

* Move const to common.go

---------

Co-authored-by: Raghav Anandan <raghav.anandan@raghav.anandan>

* fix(secure-cloud-account): Support parsing JSON encoded string inputs for Component metadata (#417)

* Resolving rebase conflicts

* Rebase and use constants for schema field names

* Populate all fields of component metadata in Cloudauth Account resource (#420)

Change summary:
----------------
Populating all the fields to fill in the GCP service_principal_metadata
proto struct (and not just the required fields), since we want to store
enough metadata information for potential usecases allowing us to run any
future workflows.

* Add support for Organization onboarding tests (#421)

* Add logs for debug

* Add test code for organization resource

* Remove logs

* Change the provider type and documentation

* Change Schema*

* Whitespace

* Whitespace

* Rebase fixes

* Add Cloudauth Account resource Tests (#419)

* Add Cloudauth Account resource Tests

Change summary:
----------------
1. Added tests for new cloudauth based CloudAccount resource.
2. Minor refactoring of marshal/unmarshal methods of cloudauth client.
3. Added the tests for the marshal/unmarshal methods.

* Remove redundant test

* Add missing import

* Fix test key input format

* Comment out failing test until proper fix

* Update Org onboarding test with account creation (#424)

* Add logs for debug

* Remove logs

* Create account before organization

* Add Cloudauth Account resource Documentation (#422)

* Add Cloudauth Account resource Documentation

* Minor updates to Cloudauth Account resource Documentation

* Fix the resource example

* Add reference note section

* Removing the provider_type from org resource (#426)

* Add logs for debug

* Remove logs

* Remove provider_type from org resource.

* Remove provider_type from the org documentation (#427)

* Add logs for debug

* Remove logs

* Remove provider_type from the doc

* Uncomment and add TestAccSecureCloudAuthAccountFC (#425)

* Uncomment and add TestAccSecureCloudAuthAccountFC

Fixed and updated TestAccSecureCloudAuthAccountFC with feature
and component payload in the resource request.

* Use ignore_changes in resource snippet for the test

* fixing unit tests json asserts

* fixing whitespace in json

* addressing linting + unit test issues

* fixing org & single project gcp cloudauth tests

* Fix the TF Read & delete for GCP Org cloudauth

* Fix the 404 for cloud account & org

---------

Co-authored-by: Raghav <35452664+raghavanandan@users.noreply.github.com>
Co-authored-by: Ravina Dhruve <ravina.dhruve@sysdig.com>
Co-authored-by: Raghav Anandan <raghav.anandan@raghav.anandan>
Co-authored-by: Christopher Geers <christopher.geers@sysdig.com>
Co-authored-by: Mandar Kulkarni <mandar.kulkarni@sysdig.com>
Co-authored-by: Ravina Dhruve <136399755+ravinadhruve10@users.noreply.github.com>
Co-authored-by: Mandar Kulkarni <131720522+mdkulkarni15@users.noreply.github.com>
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.

5 participants