Skip to content

Commit

Permalink
V0.9.1 dev (#12)
Browse files Browse the repository at this point in the history
* Introduce a new paramter to configure the seconds to wait after the initial creation of a Shared Drive (resolves #11)

* Update year

* Mention support for Drive Labels in README
  • Loading branch information
hanneshayashi authored Feb 5, 2023
1 parent 65cb3ac commit e9b2369
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ A Terraform Provider for Google Drive
* Manage Shared Drives and organize them into organizational units
* Manage Google Drive files (including file uploads, downloads and exports)
* Manage Google Drive permissions
* Manage Google Drive Labels (assignment to files als folders)

## Installation
To install this provider, copy and paste this code into your Terraform configuration. Then, run terraform init.
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ resource "gdrive_drive" "drive_restrictions" {

- `restrictions` (Block List, Max: 1) The restrictions that should be set on the Shared Drive (see [below for nested schema](#nestedblock--restrictions))
- `use_domain_admin_access` (Boolean) Use domain admin access
- `wait_after_create` (Number) The Drive API returns a Shared Drive object immediately after creation, even though it is often not ready or visibile in other APIS.
In order to prevent 404 errors after the creation of a Shared Drive, the provider will wait the specified number of seconds after the creation of a Shared Drive and before returning or attempting further operations.
This value is only used for the initial creation and not used for updates. Changing this value after the initial creation has no effect.

### Read-Only

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/data_source_drive.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/data_source_drives.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/data_source_file.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/data_source_files.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/data_source_label.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/data_source_labels.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/data_source_permission.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/data_source_permissions.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/helpers.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/provider.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
23 changes: 15 additions & 8 deletions provider/resource_drive.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -39,6 +39,14 @@ func resourceDrive() *schema.Resource {
Optional: true,
Description: "Use domain admin access",
},
"wait_after_create": {
Type: schema.TypeInt,
Optional: true,
Default: 60,
Description: `The Drive API returns a Shared Drive object immediately after creation, even though it is often not ready or visibile in other APIS.
In order to prevent 404 errors after the creation of a Shared Drive, the provider will wait the specified number of seconds after the creation of a Shared Drive and before returning or attempting further operations.
This value is only used for the initial creation and not used for updates. Changing this value after the initial creation has no effect.`,
},
"restrictions": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -146,8 +154,11 @@ func resourceCreateDrive(d *schema.ResourceData, _ any) error {
return err
}
d.SetId(driveResult.Id)
time.Sleep(5 * time.Second)
return resourceUpdateDrive(d, nil)
time.Sleep(time.Duration(d.Get("wait_after_create").(int)) * time.Second)
if d.HasChange("restrictions") {
return resourceUpdateDrive(d, nil)
}
return resourceReadDrive(d, nil)
}

func resourceReadDrive(d *schema.ResourceData, _ any) error {
Expand Down Expand Up @@ -177,11 +188,7 @@ func resourceUpdateDrive(d *schema.ResourceData, _ any) error {
if err != nil {
return err
}
err = resourceReadDrive(d, nil)
if err != nil {
return err
}
return nil
return resourceReadDrive(d, nil)
}

func resourceDeleteDrive(d *schema.ResourceData, _ any) error {
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_driveoumembership.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_file.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_label_assignment.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_label_policy.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_permission.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_permissions_policy.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Hannes Hayashi
Copyright © 2021-2023 Hannes Hayashi
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down

0 comments on commit e9b2369

Please sign in to comment.