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

Feature/cli upgrade dependencies #125

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 .github/workflows/build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: "~1.21"
deno-version: "~1.37"
- uses: actions/cache@v3
with:
path: ~/.cache/deno # see https://deno.land/manual/linking_to_external_code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: "~1.21"
deno-version: "~1.37"
- uses: actions/cache@v3
with:
path: ~/.cache/deno # see https://deno.land/manual/linking_to_external_code
Expand Down
149 changes: 149 additions & 0 deletions cli/deno.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cli/test/parse-yaml.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// a KISS deno script to parse yaml and output it as json
// this allows us to test a) yaml is valid and b) access properties using jq

import * as yaml from 'https://deno.land/std@0.136.0/encoding/yaml.ts';
import * as util from 'https://deno.land/std@0.136.0/io/util.ts';
import * as yaml from 'https://deno.land/std@0.170.0/encoding/yaml.ts';
import * as util from 'https://deno.land/std@0.170.0/io/util.ts';

const stdin = new TextDecoder().decode(
await util.readAll(Deno.stdin),
Expand Down
6 changes: 3 additions & 3 deletions cli/unipipe/commands/browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import {
import { OsbStatusValue } from "../osb.ts";
import { Repository } from "../repository.ts";
import { stringify } from "../yaml.ts";
import { show } from "./show.ts";
import { OutputFormat, show } from "./show.ts";
import { STATUSES, update } from "./update.ts";

export function registerBrowseCmd(program: Command) {
program
.command("browse [repo]")
.description("Interactively browse and manipulate a UniPipe OSB git repo.")
.action(async (_opts: Record<never, never>, repo: string | undefined) => {
.action(async (_, repo: string | undefined) => {
const repository = new Repository(repo ? repo : ".");
await browseInstances(repository);
});
Expand Down Expand Up @@ -177,7 +177,7 @@ async function browseInstances(repo: Repository) {
async function showInstance(repository: Repository, instanceId: string) {
await show(repository, {
instanceId: instanceId,
outputFormat: "yaml",
outputFormat: OutputFormat.YAML,
pretty: true,
});
}
Expand Down
6 changes: 3 additions & 3 deletions cli/unipipe/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function registerGenerateCmd(program: Command) {
"Pick a destination directory for the generated transform-handler file.",
)
.option(
"--handler <handler_b|handler_tf>",
"--handler <handler:handler>",
"Pick a handler type for the generated transform-handler file.",
)
.option(
Expand Down Expand Up @@ -112,7 +112,7 @@ export function registerGenerateCmd(program: Command) {
"Pick a destination directory for the generated unipipe-service-broker-deployment file.",
)
.option(
"--deployment <aci_tf|aci_az|gcp_cloudrun_tf>",
"--deployment <deployment:deployment>",
"Pick a deployment type for the generated unipipe-service-broker-deployment file.",
)
.action(async (options: CatalogOpts) =>
Expand All @@ -131,7 +131,7 @@ function generateUuid() {
}

async function generateService() {
const serviceDefinitionId = uuid.generate();
const serviceDefinitionId = uuid.generate() as string;

// repository root
const catalog: Dir = {
Expand Down
6 changes: 3 additions & 3 deletions cli/unipipe/commands/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export function registerGitCmd(program: Command) {
program
.command("git <cmd> [repo]")
.option(
"-n, --name [name:string]",
"-n, --name <name:string>",
"Git author username. Default is `Unipipe CLI`.",
)
.option(
"-e, --email [email:string]",
"-e, --email <email:string>",
"Git author email. Default is `[email protected]`.",
)
.option(
"-m, --message [message:string]",
"-m, --message <message:string>",
"Commit message. Default is `Commit changes`.",
)
.description(
Expand Down
10 changes: 5 additions & 5 deletions cli/unipipe/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ export function registerListCmd(program: Command) {
.type("profile", profilesType)
.type("status", statusesType)
.option(
"-p, --profile [profile:profile]",
"-p, --profile <profile:profile>",
"include columns of context information according to the specified OSB API profile. Supported values are 'meshmarketplace' and 'cloudfoundry'. Ignored when '-o json' is set.",
)
.option(
"-o, --output-format [format:format]",
"-o, --output-format <format:format>",
"Output format. Supported formats are json and text.",
{
default: "text",
default: "text" as Format,
},
)
.option(
"--status [status:status]",
"--status <status:status>",
"Filters instances by status. Allowed values are 'in progress', 'succeeded', 'failed' and 'EMPTY' (no status file present for this instance).",
)
.option(
"--deleted [deleted:boolean]",
"--deleted <deleted:boolean>",
"Filters instances by deleted. Allowed values are 'true' and 'false'",
)
.description(
Expand Down
23 changes: 13 additions & 10 deletions cli/unipipe/commands/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,34 @@ import { Command, EnumType } from "../deps.ts";
import { Repository } from "../repository.ts";
import { stringify } from "../yaml.ts";

const ALL_FORMATS = ["json", "yaml"] as const;
type FormatsTuple = typeof ALL_FORMATS;
type Format = FormatsTuple[number];
export enum OutputFormat {
JSON = "json",
YAML = "yaml",
}

const formatsType = new EnumType(ALL_FORMATS);
export const OutputFormatType = new EnumType(Object.values(OutputFormat));

export interface ShowOpts {
instanceId: string;
outputFormat: Format;
pretty: boolean;
outputFormat?: OutputFormat;
pretty?: boolean;
}

export function registerShowCmd(program: Command) {
// show
program
.command("show [repo]")
.type("format", formatsType)
.type("format", OutputFormatType)
.description(
"Shows the state stored service instance stored in a UniPipe OSB git repo.",
)
.option("-i, --instance-id <id>", "Service instance id.")
.option("-i, --instance-id <id>", "Service instance id.", {
required: true,
})
.option(
"-o, --output-format <output-format>",
"-o, --output-format <output-format:format>",
"Output format. Supported formats are yaml and json.",
{ default: "yaml" },
{ default: OutputFormat.YAML },
)
.option("--pretty", "Pretty print")
.action(async (options: ShowOpts, repo: string | undefined) => {
Expand Down
5 changes: 3 additions & 2 deletions cli/unipipe/commands/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ServiceInstance } from "../osb.ts";
import { Repository } from "../repository.ts";

interface TransformOpts {
xportRepo: string;
xportRepo?: string;
registryOfHandlers: string;
}

Expand All @@ -20,9 +20,10 @@ export function registerTransformCmd(program: Command) {
.option(
"-r, --registry-of-handlers <file>",
"A registry of handlers for processing service instance transformation. These can be defined in javascript, see `unipipe generate transform-handler` for an example.",
{ required: true },
)
.option(
"-x, --xport-repo [path:string]",
"-x, --xport-repo <path:string>",
"Path to the target git repository. If not specified the transform runs in place on the OSB git repo.",
)
.action(async (options: TransformOpts, repo: string | undefined) => {
Expand Down
8 changes: 6 additions & 2 deletions cli/unipipe/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export function registerUpdateCmd(program: Command) {
.description(
"Update status of a service instance or binding stored in a UniPipe OSB git repo.",
)
.option("-i --instance-id <instance-id>", "Service instance id.", {})
.option("-i --instance-id <instance-id>", "Service instance id.", {
required: true,
})
.option("-b --binding-id <binding-id>", "Service binding id.", {
depends: ["instance-id"],
})
Expand All @@ -39,9 +41,11 @@ export function registerUpdateCmd(program: Command) {
.option(
"--status <status:status>",
"The status. Allowed values are 'in progress', 'succeeded' and 'failed'.",
{ required: true },
) // todo use choices instead
.option("--description [description]", "Status description text.", {
.option("--description <description>", "Status description text.", {
default: "",
required: true,
})
.action(async (options: UpdateOpts, repo: string | undefined) => {
const repository = new Repository(repo ? repo : ".");
Expand Down
27 changes: 13 additions & 14 deletions cli/unipipe/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// this is a deno best practice https://deno.land/[email protected]/examples/manage_dependencies
// for discussion of the performance implications (and why this doesn't matter much for this _app_) see https://github.com/denoland/deno/issues/6194

export * as path from "https://deno.land/std@0.136.0/path/mod.ts";
export * as yaml from "https://deno.land/std@0.136.0/encoding/yaml.ts";
export { v4 as uuid } from "https://deno.land/std@0.136.0/uuid/mod.ts";
export * as colors from "https://deno.land/std@0.136.0/fmt/colors.ts";
export * as path from "https://deno.land/std@0.170.0/path/mod.ts";
export * as yaml from "https://deno.land/std@0.170.0/encoding/yaml.ts";
export { v1 as uuid } from "https://deno.land/std@0.170.0/uuid/mod.ts";
export * as colors from "https://deno.land/std@0.170.0/fmt/colors.ts";

// note: it's a bit ugly that we have to foray into the private parts of the stdlib, but otherwise we can't configure
// the options we need
export { Type as YamlType } from "https://deno.land/std@0.136.0/encoding/_yaml/type.ts";
export { Schema as YamlSchema } from "https://deno.land/std@0.136.0/encoding/_yaml/schema.ts";
export { Type as YamlType } from "https://deno.land/std@0.170.0/encoding/_yaml/type.ts";
export { Schema as YamlSchema } from "https://deno.land/std@0.170.0/encoding/_yaml/schema.ts";

/**
* 3rd party deps
Expand All @@ -21,18 +21,17 @@ export {
CompletionsCommand,
EnumType,
Type,
} from "https://deno.land/x/[email protected]/command/mod.ts";
export type { ITypeInfo } from "https://deno.land/x/[email protected]/command/mod.ts";
} from "https://deno.land/x/[email protected]/command/mod.ts";
export {
GithubProvider,
UpgradeCommand,
} from "https://deno.land/x/cliffy@v0.22.2/command/upgrade/mod.ts";
export type { GithubProviderOptions } from "https://deno.land/x/cliffy@v0.22.2/command/upgrade/mod.ts";
export { Table } from "https://deno.land/x/cliffy@v0.22.2/table/mod.ts";
} from "https://deno.land/x/cliffy@v0.25.7/command/upgrade/mod.ts";
export type { GithubProviderOptions } from "https://deno.land/x/cliffy@v0.25.7/command/upgrade/mod.ts";
export { Table } from "https://deno.land/x/cliffy@v0.25.7/table/mod.ts";
export {
Input,
prompt as prompt,
Select,
} from "https://deno.land/x/cliffy@v0.22.2/prompt/mod.ts";
export type { SelectValueOptions } from "https://deno.land/x/cliffy@v0.22.2/prompt/mod.ts";
export { List } from "https://deno.land/x/cliffy@v0.22.2/prompt/list.ts";
} from "https://deno.land/x/cliffy@v0.25.7/prompt/mod.ts";
export type { SelectValueOptions } from "https://deno.land/x/cliffy@v0.25.7/prompt/mod.ts";
export { List } from "https://deno.land/x/cliffy@v0.25.7/prompt/list.ts";
6 changes: 3 additions & 3 deletions cli/unipipe/dev_deps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export { assertEquals } from "https://deno.land/std@0.136.0/testing/asserts.ts";
export { assertEquals } from "https://deno.land/std@0.170.0/testing/asserts.ts";
export {
assertSpyCall,
assertSpyCalls,
returnsNext,
stub,
} from "https://deno.land/std@0.136.0/testing/mock.ts";
export type { Stub } from "https://deno.land/std@0.136.0/testing/mock.ts";
} from "https://deno.land/std@0.170.0/testing/mock.ts";
export type { Stub } from "https://deno.land/std@0.170.0/testing/mock.ts";
Loading