Skip to content

Commit

Permalink
Merge pull request #12 from stefanprodan/mod-push-pull
Browse files Browse the repository at this point in the history
Make push/pull sub-commands of `timoni mod`
  • Loading branch information
stefanprodan authored Feb 22, 2023
2 parents 910b9d8 + 5cc843f commit af17583
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: make install
- name: Push
run: |
timoni push ./examples/podinfo oci://localhost:5000/podinfo \
timoni mod push ./examples/podinfo oci://localhost:5000/podinfo \
--version 1.0.0
- name: Template
run: |
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ A module example can be found at [examples/podinfo](examples/podinfo).

Commands for working with local modules:

- `timoni lint <path/to/module>`
- `timoni mod init <module-name>`
- `timoni mod lint <path/to/module>`
- `timoni build <name> <path/to/module> -n <namespace>`
- `timoni apply <name> <path/to/module> -f <path/to/values.cue> --dry-run --diff`

Timoni modules are distributed as OCI artifacts and can be stored in container registries.

Commands for working with remote modules:

- `timoni push <path/to/module> oci://<module-url> -v <semver>`
- `timoni pull oci://<module-url> -v <semver> -o <path/to/module>`
- `timoni mod push <path/to/module> oci://<module-url> -v <semver>`
- `timoni mod pull oci://<module-url> -v <semver> -o <path/to/module>`

To learn more about modules, please read the [docs](https://timoni.sh/#timoni-modules).

Expand All @@ -90,9 +91,8 @@ values: {

Commands for working with instances:

- `timoni install <name> oci://<module-url> -v <semver> -n <namespace>`
- `timoni upgrade <name> oci://<module-url> -v <semver> -f <path/to/values.cue>`
- `timoni uninstall <name> -n <namespace>`
- `timoni apply <name> oci://<module-url> -v <semver> -f <path/to/values.cue>`
- `timoni delete <name> -n <namespace>`
- `timoni list -n <namespace>`
- `timoni inspect [module|values|resources] <name>`

Expand Down
2 changes: 1 addition & 1 deletion cmd/timoni/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestInspect(t *testing.T) {

// Package the module as an OCI artifact and push it to registry
_, err := executeCommand(fmt.Sprintf(
"push %s %s -v %s",
"mod push %s %s -v %s",
modPath,
modURL,
modVer,
Expand Down
4 changes: 2 additions & 2 deletions cmd/timoni/pull.go → cmd/timoni/mod_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var pullCmd = &cobra.Command{
Long: `The pull command downloads the module from a container registry and
extract its contents the specified directory.`,
Example: ` # Pull a module version from GitHub Container Registry
timoni pull oci://ghcr.io/org/manifests/app --version 1.0.0 \
timoni mod pull oci://ghcr.io/org/manifests/app --version 1.0.0 \
--output ./path/to/module \
--creds timoni:$GITHUB_TOKEN
`,
Expand All @@ -54,7 +54,7 @@ func init() {
"The directory path where the module content should be extracted.")
pullCmd.Flags().Var(&pullArgs.creds, pullArgs.creds.Type(), pullArgs.creds.Description())

rootCmd.AddCommand(pullCmd)
modCmd.AddCommand(pullCmd)
}

func pullCmdRun(cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 2 additions & 2 deletions cmd/timoni/pull_test.go → cmd/timoni/mod_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Test_Pull(t *testing.T) {

// Package the module as an OCI artifact and push it to registry
_, err := executeCommand(fmt.Sprintf(
"push %s oci://%s -v %s",
"mod push %s oci://%s -v %s",
modPath,
modURL,
modVer,
Expand All @@ -45,7 +45,7 @@ func Test_Pull(t *testing.T) {
// Pull the OCI artifact from registry and extract the module to tmp
tmpDir := t.TempDir()
_, err = executeCommand(fmt.Sprintf(
"pull oci://%s -v %s -o %s",
"mod pull oci://%s -v %s -o %s",
modURL,
modVer,
tmpDir,
Expand Down
6 changes: 3 additions & 3 deletions cmd/timoni/push.go → cmd/timoni/mod_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ var pushCmd = &cobra.Command{
container registry using the version as the image tag.`,
Example: ` # Push a module to Docker Hub using the credentials from '~/.docker/config.json'
echo $DOCKER_PAT | docker login --username timoni --password-stdin
timoni push ./path/to/module oci://docker.io/org/app \
timoni mod push ./path/to/module oci://docker.io/org/app \
--source="$(git config --get remote.origin.url)" \
--version=1.0.0
# Push a module to GitHub Container Registry using a GitHub token
timoni push ./path/to/module oci://ghcr.io/org/modules/app \
timoni mod push ./path/to/module oci://ghcr.io/org/modules/app \
--source="$(git config --get remote.origin.url)" \
--version=1.0.0 \
--creds timoni:$GITHUB_TOKEN
Expand All @@ -71,7 +71,7 @@ func init() {
pushCmd.Flags().StringVarP(&pushArgs.output, "output", "o", "",
"The format in which the artifact digest should be printed, can be 'yaml' or 'json'.")

rootCmd.AddCommand(pushCmd)
modCmd.AddCommand(pushCmd)
}

func pushCmdRun(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/timoni/push_test.go → cmd/timoni/mod_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Test_Push(t *testing.T) {

// Push the module to registry
output, err := executeCommand(fmt.Sprintf(
"push %s oci://%s -v %s",
"mod push %s oci://%s -v %s",
modPath,
modURL,
modVer,
Expand Down
10 changes: 5 additions & 5 deletions docs/github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint
run: |
timoni lint ./modules/my-module
- name: Test build
timoni mod lint ./modules/my-module
- name: Test instance build
run: |
timoni build -n testing test ./modules/my-module
- name: Push
run: |
timoni push ./modules/my-module \
timoni mod push ./modules/my-module \
oci://ghcr.io/${{ github.repository_owner }}/modules/my-module \
--version ${{ github.ref_name }} \
--creds ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -93,13 +93,13 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push
run: |
timoni push ./modules/my-module \
timoni mod push ./modules/my-module \
oci://docker.io/my-org/my-module \
--version ${{ github.ref_name }}
- name: Pull
run: |
mkdir -p /tmp/my-module
timoni pull oci://docker.io/my-org/my-module \
timoni mod pull oci://docker.io/my-org/my-module \
--version ${{ github.ref_name }} \
--output /tmp/my-module
```
Expand Down
8 changes: 5 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Module structure:

Commands for working with local modules:

- `timoni lint <path/to/module>`
- `timoni mod init <module-name>`
- `timoni mod lint <path/to/module>`
- `timoni build <name> <path/to/module> -n <namespace>`
- `timoni apply <name> <path/to/module> -f <path/to/values.cue> --dry-run --diff`

Expand All @@ -60,8 +61,8 @@ the version of a module is used as the OCI artifact tag.

Commands for working with remote modules:

- `timoni push <path/to/module> oci://<module-url> -v <semver>`
- `timoni pull oci://<module-url> -v <semver> -o <path/to/module>`
- `timoni mod push <path/to/module> oci://<module-url> -v <semver>`
- `timoni mod pull oci://<module-url> -v <semver> -o <path/to/module>`

Timoni produces artifacts compatible with Docker Hub, GitHub Container Registry,
Azure Container Registry, Amazon Elastic Container Registry, Google Artifact Registry,
Expand Down Expand Up @@ -94,6 +95,7 @@ Commands for working with module instances:
- `timoni upgrade <name> oci://<module-url> -v <semver> -f <path/to/values.cue>`
- `timoni uninstall <name> -n <namespace>`
- `timoni list -n <namespace>`
- `timoni inspect [module|values|resources] <name>`

The `install` and `upgrade` commands are aliases of `timoni apply`.
To apply the Kubernetes resources belonging to a module instance,
Expand Down
7 changes: 5 additions & 2 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ waiting for 3 resource(s) to become ready...
all resources are ready
```

## List and inspect instances

You can list all instances in a cluster with `timoni ls -A`.

To get more information on an instance, you can use the `timoni inspect` sub-commands:

```console
Expand All @@ -60,7 +63,7 @@ version: 6.3.3

To learn more about the available commands, use `timoni inspect --help`.

## Configure an module instance
## Configure a module instance

To customise an instance, you can supply the configuration values using `values.cue` files.

Expand All @@ -81,7 +84,7 @@ Apply the config to the podinfo module to perform an upgrade:

```shell
timoni -n test apply podinfo \
oci://ghcr.io/stefanprodan/modules/podinfo -v 6.3.3 \
oci://ghcr.io/stefanprodan/modules/podinfo -v 6.3.4 \
--values qos-values.cue
```

Expand Down

0 comments on commit af17583

Please sign in to comment.