diff --git a/docs/data-sources/module.md b/docs/data-sources/module.md
index 8c173548..571de09b 100644
--- a/docs/data-sources/module.md
+++ b/docs/data-sources/module.md
@@ -42,6 +42,7 @@ data "spacelift_module" "k8s-module" {
- `name` (String) The module name will by default be inferred from the repository name if it follows the terraform-provider-name naming convention. However, if the repository doesn't follow this convention, or you want to give it a custom name, you can provide it here.
- `project_root` (String) Project root is the optional directory relative to the repository root containing the module source code.
- `protect_from_deletion` (Boolean) Protect this module from accidental deletion. If set, attempts to delete this module will fail.
+- `raw_git` (List of Object) One-way VCS integration using a raw Git repository link (see [below for nested schema](#nestedatt--raw_git))
- `repository` (String) Name of the repository, without the owner part
- `shared_accounts` (Set of String) List of the accounts (subdomains) which should have access to the Module
- `space_id` (String) ID (slug) of the space the module is in
@@ -97,3 +98,12 @@ Read-Only:
- `id` (String)
- `is_default` (Boolean)
- `namespace` (String)
+
+
+
+### Nested Schema for `raw_git`
+
+Read-Only:
+
+- `namespace` (String)
+- `url` (String)
diff --git a/docs/resources/module.md b/docs/resources/module.md
index dfc94545..fb689570 100644
--- a/docs/resources/module.md
+++ b/docs/resources/module.md
@@ -55,6 +55,7 @@ resource "spacelift_module" "example-module" {
- `name` (String) The module name will by default be inferred from the repository name if it follows the terraform-provider-name naming convention. However, if the repository doesn't follow this convention, or you want to give it a custom name, you can provide it here.
- `project_root` (String) Project root is the optional directory relative to the repository root containing the module source code.
- `protect_from_deletion` (Boolean) Protect this module from accidental deletion. If set, attempts to delete this module will fail. Defaults to `false`.
+- `raw_git` (Block List, Max: 1) One-way VCS integration using a raw Git repository link (see [below for nested schema](#nestedblock--raw_git))
- `shared_accounts` (Set of String) List of the accounts (subdomains) which should have access to the Module
- `space_id` (String) ID (slug) of the space the module is in
- `terraform_provider` (String) The module provider will by default be inferred from the repository name if it follows the terraform-provider-name naming convention. However, if the repository doesn't follow this convention, or you gave the module a custom name, you can provide the provider name here.
@@ -145,6 +146,15 @@ Read-Only:
- `is_default` (Boolean) Indicates whether this is the default GitLab integration
+
+
+### Nested Schema for `raw_git`
+
+Required:
+
+- `namespace` (String) User-friendly namespace for the repository, this is for cosmetic purposes only
+- `url` (String) HTTPS URL of the Git repository
+
## Import
Import is supported using the following syntax:
diff --git a/spacelift/data_module.go b/spacelift/data_module.go
index 41b6b112..7fd1b338 100644
--- a/spacelift/data_module.go
+++ b/spacelift/data_module.go
@@ -185,6 +185,25 @@ func dataModule() *schema.Resource {
Description: "Protect this module from accidental deletion. If set, attempts to delete this module will fail.",
Computed: true,
},
+ "raw_git": {
+ Type: schema.TypeList,
+ Description: "One-way VCS integration using a raw Git repository link",
+ Computed: true,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "namespace": {
+ Type: schema.TypeString,
+ Description: "User-friendly namespace for the repository, this is for cosmetic purposes only",
+ Computed: true,
+ },
+ "url": {
+ Type: schema.TypeString,
+ Description: "HTTPS URL of the Git repository",
+ Computed: true,
+ },
+ },
+ },
+ },
"repository": {
Type: schema.TypeString,
Description: "Name of the repository, without the owner part",
diff --git a/spacelift/data_module_test.go b/spacelift/data_module_test.go
index 3f4f5db4..845f4d04 100644
--- a/spacelift/data_module_test.go
+++ b/spacelift/data_module_test.go
@@ -93,6 +93,40 @@ func TestModuleData(t *testing.T) {
},
})
})
+
+ t.Run("with Raw Git", func(t *testing.T) {
+ randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
+
+ testSteps(t, []resource.TestStep{
+ {
+ Config: fmt.Sprintf(`
+ resource "spacelift_module" "test" {
+ name = "test-module-%s"
+ administrative = false
+ branch = "main"
+ repository = "terraform-bacon-tasty"
+
+ raw_git {
+ namespace = "bacon"
+ url = "https://gist.github.com/d8d18c7c2841b578de22be34cb5943f5.git"
+ }
+ }
+ data "spacelift_module" "test" {
+ module_id = spacelift_module.test.id
+ }
+ `, randomID),
+ Check: Resource(
+ "data.spacelift_module.test",
+ Nested("raw_git",
+ CheckInList(
+ Attribute("namespace", Equals("bacon")),
+ Attribute("url", Equals("https://gist.github.com/d8d18c7c2841b578de22be34cb5943f5.git")),
+ ),
+ ),
+ ),
+ },
+ })
+ })
}
func TestModuleDataSpace(t *testing.T) {
diff --git a/spacelift/internal/structs/module.go b/spacelift/internal/structs/module.go
index 67f3b33d..1ffbe6f9 100644
--- a/spacelift/internal/structs/module.go
+++ b/spacelift/internal/structs/module.go
@@ -20,6 +20,7 @@ type Module struct {
ProtectFromDeletion bool `graphql:"protectFromDeletion"`
Provider VCSProvider `graphql:"provider"`
Repository string `graphql:"repository"`
+ RepositoryURL *string `graphql:"repositoryURL"`
SharedAccounts []string `graphql:"sharedAccounts"`
Space string `graphql:"space"`
TerraformProvider string `graphql:"terraformProvider"`
@@ -84,6 +85,12 @@ func (m *Module) ExportVCSSettings(d *schema.ResourceData) error {
}
}
fieldName = "gitlab"
+ case VCSProviderRawGit:
+ vcsSettings = map[string]interface{}{
+ "namespace": m.Namespace,
+ "url": m.RepositoryURL,
+ }
+ fieldName = "raw_git"
}
if fieldName != "" {
diff --git a/spacelift/internal/structs/module_input.go b/spacelift/internal/structs/module_input.go
index 09a1e232..edccb3c2 100644
--- a/spacelift/internal/structs/module_input.go
+++ b/spacelift/internal/structs/module_input.go
@@ -9,6 +9,7 @@ type ModuleCreateInput struct {
Namespace *graphql.String `json:"namespace"`
Provider *graphql.String `json:"provider"`
Repository graphql.String `json:"repository"`
+ RepositoryURL *graphql.String `json:"repositoryURL"`
TerraformProvider *graphql.String `json:"terraformProvider"`
Space *graphql.String `json:"space"`
VCSIntegrationID *graphql.ID `json:"vcsIntegrationId"`
@@ -42,6 +43,7 @@ type ModuleUpdateV2Input struct {
ProtectFromDeletion graphql.Boolean `json:"protectFromDeletion"`
Provider *graphql.String `json:"provider"`
Repository graphql.String `json:"repository"`
+ RepositoryURL *graphql.String `json:"repositoryURL"`
SharedAccounts *[]graphql.String `json:"sharedAccounts"`
Space *graphql.String `json:"space"`
VCSIntegrationID *graphql.ID `json:"vcsIntegrationId"`
diff --git a/spacelift/resource_module.go b/spacelift/resource_module.go
index 048e089b..f452616d 100644
--- a/spacelift/resource_module.go
+++ b/spacelift/resource_module.go
@@ -247,6 +247,29 @@ func resourceModule() *schema.Resource {
Optional: true,
Default: false,
},
+ "raw_git": {
+ Type: schema.TypeList,
+ Description: "One-way VCS integration using a raw Git repository link",
+ Optional: true,
+ ConflictsWith: conflictingVCSProviders("raw_git"),
+ MaxItems: 1,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "namespace": {
+ Type: schema.TypeString,
+ Required: true,
+ Description: "User-friendly namespace for the repository, this is for cosmetic purposes only",
+ ValidateDiagFunc: validations.DisallowEmptyString,
+ },
+ "url": {
+ Type: schema.TypeString,
+ Required: true,
+ Description: "HTTPS URL of the Git repository",
+ ValidateDiagFunc: validations.DisallowEmptyString,
+ },
+ },
+ },
+ },
"repository": {
Type: schema.TypeString,
Description: "Name of the repository, without the owner part",
@@ -404,7 +427,7 @@ func resourceModuleDelete(ctx context.Context, d *schema.ResourceData, meta inte
return nil
}
-func getSourceData(d *schema.ResourceData) (provider *graphql.String, namespace *graphql.String, vcsIntegrationID *graphql.ID) {
+func getSourceData(d *schema.ResourceData) (provider *graphql.String, namespace *graphql.String, repositoryURL *graphql.String, vcsIntegrationID *graphql.ID) {
provider = graphql.NewString("GITHUB")
if azureDevOps, ok := d.Get("azure_devops").([]interface{}); ok && len(azureDevOps) > 0 {
@@ -460,6 +483,12 @@ func getSourceData(d *schema.ResourceData) (provider *graphql.String, namespace
provider = graphql.NewString(graphql.String(structs.VCSProviderGitlab))
}
+ if rawGit, ok := d.Get("raw_git").([]interface{}); ok && len(rawGit) > 0 {
+ repositoryURL = toOptionalString(rawGit[0].(map[string]interface{})["url"])
+ namespace = toOptionalString(rawGit[0].(map[string]interface{})["namespace"])
+ provider = graphql.NewString(graphql.String(structs.VCSProviderRawGit))
+ }
+
return
}
@@ -468,7 +497,7 @@ func moduleCreateInput(d *schema.ResourceData) structs.ModuleCreateInput {
UpdateInput: moduleUpdateInput(d),
Repository: toString(d.Get("repository")),
}
- ret.Provider, ret.Namespace, ret.VCSIntegrationID = getSourceData(d)
+ ret.Provider, ret.Namespace, ret.RepositoryURL, ret.VCSIntegrationID = getSourceData(d)
name, ok := d.GetOk("name")
if ok {
@@ -547,7 +576,7 @@ func moduleUpdateV2Input(d *schema.ResourceData) structs.ModuleUpdateV2Input {
ProtectFromDeletion: graphql.Boolean(d.Get("protect_from_deletion").(bool)),
Repository: toString(d.Get("repository")),
}
- ret.Provider, ret.Namespace, ret.VCSIntegrationID = getSourceData(d)
+ ret.Provider, ret.Namespace, ret.RepositoryURL, ret.VCSIntegrationID = getSourceData(d)
description, ok := d.GetOk("description")
if ok {
diff --git a/spacelift/resource_module_test.go b/spacelift/resource_module_test.go
index 2d094fd2..8aa7d518 100644
--- a/spacelift/resource_module_test.go
+++ b/spacelift/resource_module_test.go
@@ -69,6 +69,41 @@ func TestModuleResource(t *testing.T) {
})
})
+ t.Run("with Raw Git", func(t *testing.T) {
+ randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)
+
+ config := func() string {
+ return fmt.Sprintf(`
+ resource "spacelift_module" "test" {
+ name = "raw-git-%s"
+ administrative = false
+ branch = "main"
+ repository = "terraform-bacon-tasty"
+
+ raw_git {
+ namespace = "bacon"
+ url = "https://gist.github.com/d8d18c7c2841b578de22be34cb5943f5.git"
+ }
+ }
+ `, randomID)
+ }
+
+ testSteps(t, []resource.TestStep{
+ {
+ Config: config(),
+ Check: Resource(
+ "spacelift_module.test",
+ Nested("raw_git",
+ CheckInList(
+ Attribute("namespace", Equals("bacon")),
+ Attribute("url", Equals("https://gist.github.com/d8d18c7c2841b578de22be34cb5943f5.git")),
+ ),
+ ),
+ ),
+ },
+ })
+ })
+
t.Run("project root and custom name", func(t *testing.T) {
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)