Skip to content

Commit

Permalink
Missing terraform
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Sverdlov <[email protected]>
  • Loading branch information
sverdlov93 committed Jan 22, 2024
1 parent 9820268 commit 73afbcd
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ apiKey, err := rtManager.GetAPIKey()
You can create and update a local repository for the following package types:

Alpine, Bower, Cran, Cargo, Chef, Cocoapods, Composer, Conan, Conda, Debian, Docker, Gems, Generic, Gitlfs, Go, Gradle,
Helm, Ivy, Maven, Npm, Nuget, Opkg, Puppet, Pypi, Rpm, Sbt, Swift, Vagrant, and Yum.
Helm, Ivy, Maven, Npm, Nuget, Opkg, Puppet, Pypi, Rpm, Sbt, Swift, Terraform, Vagrant, and Yum.

Each package type has its own parameters struct, can be created using the method
`New<packageType>LocalRepositoryParams()`.
Expand Down Expand Up @@ -845,7 +845,7 @@ err = servicesManager.UpdateLocalRepository().Generic(params)
You can create and update a remote repository for the following package types:

Alpine, Bower, Cran, Cargo, Chef, Cocoapods, Composer, Conan, Conda, Debian, Docker, Gems, Generic, Gitlfs, Go, Gradle,
Helm, Ivy, Maven, Npm, Nuget, Opkg, P2, Puppet, Pypi, Rpm, Sbt, Swift, Vcs, and Yum.
Helm, Ivy, Maven, Npm, Nuget, Opkg, P2, Puppet, Pypi, Rpm, Sbt, Swift, Terraform, Vcs, and Yum.

Each package type has its own parameters struct, can be created using the method
`New<packageType>RemoteRepositoryParams()`.
Expand Down Expand Up @@ -889,7 +889,7 @@ err := servicesManager.CreateRemoteRepository(params)
You can create and update a virtual repository for the following package types:

Alpine, Bower, Cran, Chef, Conan, Conda, Debian, Docker, Gems, Generic, Gitlfs, Go, Gradle, Helm, Ivy, Maven, Npm,
Nuget, P2, Puppet, Pypi, Rpm, Sbt, Swift and Yum.
Nuget, P2, Puppet, Pypi, Rpm, Sbt, Swift, Terraform and Yum.

Each package type has its own parameters struct, can be created using the method
`New<packageType>VirtualRepositoryParams()`.
Expand Down Expand Up @@ -931,7 +931,7 @@ err = servicesManager.UpdateVirtualRepository().Go(params)
You can create and update a federated repository for the following package types:

Alpine, Bower, Cran, Cargo, Chef, Cocoapods, Composer, Conan, Conda, Debian, Docker, Gems, Generic, Gitlfs, Go, Gradle,
Helm, Ivy, Maven, Npm, Nuget, Opkg, Puppet, Pypi, Rpm, Sbt, Swift Vagrant and Yum
Helm, Ivy, Maven, Npm, Nuget, Opkg, Puppet, Pypi, Rpm, Sbt, Swift, Terraform, Vagrant and Yum

Each package type has its own parameters struct, can be created using the method
`New<packageType>FederatedRepositoryParams()`.
Expand Down
12 changes: 12 additions & 0 deletions artifactory/services/federatedrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ func (frs *FederatedRepositoryService) Swift(params SwiftFederatedRepositoryPara
return frs.performRequest(params, params.Key)
}

func (frs *FederatedRepositoryService) Terraform(params TerraformFederatedRepositoryParams) error {
return frs.performRequest(params, params.Key)
}

func (frs *FederatedRepositoryService) Vagrant(params VagrantFederatedRepositoryParams) error {
return frs.performRequest(params, params.Key)
}
Expand Down Expand Up @@ -389,6 +393,14 @@ func NewSwiftFederatedRepositoryParams() SwiftFederatedRepositoryParams {
return SwiftFederatedRepositoryParams{FederatedRepositoryBaseParams: NewFederatedRepositoryPackageParams("swift")}
}

type TerraformFederatedRepositoryParams struct {
FederatedRepositoryBaseParams
}

func NewTerraformFederatedRepositoryParams() TerraformFederatedRepositoryParams {
return TerraformFederatedRepositoryParams{FederatedRepositoryBaseParams: NewFederatedRepositoryPackageParams("terraform")}
}

type VagrantFederatedRepositoryParams struct {
FederatedRepositoryBaseParams
}
Expand Down
3 changes: 1 addition & 2 deletions artifactory/services/remoterepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,9 @@ func NewSwiftRemoteRepositoryParams() SwiftRemoteRepositoryParams {

type TerraformRemoteRepositoryParams struct {
RemoteRepositoryBaseParams
VcsGitRemoteRepositoryParams
TerraformRegistryUrl string `json:"terraformRegistryUrl,omitempty"`
TerraformProvidersUrl string `json:"terraformProvidersUrl,omitempty"`
VcsType string `json:"vcsType,omitempty"`
VcsGitProvider string `json:"vcsGitProvider,omitempty"`
}

func NewTerraformRemoteRepositoryParams() TerraformRemoteRepositoryParams {
Expand Down
22 changes: 22 additions & 0 deletions tests/artifactoryfederatedrepository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestArtifactoryFederatedRepository(t *testing.T) {
t.Run("federatedRpmTest", federatedRpmTest)
t.Run("federatedSbtTest", federatedSbtTest)
t.Run("federatedSwiftTest", federatedSwiftTest)
t.Run("federatedTerraformTest", federatedTerraformTest)
t.Run("federatedVagrantTest", federatedVagrantTest)
t.Run("federatedYumTest", federatedYumTest)
t.Run("federatedCreateWithParamTest", federatedCreateWithParamTest)
Expand Down Expand Up @@ -654,6 +655,27 @@ func federatedSwiftTest(t *testing.T) {
}
}

func federatedTerraformTest(t *testing.T) {
repoKey := GenerateRepoKeyForRepoServiceTest()
sfp := services.NewTerraformFederatedRepositoryParams()
sfp.Key = repoKey
setFederatedRepositoryBaseParams(&sfp.FederatedRepositoryBaseParams, false)

err := testsCreateFederatedRepositoryService.Terraform(sfp)
if !assert.NoError(t, err, "Failed to create "+repoKey) {
return
}
defer deleteRepo(t, repoKey)
validateRepoConfig(t, repoKey, sfp)

setFederatedRepositoryBaseParams(&sfp.FederatedRepositoryBaseParams, true)

err = testsUpdateFederatedRepositoryService.Terraform(sfp)
if assert.NoError(t, err, "Failed to update "+repoKey) {
validateRepoConfig(t, repoKey, sfp)
}
}

func federatedVagrantTest(t *testing.T) {
repoKey := GenerateRepoKeyForRepoServiceTest()
vfp := services.NewVagrantFederatedRepositoryParams()
Expand Down
22 changes: 22 additions & 0 deletions tests/artifactorylocalrepository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestArtifactoryLocalRepository(t *testing.T) {
t.Run("localRpmTest", localRpmTest)
t.Run("localSbtTest", localSbtTest)
t.Run("localSwiftTest", localSwiftTest)
t.Run("localTerraformTest", localTerraformTest)
t.Run("localVagrantTest", localVagrantTest)
t.Run("localYumTest", localYumTest)
t.Run("localCreateWithParamTest", localCreateWithParamTest)
Expand Down Expand Up @@ -640,6 +641,27 @@ func localSwiftTest(t *testing.T) {
}
}

func localTerraformTest(t *testing.T) {
repoKey := GenerateRepoKeyForRepoServiceTest()
tlp := services.NewTerraformLocalRepositoryParams()
tlp.Key = repoKey
setLocalRepositoryBaseParams(&tlp.LocalRepositoryBaseParams, false)

err := testsCreateLocalRepositoryService.Terraform(tlp)
if !assert.NoError(t, err, "Failed to create "+repoKey) {
return
}
defer deleteRepo(t, repoKey)
validateRepoConfig(t, repoKey, tlp)

setLocalRepositoryBaseParams(&tlp.LocalRepositoryBaseParams, true)

err = testsUpdateLocalRepositoryService.Terraform(tlp)
if assert.NoError(t, err, "Failed to update "+repoKey) {
validateRepoConfig(t, repoKey, tlp)
}
}

func localVagrantTest(t *testing.T) {
repoKey := GenerateRepoKeyForRepoServiceTest()
vlp := services.NewVagrantLocalRepositoryParams()
Expand Down

0 comments on commit 73afbcd

Please sign in to comment.