Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new resource argocd_account_token #281

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test:
go test -v -cover -timeout=120s -parallel=4 ./...

testacc:
TF_ACC=1 go test -v -cover -timeout 8m ./...
TF_ACC=1 go test -v -cover -timeout 10m ./...

testacc_clean_env:
kind delete cluster --name argocd
Expand Down
37 changes: 30 additions & 7 deletions argocd/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (

"github.com/Masterminds/semver"
"github.com/argoproj/argo-cd/v2/pkg/apiclient"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/account"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/certificate"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/project"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/repocreds"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/repository"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/session"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/version"
"github.com/argoproj/argo-cd/v2/util/io"
"github.com/golang/protobuf/ptypes/empty"
Expand Down Expand Up @@ -50,13 +52,16 @@ var featureVersionConstraintsMap = map[int]*semver.Version{
}

type ServerInterface struct {
ApiClient apiclient.Client
ApplicationClient application.ApplicationServiceClient
CertificateClient certificate.CertificateServiceClient
ClusterClient cluster.ClusterServiceClient
ProjectClient project.ProjectServiceClient
RepositoryClient repository.RepositoryServiceClient
RepoCredsClient repocreds.RepoCredsServiceClient
AccountClient account.AccountServiceClient
ApiClient apiclient.Client
ApplicationClient application.ApplicationServiceClient
CertificateClient certificate.CertificateServiceClient
ClusterClient cluster.ClusterServiceClient
ProjectClient project.ProjectServiceClient
RepositoryClient repository.RepositoryServiceClient
RepoCredsClient repocreds.RepoCredsServiceClient
SessionClient session.SessionServiceClient

ServerVersion *semver.Version
ServerVersionMessage *version.VersionMessage
ProviderData *schema.ResourceData
Expand Down Expand Up @@ -84,6 +89,15 @@ func (p *ServerInterface) initClients(ctx context.Context) error {
p.ApiClient = apiClient
}

if p.AccountClient == nil {
_, accountClient, err := p.ApiClient.NewAccountClient()
if err != nil {
return err
}

p.AccountClient = accountClient
}

if p.ClusterClient == nil {
_, clusterClient, err := p.ApiClient.NewClusterClient()
if err != nil {
Expand Down Expand Up @@ -138,6 +152,15 @@ func (p *ServerInterface) initClients(ctx context.Context) error {
p.RepoCredsClient = repoCredsClient
}

if p.SessionClient == nil {
_, sessionClient, err := p.ApiClient.NewSessionClient()
if err != nil {
return err
}

p.SessionClient = sessionClient
}

acCloser, versionClient, err := p.ApiClient.NewVersionClient()
if err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions argocd/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ var tokenMutexClusters = &sync.RWMutex{}
// Used to handle concurrent access to each ArgoCD project
var tokenMutexProjectMap = make(map[string]*sync.RWMutex, 0)

// Used to handle concurrent access to ArgoCD secrets
var tokenMutexSecrets = &sync.RWMutex{}

var runtimeErrorHandlers []func(error)

func Provider() *schema.Provider {
Expand Down Expand Up @@ -219,6 +222,7 @@ func Provider() *schema.Provider {
},

ResourcesMap: map[string]*schema.Resource{
"argocd_account_token": resourceArgoCDAccountToken(),
"argocd_application": resourceArgoCDApplication(),
"argocd_repository_certificate": resourceArgoCDRepositoryCertificates(),
"argocd_cluster": resourceArgoCDCluster(),
Expand Down
Loading