Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Add Scope for Resource_Gitea_Token #53

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

David-Elizondo
Copy link

@David-Elizondo David-Elizondo commented Aug 21, 2023

Token scope was added to Gitea Tokens in V0.16+. The official Gitea SDK has not released a official version in 2years. The Implementation does exists in the default branch (Thanks John Olheiser).

Until the SDK has an official release of this feature it's not advisable to merge this PR into your provider.

But in the mean time, I've added this scope attr resource to be able to handle this new feature.

Updates:

  • Bump Provider Version to 0.16.1
  • Bump Go-SDK to point to the latest commit on Go-SDK Repo (091528835fc2b7947cdc51cc9fdea94d56994825)
  • Bumped vendor folder to reflect dependencies
  • Implemented scope using Go-SDK for Gitea Tokens

Workaround:

Install this branch locally with the existing makefile. make install and point provider to local install and operate terraform as usual.

terraform {
  required_providers {
    gitea = {
      source  = "terraform.local/lerentis/gitea"
      version = "0.16.1"
    }
  }
}

Example Usage:

terraform {
  required_providers {
    gitea = {
      source  = "terraform.local/lerentis/gitea"
      version = "0.16.1"
    }
  }
}

provider "gitea" {
  base_url = "http://localhost:3000/" 
  username = "root"                     
  password = "root"                     
}

resource "gitea_token" "test" {
  username = "root"
  name     = "test"
  scope    = ["write:organization","write:user"]
}

resource "gitea_token" "test2" {
  username = "root"
  name     = "test2"
  scope    = ["all"]
}

resource "gitea_token" "test3" {
  username = "root"
  name     = "test3"
  scope    = ["public-only","all"]
}

Copy link
Owner

@Lerentis Lerentis left a comment

Choose a reason for hiding this comment

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

Hi @David-Elizondo ,
thanks a lot for the PR. This is definitely a good addition 😃
a few points independent from the inline comments:

Makefile Outdated
@@ -5,7 +5,7 @@ KERNEL?=$$(uname -s | tr '[:upper:]' '[:lower:]')

GOFMT ?= gofmt -s

VERSION = 0.16.0
VERSION = 0.16.1
Copy link
Owner

Choose a reason for hiding this comment

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

i think this is definitely worthy of a minor release and not a patch release ;-)

Copy link
Author

Choose a reason for hiding this comment

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

bumped :)

},
Optional: true,
ForceNew: true,
Description: "The token scope",
Copy link
Owner

Choose a reason for hiding this comment

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

maybe add the list of possible values here as it would directly be computed into the documentation

Copy link
Author

Choose a reason for hiding this comment

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

Added the list from go-gitea/gitea#24767

@@ -3,7 +3,7 @@ module git.uploadfilter24.eu/terraform-provider-gitea
go 1.18

require (
code.gitea.io/sdk/gitea v0.15.1
code.gitea.io/sdk/gitea v0.15.1-0.20230815151548-091528835fc2
Copy link
Owner

Choose a reason for hiding this comment

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

i am wondering if this is not just the way to go. the gitea SDK maintainers do not really release anymore it seems. will try to reach out and clarify the situation but with what i know now this would not be a blocker to move forward here

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, It seems to be odd. Not sure if this is related to them changing license structure?

Copy link
Owner

Choose a reason for hiding this comment

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

just to give you an update:
i wrote a mail to @6543 to ask about a possible release as he is the one who did the last release of the go sdk, but did not yet receive any response.
i will wait until next week and if there is no response by then i will just assume that this is the way to go 🤷

Copy link
Author

Choose a reason for hiding this comment

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

Ok 👍 Thanks for the update :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@David-Elizondo As an FYI, there is no licensing change to any Gitea repos.
I've released 0.16.0 to the go-sdk, so hopefully, you don't need to target a hash in the gomod anymore.
The official terraform provider is back under active development, with all of @Lerentis amazing changes merged back in, and @Lerentis has been invited to be a maintainer of the provider (and has write access to the repo).
If you're open to it, a PR to https://gitea.com/gitea/terraform-provider-gitea would be very welcome and appreciated. Or, I could do it for you. Either way, thanks :)

Copy link
Author

Choose a reason for hiding this comment

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

Hello @techknowlogick,

Thanks for the update. Sure thing I'll go over their and push these changes. I'll close this PR once complete.

Congrats @Lerentis 🥳

@David-Elizondo
Copy link
Author

Hello @Lerentis !
Made the changes requested, thanks for the review!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants