Skip to content

Commit

Permalink
Use new query against nais-api
Browse files Browse the repository at this point in the history
Co-authored-by: Christer Edvartsen <[email protected]>
Co-authored-by: Vegar Sechmann Molvig <[email protected]>
  • Loading branch information
3 people committed Feb 23, 2024
1 parent eea5671 commit 75c2952
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 0 additions & 3 deletions charts/nais-verification/Feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ values:
naisTeams.apiToken:
computed:
template: '"{{.Management.nais_verification_teams_api_key}}"'
naisTeams.apiUrl:
computed:
template: http://teams-backend/query
image.pullPolicy:
config:
type: string
Expand Down
3 changes: 1 addition & 2 deletions charts/nais-verification/templates/netpol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ spec:
kubernetes.io/metadata.name: nais-system
podSelector:
matchLabels:
app.kubernetes.io/instance: teams-backend
app.kubernetes.io/name: teams-backend
app: nais-api
podSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
2 changes: 1 addition & 1 deletion charts/nais-verification/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ secretName: nais-verification-deploy-key
slackChannel: "#nais"

naisTeams:
apiUrl: http://teams-backend # Mapped in fasit
apiUrl: http://nais-api/query
apiToken: "" # Mapped in fasit
11 changes: 9 additions & 2 deletions nais_verification/deploy_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def _get_team_deploy_key(settings: Settings) -> str:
query = gql(
"""
query getDeployKey($slug: Slug!) {
deployKey(slug: $slug)
team(slug: $slug) {
deployKey {
key
}
}
}
"""
)
Expand All @@ -65,8 +69,11 @@ def _get_team_deploy_key(settings: Settings) -> str:
try:
result = client.execute(query, variable_values=params)
LOG.debug("result from getDeployKey query: %s", pformat(result))
deploy_key = result.get("deployKey", "")
deploy_key = result["team"]["deployKey"]["key"]
return deploy_key
except KeyError as e:
LOG.error("No deploy key returned:\n\t%s", _format_errors(e))
raise RuntimeError("Failed to get deploy key") from e
except TransportQueryError as e:
LOG.error("Failed to get deploy key:\n\t%s", _format_errors(e))
raise RuntimeError("Failed to get deploy key") from e
Expand Down

0 comments on commit 75c2952

Please sign in to comment.