Skip to content

Index

Add infra for APP_NAME.

Source code in nava/platform/cli/commands/infra/__init__.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@app.command()
def add_app(
    typer_context: typer.Context,
    project_dir: str,
    app_name: str,
    template_uri: Annotated[str, opt_template_uri] = DEFAULT_TEMPLATE_URI,
    data: Annotated[list[str] | None, opt_data] = None,
    commit: Annotated[bool, opt_commit] = True,
) -> None:
    """Add infra for APP_NAME."""
    ctx = typer_context.ensure_object(CliContext)

    with ctx.handle_exceptions():
        add_app_command.add_app(
            ctx,
            template_uri,
            project_dir,
            app_name,
            data=dict_util.from_str_values(data),
            commit=commit,
        )

Display some information about the state of template-infra in the project.

Source code in nava/platform/cli/commands/infra/__init__.py
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@app.command()
def info(
    typer_context: typer.Context,
    project_dir: Annotated[
        Path,
        typer.Argument(
            exists=True,
            file_okay=False,
        ),
    ],
    template_uri: Annotated[str | None, opt_template_uri] = None,
) -> None:
    """Display some information about the state of template-infra in the project."""
    ctx = typer_context.ensure_object(CliContext)

    with ctx.handle_exceptions():
        info_command.info(ctx, project_dir, template_uri)

Install template-infra in project.

Source code in nava/platform/cli/commands/infra/__init__.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@app.command()
def install(
    typer_context: typer.Context,
    project_dir: str,
    template_uri: Annotated[str, opt_template_uri] = DEFAULT_TEMPLATE_URI,
    version: Annotated[str | None, opt_version] = DEFAULT_VERSION,
    data: Annotated[list[str] | None, opt_data] = None,
    commit: Annotated[bool, opt_commit] = False,
) -> None:
    """Install template-infra in project."""
    ctx = typer_context.ensure_object(CliContext)

    with ctx.handle_exceptions():
        install_command.install(
            ctx,
            template_uri,
            project_dir,
            version=version,
            data=dict_util.from_str_values(data),
            commit=commit,
        )

Migrate an older version of the template to platform-cli setup.

Source code in nava/platform/cli/commands/infra/__init__.py
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@app.command()
def migrate_from_legacy(
    typer_context: typer.Context,
    project_dir: str,
    origin_template_uri: Annotated[
        str,
        typer.Option(
            help="Path or URL to the legacy infra template that was used to set up the project. Can be a path to a local clone of template-infra. Defaults to the template-infra repository on GitHub.",
        ),
    ] = "https://github.com/navapbc/template-infra",
    commit: Annotated[bool, opt_commit] = False,
) -> None:
    """Migrate an older version of the template to platform-cli setup."""
    ctx = typer_context.ensure_object(CliContext)

    with ctx.handle_exceptions():
        migrate_from_legacy_command.migrate_from_legacy(
            ctx, project_dir, origin_template_uri, commit=commit
        )

Update base and application infrastructure.

This effectively just runs update-base followed by update-app --all. This automatically commits each phase of the update that is successful to save progress. You can merge all these commits together after if you would like.

Source code in nava/platform/cli/commands/infra/__init__.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@app.command()
def update(
    typer_context: typer.Context,
    project_dir: str,
    template_uri: Annotated[str, opt_template_uri] = DEFAULT_TEMPLATE_URI,
    version: Annotated[str | None, opt_version] = DEFAULT_VERSION,
    data: Annotated[list[str] | None, opt_data] = None,
    answers_only: Annotated[bool, opt_answers_only] = False,
    force: Annotated[bool, opt_force_update] = False,
) -> None:
    """Update base and application infrastructure.

    This effectively just runs `update-base` followed by `update-app --all`.
    This automatically commits each phase of the update that is successful to
    save progress. You can merge all these commits together after if you would
    like.
    """
    ctx = typer_context.ensure_object(CliContext)

    with ctx.handle_exceptions():
        try:
            update_command.update(
                ctx,
                template_uri,
                project_dir,
                version=version if not answers_only else None,
                data=dict_util.from_str_values(data),
                answers_only=answers_only,
                force=force,
            )
        except MergeConflictsDuringUpdateError:
            message = (
                "Merge conflicts found occurred during the update\n"
                "Try running `infra update-base` and `infra update-app` commands separately and resolve conflicts as needed"
            )
            ctx.fail(message)

Update application(s) infrastructure.

Source code in nava/platform/cli/commands/infra/__init__.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
@app.command()
def update_app(
    typer_context: typer.Context,
    project_dir: str,
    app_name: Annotated[list[str] | None, typer.Argument()] = None,
    template_uri: Annotated[str, opt_template_uri] = DEFAULT_TEMPLATE_URI,
    version: Annotated[str | None, opt_version] = DEFAULT_VERSION,
    data: Annotated[list[str] | None, opt_data] = None,
    commit: Annotated[bool, opt_commit] = True,
    all: Annotated[bool, typer.Option("--all", help="Attempt to update all known apps")] = False,
    answers_only: Annotated[bool, opt_answers_only] = False,
    force: Annotated[bool, opt_force_update] = False,
) -> None:
    """Update application(s) infrastructure."""
    ctx = typer_context.ensure_object(CliContext)

    with ctx.handle_exceptions():
        update_command.update_app(
            ctx,
            template_uri,
            project_dir,
            app_names=app_name,
            version=version if not answers_only else None,
            data=dict_util.from_str_values(data),
            commit=commit,
            all=all,
            answers_only=answers_only,
            force=force,
        )

Update base infrastructure.

Source code in nava/platform/cli/commands/infra/__init__.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@app.command()
def update_base(
    typer_context: typer.Context,
    project_dir: str,
    template_uri: Annotated[str, opt_template_uri] = DEFAULT_TEMPLATE_URI,
    version: Annotated[str | None, opt_version] = DEFAULT_VERSION,
    data: Annotated[list[str] | None, opt_data] = None,
    commit: Annotated[bool, opt_commit] = True,
    answers_only: Annotated[bool, opt_answers_only] = False,
    force: Annotated[bool, opt_force_update] = False,
) -> None:
    """Update base infrastructure."""
    ctx = typer_context.ensure_object(CliContext)

    with ctx.handle_exceptions():
        update_command.update_base(
            ctx,
            template_uri,
            project_dir,
            version=version if not answers_only else None,
            data=dict_util.from_str_values(data),
            commit=commit,
            answers_only=answers_only,
            force=force,
        )