Skip to content

Commit

Permalink
Fix readme sideload for runtime services (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Mar 15, 2024
1 parent aaf1b0b commit d45fb95
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 71 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
path: _build
key: ${{ runner.os }}-mix-1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-1-
- name: download jwt verification key
run: |
echo $JWT_PUBLIC_KEY > config/pubkey.pem
env:
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
# - name: download jwt verification key
# run: |
# echo $JWT_PUBLIC_KEY > config/pubkey.pem
# env:
# JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
- run: mix deps.get
- run: mix test
- uses: 8398a7/action-slack@v3
Expand Down Expand Up @@ -104,11 +104,11 @@ jobs:
with:
username: mjgpluralsh
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: download jwt verification key
run: |
echo $JWT_PUBLIC_KEY > config/pubkey.pem
env:
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
# - name: download jwt verification key
# run: |
# echo $JWT_PUBLIC_KEY > config/pubkey.pem
# env:
# JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
- name: Build and push
uses: docker/build-push-action@v3
with:
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ jobs:
with:
username: mjgpluralsh
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
# - name: download jwt verification key
# run: |
# echo $JWT_PUBLIC_KEY > config/pubkey.pem
# env:
# JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
- name: Test Build console image
uses: docker/build-push-action@v3
with:
Expand All @@ -67,11 +72,11 @@ jobs:
with:
version: latest
- run: make testup
- name: download jwt verification key
run: |
echo $JWT_PUBLIC_KEY > config/pubkey.pem
env:
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
# - name: download jwt verification key
# run: |
# echo $JWT_PUBLIC_KEY > config/pubkey.pem
# env:
# JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
- name: Restore dependencies cache
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ watchman-*.tar
.yalc
yalc.lock

config/pubkey.pem
# config/pubkey.pem
41 changes: 17 additions & 24 deletions assets/src/components/cd/cluster/addon/ClusterAddOnDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
useSetBreadcrumbs,
} from '@pluralsh/design-system'
import { useEffect, useMemo, useState } from 'react'
import isEmpty from 'lodash/isEmpty'

import ClusterAddOnDetailsSidecar from './ClusterAddOnDetailsSidecar'

Expand Down Expand Up @@ -72,28 +71,23 @@ export const getAddOnDetailsBreadcrumbs = ({
: []),
]

const useGetDirectory = (readme: string | null | undefined) =>
useMemo(() => {
const hasReadme = !isEmpty(readme)

return [
{
path: 'compatibility',
label: 'Compatibility',
enabled: true,
},
{
path: 'releases',
label: 'Releases',
enabled: true,
},
{
path: 'readme',
label: 'Readme',
enabled: hasReadme,
},
]
}, [readme])
const directory = [
{
path: 'compatibility',
label: 'Compatibility',
enabled: true,
},
{
path: 'releases',
label: 'Releases',
enabled: true,
},
{
path: 'readme',
label: 'Readme',
enabled: true,
},
]

export default function ClusterAddOnDetails() {
const theme = useTheme()
Expand Down Expand Up @@ -124,7 +118,6 @@ export default function ClusterAddOnDetails() {

useEffect(() => setKubeVersionVar(kubeVersion), [kubeVersion])
const rts = runtimeServices?.find((rts) => rts?.id === addOnId)
const directory = useGetDirectory(rts?.addon?.readme)

useSetBreadcrumbs(
useMemo(
Expand Down
27 changes: 25 additions & 2 deletions assets/src/components/cd/cluster/addon/ClusterAddOnReadme.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
import { ScrollablePage } from 'components/utils/layout/ScrollablePage'

import LoadingIndicator from 'components/utils/LoadingIndicator'
import { GqlError } from 'components/utils/Alert'
import { useRuntimeServiceQuery } from 'generated/graphql'

import MarkdocComponent from '../../../utils/MarkdocContent'

import { useClusterAddOnContext } from './ClusterAddOnDetails'
import { versionPlaceholder } from './ClusterAddOnReleases'

export default function ClusterAddOnReadme() {
const { runtimeService } = useClusterAddOnContext()
const { runtimeService: rts } = useClusterAddOnContext()
const { data, loading, error } = useRuntimeServiceQuery({
variables: { id: rts?.id, version: versionPlaceholder },
})

if (loading) return <LoadingIndicator />

if (error)
return (
<GqlError
header="Could not fetch readme"
error={error}
/>
)

return (
<ScrollablePage heading="Readme">
<MarkdocComponent raw={runtimeService?.addon?.readme} />
<MarkdocComponent
raw={
data?.runtimeService?.addon?.readme ||
'No readme available for this component'
}
/>
</ScrollablePage>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react'
import { Table } from '@pluralsh/design-system'
import { createColumnHelper } from '@tanstack/react-table'
import { ScrollablePage } from 'components/utils/layout/ScrollablePage'
import { useAddonReleaseUrlQuery } from 'generated/graphql'
import { useRuntimeServiceQuery } from 'generated/graphql'
import { TabularNumbers } from 'components/cluster/TableElements'
import { FullHeightTableWrap } from 'components/utils/layout/FullHeightTableWrap'
import isEmpty from 'lodash/isEmpty'
Expand All @@ -18,7 +18,7 @@ type Release = {
url: string
}

const versionPlaceholder = '_VSN_PLACEHOLDER_'
export const versionPlaceholder = '_VSN_PLACEHOLDER_'

const columnHelper = createColumnHelper<Release>()

Expand All @@ -41,7 +41,7 @@ export default function ClusterAddOnReleases() {

const columns = useMemo(() => [colVersion, colRelease], [])

const { data, loading, error } = useAddonReleaseUrlQuery({
const { data, loading, error } = useRuntimeServiceQuery({
variables: { id: rts?.id, version: versionPlaceholder },
})

Expand Down
50 changes: 27 additions & 23 deletions assets/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6512,7 +6512,7 @@ export type NodePoolFragment = { __typename?: 'NodePool', id: string, name: stri

export type ApiDeprecationFragment = { __typename?: 'ApiDeprecation', availableIn?: string | null, blocking?: boolean | null, deprecatedIn?: string | null, removedIn?: string | null, replacement?: string | null, component?: { __typename?: 'ServiceComponent', group?: string | null, version?: string | null, kind: string, name: string, namespace?: string | null, service?: { __typename?: 'ServiceDeployment', git?: { __typename?: 'GitRef', ref: string, folder: string } | null, repository?: { __typename?: 'GitRepository', httpsPath?: string | null, urlFormat?: string | null } | null } | null } | null };

export type RuntimeServiceFragment = { __typename?: 'RuntimeService', id: string, name: string, version: string, addon?: { __typename?: 'RuntimeAddon', icon?: string | null, readme?: string | null, versions?: Array<{ __typename?: 'AddonVersion', version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null> | null } | null, service?: { __typename?: 'ServiceDeployment', git?: { __typename?: 'GitRef', ref: string, folder: string } | null, repository?: { __typename?: 'GitRepository', httpsPath?: string | null, urlFormat?: string | null } | null, helm?: { __typename?: 'HelmSpec', version?: string | null } | null } | null, addonVersion?: { __typename?: 'AddonVersion', blocking?: boolean | null, version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null };
export type RuntimeServiceFragment = { __typename?: 'RuntimeService', id: string, name: string, version: string, addon?: { __typename?: 'RuntimeAddon', icon?: string | null, versions?: Array<{ __typename?: 'AddonVersion', version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null> | null } | null, service?: { __typename?: 'ServiceDeployment', git?: { __typename?: 'GitRef', ref: string, folder: string } | null, repository?: { __typename?: 'GitRepository', httpsPath?: string | null, urlFormat?: string | null } | null, helm?: { __typename?: 'HelmSpec', version?: string | null } | null } | null, addonVersion?: { __typename?: 'AddonVersion', blocking?: boolean | null, version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null };

export type AddonVersionFragment = { __typename?: 'AddonVersion', version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null };

Expand Down Expand Up @@ -6599,15 +6599,15 @@ export type RuntimeServicesQueryVariables = Exact<{
}>;


export type RuntimeServicesQuery = { __typename?: 'RootQueryType', cluster?: { __typename?: 'Cluster', id: string, name: string, currentVersion?: string | null, version?: string | null, runtimeServices?: Array<{ __typename?: 'RuntimeService', id: string, name: string, version: string, addon?: { __typename?: 'RuntimeAddon', icon?: string | null, readme?: string | null, versions?: Array<{ __typename?: 'AddonVersion', version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null> | null } | null, service?: { __typename?: 'ServiceDeployment', git?: { __typename?: 'GitRef', ref: string, folder: string } | null, repository?: { __typename?: 'GitRepository', httpsPath?: string | null, urlFormat?: string | null } | null, helm?: { __typename?: 'HelmSpec', version?: string | null } | null } | null, addonVersion?: { __typename?: 'AddonVersion', blocking?: boolean | null, version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null } | null> | null } | null };
export type RuntimeServicesQuery = { __typename?: 'RootQueryType', cluster?: { __typename?: 'Cluster', id: string, name: string, currentVersion?: string | null, version?: string | null, runtimeServices?: Array<{ __typename?: 'RuntimeService', id: string, name: string, version: string, addon?: { __typename?: 'RuntimeAddon', icon?: string | null, versions?: Array<{ __typename?: 'AddonVersion', version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null> | null } | null, service?: { __typename?: 'ServiceDeployment', git?: { __typename?: 'GitRef', ref: string, folder: string } | null, repository?: { __typename?: 'GitRepository', httpsPath?: string | null, urlFormat?: string | null } | null, helm?: { __typename?: 'HelmSpec', version?: string | null } | null } | null, addonVersion?: { __typename?: 'AddonVersion', blocking?: boolean | null, version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null } | null> | null } | null };

export type AddonReleaseUrlQueryVariables = Exact<{
export type RuntimeServiceQueryVariables = Exact<{
id: Scalars['ID']['input'];
version: Scalars['String']['input'];
}>;


export type AddonReleaseUrlQuery = { __typename?: 'RootQueryType', runtimeService?: { __typename?: 'RuntimeService', id: string, addon?: { __typename?: 'RuntimeAddon', releaseUrl?: string | null } | null } | null };
export type RuntimeServiceQuery = { __typename?: 'RootQueryType', runtimeService?: { __typename?: 'RuntimeService', id: string, addon?: { __typename?: 'RuntimeAddon', icon?: string | null, releaseUrl?: string | null, readme?: string | null, versions?: Array<{ __typename?: 'AddonVersion', version?: string | null, kube?: Array<string | null> | null, incompatibilities?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null, requirements?: Array<{ __typename?: 'VersionReference', version: string, name: string } | null> | null } | null> | null } | null } | null };

export type UpdateClusterBindingsMutationVariables = Exact<{
id: Scalars['ID']['input'];
Expand Down Expand Up @@ -7825,7 +7825,6 @@ export const RuntimeServiceFragmentDoc = gql`
versions {
...AddonVersion
}
readme
}
service {
git {
Expand Down Expand Up @@ -11078,50 +11077,55 @@ export type RuntimeServicesQueryHookResult = ReturnType<typeof useRuntimeService
export type RuntimeServicesLazyQueryHookResult = ReturnType<typeof useRuntimeServicesLazyQuery>;
export type RuntimeServicesSuspenseQueryHookResult = ReturnType<typeof useRuntimeServicesSuspenseQuery>;
export type RuntimeServicesQueryResult = Apollo.QueryResult<RuntimeServicesQuery, RuntimeServicesQueryVariables>;
export const AddonReleaseUrlDocument = gql`
query AddonReleaseURL($id: ID!, $version: String!) {
export const RuntimeServiceDocument = gql`
query RuntimeService($id: ID!, $version: String!) {
runtimeService(id: $id) {
id
addon {
icon
versions {
...AddonVersion
}
releaseUrl(version: $version)
readme
}
}
}
`;
${AddonVersionFragmentDoc}`;

/**
* __useAddonReleaseUrlQuery__
* __useRuntimeServiceQuery__
*
* To run a query within a React component, call `useAddonReleaseUrlQuery` and pass it any options that fit your needs.
* When your component renders, `useAddonReleaseUrlQuery` returns an object from Apollo Client that contains loading, error, and data properties
* To run a query within a React component, call `useRuntimeServiceQuery` and pass it any options that fit your needs.
* When your component renders, `useRuntimeServiceQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useAddonReleaseUrlQuery({
* const { data, loading, error } = useRuntimeServiceQuery({
* variables: {
* id: // value for 'id'
* version: // value for 'version'
* },
* });
*/
export function useAddonReleaseUrlQuery(baseOptions: Apollo.QueryHookOptions<AddonReleaseUrlQuery, AddonReleaseUrlQueryVariables>) {
export function useRuntimeServiceQuery(baseOptions: Apollo.QueryHookOptions<RuntimeServiceQuery, RuntimeServiceQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<AddonReleaseUrlQuery, AddonReleaseUrlQueryVariables>(AddonReleaseUrlDocument, options);
return Apollo.useQuery<RuntimeServiceQuery, RuntimeServiceQueryVariables>(RuntimeServiceDocument, options);
}
export function useAddonReleaseUrlLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AddonReleaseUrlQuery, AddonReleaseUrlQueryVariables>) {
export function useRuntimeServiceLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<RuntimeServiceQuery, RuntimeServiceQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<AddonReleaseUrlQuery, AddonReleaseUrlQueryVariables>(AddonReleaseUrlDocument, options);
return Apollo.useLazyQuery<RuntimeServiceQuery, RuntimeServiceQueryVariables>(RuntimeServiceDocument, options);
}
export function useAddonReleaseUrlSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions<AddonReleaseUrlQuery, AddonReleaseUrlQueryVariables>) {
export function useRuntimeServiceSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions<RuntimeServiceQuery, RuntimeServiceQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useSuspenseQuery<AddonReleaseUrlQuery, AddonReleaseUrlQueryVariables>(AddonReleaseUrlDocument, options);
return Apollo.useSuspenseQuery<RuntimeServiceQuery, RuntimeServiceQueryVariables>(RuntimeServiceDocument, options);
}
export type AddonReleaseUrlQueryHookResult = ReturnType<typeof useAddonReleaseUrlQuery>;
export type AddonReleaseUrlLazyQueryHookResult = ReturnType<typeof useAddonReleaseUrlLazyQuery>;
export type AddonReleaseUrlSuspenseQueryHookResult = ReturnType<typeof useAddonReleaseUrlSuspenseQuery>;
export type AddonReleaseUrlQueryResult = Apollo.QueryResult<AddonReleaseUrlQuery, AddonReleaseUrlQueryVariables>;
export type RuntimeServiceQueryHookResult = ReturnType<typeof useRuntimeServiceQuery>;
export type RuntimeServiceLazyQueryHookResult = ReturnType<typeof useRuntimeServiceLazyQuery>;
export type RuntimeServiceSuspenseQueryHookResult = ReturnType<typeof useRuntimeServiceSuspenseQuery>;
export type RuntimeServiceQueryResult = Apollo.QueryResult<RuntimeServiceQuery, RuntimeServiceQueryVariables>;
export const UpdateClusterBindingsDocument = gql`
mutation UpdateClusterBindings($id: ID!, $rbac: RbacAttributes!) {
updateRbac(clusterId: $id, rbac: $rbac)
Expand Down Expand Up @@ -15247,7 +15251,7 @@ export const namedOperations = {
ClusterNamespaces: 'ClusterNamespaces',
ClusterBindings: 'ClusterBindings',
RuntimeServices: 'RuntimeServices',
AddonReleaseURL: 'AddonReleaseURL',
RuntimeService: 'RuntimeService',
ClusterStatuses: 'ClusterStatuses',
TagPairs: 'TagPairs',
Usage: 'Usage',
Expand Down
8 changes: 6 additions & 2 deletions assets/src/graph/cdClusters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ fragment RuntimeService on RuntimeService {
versions {
...AddonVersion
}
readme
}
service {
git {
Expand Down Expand Up @@ -379,11 +378,16 @@ query RuntimeServices(
}
}

query AddonReleaseURL($id: ID!, $version: String!) {
query RuntimeService($id: ID!, $version: String!) {
runtimeService(id: $id) {
id
addon {
icon
versions {
...AddonVersion
}
releaseUrl(version: $version)
readme
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions config/pubkey.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvLmqPPIO2dJTTJ28IZZ9
hqEMkJemPM8bXICoG5X3csm7HlITB8SIwsWx8QBjPHY4quh/5Ry+C117x4IbrwR4
hriCXK4BTembJa1gPR/YDrX2deJRGb+yLA13iEXNn/p9wlQFJr621ta7sRy5w0cR
nvHb8LEUuJIx2E5PdUgrZ5voV87CB94UzL+N/IXyYovUeCPpTZMBsbmgjzCNYjy6
zPZeoGF3yRojbjYkv0NljVEAEZljCI5+4copNQ3uwv1Uf6DOON8UhznbR8w07Cl3
ADt3spWH2KEIgZ1uRKFSp+wTSFP9bPYfIMYsB42hvPi1oq2l0nhP22IFQggGXiHK
4wIDAQAB
-----END PUBLIC KEY-----
2 changes: 1 addition & 1 deletion lib/console/deployments/settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule Console.Deployments.Settings do
"""
@spec agent_helm_values() :: binary | nil
def agent_helm_values() do
case fetch() do
case fetch_consistent() do
%DeploymentSettings{agent_helm_values: vs} when is_binary(vs) and byte_size(vs) > 0 -> vs
_ -> nil
end
Expand Down

0 comments on commit d45fb95

Please sign in to comment.