mirror of
https://github.com/openziti/zrok.git
synced 2025-02-26 23:21:56 +01:00
enough machete work to make this stop complaining, at least (#893)
This commit is contained in:
parent
8aecb2d8c7
commit
435296f813
@ -1,6 +1,6 @@
|
||||
import { configFile, environmentFile, identityFile, metadataFile, rootDir } from "./dirs";
|
||||
import fs from "node:fs"
|
||||
import { Configuration, MetadataApi, HTTPHeaders } from "../zrok/api"
|
||||
import {Configuration, MetadataApi, MetadataApiApiKeys} from "../zrok/api/api"
|
||||
|
||||
const V = "v0.4"
|
||||
|
||||
@ -61,12 +61,8 @@ export class Root {
|
||||
|
||||
public async Client(): Promise<Configuration> {
|
||||
let apiEndpoint = this.ApiEndpoint()
|
||||
let conf = new Configuration({
|
||||
basePath: apiEndpoint.endpoint + '/api/v1',
|
||||
apiKey: this.env.Token,
|
||||
})
|
||||
|
||||
let mapi = new MetadataApi(conf)
|
||||
let mapi = new MetadataApi({basePath: apiEndpoint.endpoint + "/api/v1"})
|
||||
mapi.setApiKey(MetadataApiApiKeys, this.env.Token);
|
||||
let ver: Promise<string> = mapi.version()
|
||||
|
||||
const regex : RegExp = new RegExp("^(refs/(heads|tags)/)?" + V);
|
||||
|
@ -1,11 +1,9 @@
|
||||
import {Root} from "../environment/root"
|
||||
import {
|
||||
Share,
|
||||
ShareApi,
|
||||
AccessRequest,
|
||||
AccessResponse,
|
||||
AuthUser,
|
||||
UnaccessRequest} from "./api"
|
||||
Access201Response,
|
||||
UnaccessRequest} from "./api/api"
|
||||
import * as model from "./model"
|
||||
|
||||
export async function CreateAccess(root: Root, request: model.AccessRequest): Promise<model.Access> {
|
||||
@ -15,12 +13,12 @@ export async function CreateAccess(root: Root, request: model.AccessRequest): Pr
|
||||
|
||||
let out: AccessRequest = {
|
||||
envZId: root.env.ZitiIdentity,
|
||||
shrToken: request.ShareToken
|
||||
shareToken: request.ShareToken
|
||||
}
|
||||
|
||||
let conf = await root.Client()
|
||||
let client = new ShareApi(conf)
|
||||
let shr: AccessResponse = await client.access({body: out})
|
||||
let shr = await client.access({body: out})
|
||||
.catch(resp => {
|
||||
throw new Error("unable to create access " + resp)
|
||||
})
|
||||
@ -38,7 +36,7 @@ export async function CreateAccess(root: Root, request: model.AccessRequest): Pr
|
||||
export async function DeleteAccess(root: Root, acc: model.Access): Promise<void> {
|
||||
let out: UnaccessRequest = {
|
||||
frontendToken: acc.Token,
|
||||
shrToken: acc.ShareToken,
|
||||
shareToken: acc.ShareToken,
|
||||
envZId: root.env.ZitiIdentity
|
||||
}
|
||||
let conf = await root.Client()
|
||||
|
@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
@ -1,4 +1,6 @@
|
||||
import {ShareRequestBackendModeEnum, ShareRequestShareModeEnum, ShareRequestOauthProviderEnum} from "./api"
|
||||
// import {ShareRequestBackendModeEnum, ShareRequestShareModeEnum, ShareRequestOauthProviderEnum} from "./api"
|
||||
|
||||
import {ShareRequest as ApiShareRequest} from "./api/api";
|
||||
|
||||
export type BackendMode = string
|
||||
|
||||
@ -100,40 +102,40 @@ export const AUTH_SCHEME_NONE: AuthScheme = "none"
|
||||
export const AUTH_SCHEME_BASIC: AuthScheme = "basic"
|
||||
export const AUTH_SCHEME_OAUTH: AuthScheme = "oauth"
|
||||
|
||||
export function zrokBackendModeToOpenApi(z: BackendMode): ShareRequestBackendModeEnum | undefined{
|
||||
export function zrokBackendModeToOpenApi(z: BackendMode): ApiShareRequest.BackendModeEnum | undefined{
|
||||
switch(z){
|
||||
case PROXY_BACKEND_MODE:
|
||||
return ShareRequestBackendModeEnum.Proxy
|
||||
return ApiShareRequest.BackendModeEnum.Proxy
|
||||
case WEB_BACKEND_MODE:
|
||||
return ShareRequestBackendModeEnum.Web
|
||||
return ApiShareRequest.BackendModeEnum.Web
|
||||
case TCP_TUNNEL_BACKEND_MODE:
|
||||
return ShareRequestBackendModeEnum.TcpTunnel
|
||||
return ApiShareRequest.BackendModeEnum.TcpTunnel
|
||||
case UDP_TUNNEL_BACKEND_MODE:
|
||||
return ShareRequestBackendModeEnum.UdpTunnel
|
||||
return ApiShareRequest.BackendModeEnum.UdpTunnel
|
||||
case CADDY_BACKEND_MODE:
|
||||
return ShareRequestBackendModeEnum.Caddy
|
||||
return ApiShareRequest.BackendModeEnum.Caddy
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export function zrokShareModeToOpenApi(z: ShareMode): ShareRequestShareModeEnum | undefined {
|
||||
export function zrokShareModeToOpenApi(z: ShareMode): ApiShareRequest.ShareModeEnum | undefined {
|
||||
switch(z) {
|
||||
case PRIVATE_SHARE_MODE:
|
||||
return ShareRequestShareModeEnum.Private
|
||||
return ApiShareRequest.ShareModeEnum.Private
|
||||
case PUBLIC_SHARE_MODE:
|
||||
return ShareRequestShareModeEnum.Public
|
||||
return ApiShareRequest.ShareModeEnum.Public
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export function zrokOauthProviderToOpenApi(z: string): ShareRequestOauthProviderEnum | undefined {
|
||||
export function zrokOauthProviderToOpenApi(z: string): ApiShareRequest.OauthProviderEnum | undefined {
|
||||
switch(z.toLowerCase()){
|
||||
case ShareRequestOauthProviderEnum.Github.toString().toLowerCase():
|
||||
return ShareRequestOauthProviderEnum.Github
|
||||
case ShareRequestOauthProviderEnum.Google.toString().toLowerCase():
|
||||
return ShareRequestOauthProviderEnum.Google
|
||||
case (ApiShareRequest.OauthProviderEnum.Github as string).toString().toLowerCase():
|
||||
return ApiShareRequest.OauthProviderEnum.Github
|
||||
case (ApiShareRequest.OauthProviderEnum.Google as string).toString().toLowerCase():
|
||||
return ApiShareRequest.OauthProviderEnum.Google
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
|
@ -5,9 +5,7 @@ import {
|
||||
ShareRequest,
|
||||
ShareResponse,
|
||||
AuthUser,
|
||||
ShareRequestOauthProviderEnum,
|
||||
ShareRequestShareModeEnum,
|
||||
UnshareRequest} from "./api"
|
||||
UnshareRequest} from "./api/api"
|
||||
import * as model from "./model"
|
||||
|
||||
export async function CreateShare(root: Root, request: model.ShareRequest): Promise<model.Share> {
|
||||
@ -17,10 +15,10 @@ export async function CreateShare(root: Root, request: model.ShareRequest): Prom
|
||||
let out: ShareRequest
|
||||
|
||||
switch(request.ShareMode) {
|
||||
case ShareRequestShareModeEnum.Private:
|
||||
case ShareRequest.ShareModeEnum.Private:
|
||||
out = newPrivateShare(root, request)
|
||||
break
|
||||
case ShareRequestShareModeEnum.Public:
|
||||
case ShareRequest.ShareModeEnum.Public:
|
||||
out = newPublicShare(root, request)
|
||||
break
|
||||
default:
|
||||
@ -53,7 +51,7 @@ export async function CreateShare(root: Root, request: model.ShareRequest): Prom
|
||||
.catch(resp => {
|
||||
throw new Error("unable to create share " + resp)
|
||||
})
|
||||
return new model.Share(shr.shrToken||"", shr.frontendProxyEndpoints||[])
|
||||
return new model.Share(shr.shareToken||"", shr.frontendProxyEndpoints||[])
|
||||
}
|
||||
|
||||
function newPrivateShare(root: Root, request: model.ShareRequest): ShareRequest {
|
||||
@ -81,7 +79,7 @@ export async function DeleteShare(root: Root, shr: model.Share): Promise<void> {
|
||||
let client = new ShareApi(conf)
|
||||
let req: UnshareRequest = {
|
||||
envZId: root.env.ZitiIdentity,
|
||||
shrToken: shr.Token,
|
||||
shareToken: shr.Token,
|
||||
}
|
||||
req.envZId = root.env.ZitiIdentity
|
||||
return client.unshare({body: req})
|
||||
|
Loading…
Reference in New Issue
Block a user