github.com/GoogleCloudPlatform/terraformer@v0.8.18/providers/keycloak/scope.go (about)

     1  // Copyright 2018 The Terraformer Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package keycloak
    16  
    17  import (
    18  	"strings"
    19  
    20  	"github.com/GoogleCloudPlatform/terraformer/terraformutils"
    21  	"github.com/mrparkers/terraform-provider-keycloak/keycloak"
    22  )
    23  
    24  func (g RealmGenerator) createScopeResources(realmID string, openidClientScopes []*keycloak.OpenidClientScope) []terraformutils.Resource {
    25  	var resources []terraformutils.Resource
    26  	for _, openidClientScope := range openidClientScopes {
    27  		resources = append(resources, terraformutils.NewResource(
    28  			openidClientScope.Id,
    29  			"openid_client_scope_"+normalizeResourceName(realmID)+"_"+normalizeResourceName(openidClientScope.Name),
    30  			"keycloak_openid_client_scope",
    31  			"keycloak",
    32  			map[string]string{
    33  				"realm_id": realmID,
    34  			},
    35  			[]string{},
    36  			map[string]interface{}{},
    37  		))
    38  	}
    39  	return resources
    40  }
    41  
    42  func (g RealmGenerator) createOpenidClientScopesResources(realmID, clientID, clientClientID, t string, openidClientScopes *[]keycloak.OpenidClientScope) terraformutils.Resource {
    43  	var scopes []string
    44  	for _, openidClientScope := range *openidClientScopes {
    45  		scopes = append(scopes, openidClientScope.Name)
    46  	}
    47  	return terraformutils.NewResource(
    48  		realmID+"/"+clientID,
    49  		"openid_client_"+t+"_scopes_"+normalizeResourceName(realmID)+"_"+normalizeResourceName(clientClientID),
    50  		"keycloak_openid_client_"+t+"_scopes",
    51  		"keycloak",
    52  		map[string]string{
    53  			"realm_id":    realmID,
    54  			"client_id":   clientID,
    55  			t + "_scopes": strings.Join(scopes, ","),
    56  		},
    57  		[]string{},
    58  		map[string]interface{}{},
    59  	)
    60  }