Skip to content
Merged
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
17 changes: 17 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@ on:
- main

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Update docs & licenses
run: hack/update-docs.sh

tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-tags: true
fetch-depth: 0

Expand Down
8 changes: 7 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ builds:
- amd64
- arm64
- arm
main: ./cmd/cs
main: ./cli
binary: cs
ldflags:
- -s -w
- -X github.com/codesphere-cloud/cs-go/pkg/cs.version={{.Version}}
- -X github.com/codesphere-cloud/cs-go/pkg/cs.commit={{.Commit}}
- -X github.com/codesphere-cloud/cs-go/pkg/cs.date={{.Date}}

changelog:
sort: asc
Expand Down
2 changes: 1 addition & 1 deletion .mockery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require-template-schema-exists: true
template: testify
template-schema: '{{.Template}}.schema.json'
packages:
github.com/codesphere-cloud/cs-go/cmd:
github.com/codesphere-cloud/cs-go/cli/cmd:
interfaces:
Client:
Env:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2025 Codesphere Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ endif
${OPENAPI_DIR}/test
make generate


release-binaries:
goreleaser release --verbose --skip=validate --skip=publish --clean

generate-api: generate-client format

.PHONY: docs
Expand All @@ -56,7 +58,7 @@ docs:
go run -ldflags="-X 'github.com/codesphere-cloud/cs-go/pkg/out.binName=cs'" hack/gendocs/main.go
cp docs/{cs,README}.md

generate-license:
generate-license: generate
go-licenses report --template .NOTICE.template ./... > NOTICE
copywrite headers apply

Expand Down
18 changes: 18 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ Copyright (c) Codesphere Inc.

This project includes code licensed under the following terms:

----------
Module: github.com/codesphere-cloud/cs-go/pkg/tmpl
Version: Unknown
License: Apache-2.0
License URL: https://github.com/codesphere-cloud/cs-go/blob/HEAD/pkg/tmpl/LICENSE

----------
Module: github.com/cpuguy83/go-md2man/v2/md2man
Version: v2.0.6
License: MIT
License URL: https://github.com/cpuguy83/go-md2man/blob/v2.0.6/LICENSE.md

----------
Module: github.com/davecgh/go-spew/spew
Version: v1.1.1
Expand Down Expand Up @@ -33,6 +45,12 @@ Version: v0.4.7
License: MIT
License URL: https://github.com/rivo/uniseg/blob/v0.4.7/LICENSE.txt

----------
Module: github.com/russross/blackfriday/v2
Version: v2.1.0
License: BSD-2-Clause
License URL: https://github.com/russross/blackfriday/blob/v2.1.0/LICENSE.txt

----------
Module: github.com/spf13/cobra
Version: v1.9.1
Expand Down
41 changes: 41 additions & 0 deletions cli/cmd/licenses.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright © 2025 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
_ "embed"
"fmt"

"github.com/codesphere-cloud/cs-go/pkg/tmpl"
"github.com/spf13/cobra"
)

// LicensesCmd represents the licenses command
type LicensesCmd struct {
cmd *cobra.Command
}

func (c *LicensesCmd) RunE(_ *cobra.Command, args []string) error {
fmt.Println("Codesphere CLI License:")
fmt.Println(tmpl.License())

fmt.Println("=================================")

fmt.Println("Codesphere CLI licenses included work:")
fmt.Println(tmpl.Notice())

return nil
}

func AddLicensesCmd(rootCmd *cobra.Command) {
licenses := LicensesCmd{
cmd: &cobra.Command{
Use: "licenses",
Short: "Print license information",
Long: `Print information about the Codesphere CLI license and open source licenses of dependencies.`,
},
}
rootCmd.AddCommand(licenses.cmd)
licenses.cmd.RunE = licenses.RunE
}
4 changes: 2 additions & 2 deletions cli/cmd/list-teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func addListTeamsCmd(p *cobra.Command, opts GlobalOptions) {
Use: "teams",
Short: "list teams",
Long: `list teams available in Codesphere`,
Example: out.FormatExampleCommands("list teams", map[string]string{
"": "List all teams",
Example: out.FormatExampleCommands("list teams", []out.Example{
{Desc: "List all teams"},
}),
},
opts: opts,
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/list-workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func addListWorkspacesCmd(p *cobra.Command, opts GlobalOptions) {
Use: "workspaces",
Short: "list workspaces",
Long: `list workspaces available in Codesphere`,
Example: out.FormatExampleCommands("list workspaces", map[string]string{
"--team-id <team-id>": "List all workspaces",
Example: out.FormatExampleCommands("list workspaces", []out.Example{
{Cmd: "--team-id <team-id>", Desc: "List all workspaces"},
}),
},
Opts: opts,
Expand Down
6 changes: 3 additions & 3 deletions cli/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ type ListCmd struct {
cmd *cobra.Command
}

func addListCmd(rootCmd *cobra.Command, opts GlobalOptions) {
func AddListCmd(rootCmd *cobra.Command, opts GlobalOptions) {
l := ListCmd{
cmd: &cobra.Command{
Use: "list",
Short: "list resources",
Long: `list resources available in Codesphere`,
Example: out.FormatExampleCommands("list", map[string]string{
"workspaces": "List all workspaces",
Example: out.FormatExampleCommands("list", []out.Example{
{Cmd: "workspaces", Desc: "List all workspaces"},
}),
},
}
Expand Down
10 changes: 5 additions & 5 deletions cli/cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type SSE struct {
data string
}

func addLogCmd(rootCmd *cobra.Command, opts GlobalOptions) {
func AddLogCmd(rootCmd *cobra.Command, opts GlobalOptions) {
logCmd := LogCmd{
cmd: &cobra.Command{
Use: "log",
Expand All @@ -65,10 +65,10 @@ all replicas of that server.

If you provide a specific replica id, it will return the logs of
that replica only.`,
Example: out.FormatExampleCommands("log", map[string]string{
"-w 637128 -s app": "Get logs from a server",
"-w 637128": "Get all logs of all servers",
"-w 637128 -r workspace-213d7a8c-48b4-42e2-8f70-c905ab04abb5-58d657cdc5-m8rrp": "Get logs from a replica",
Example: out.FormatExampleCommands("log", []out.Example{
{Cmd: "-w 637128 -s app", Desc: "Get logs from a server"},
{Cmd: "-w 637128", Desc: "Get all logs of all servers"},
{Cmd: "-w 637128 -r workspace-213d7a8c-48b4-42e2-8f70-c905ab04abb5-58d657cdc5-m8rrp", Desc: "Get logs from a replica"},
}),
},
opts: opts,
Expand Down
46 changes: 0 additions & 46 deletions cli/cmd/mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ func GetRootCmd() *cobra.Command {
}

opts := GlobalOptions{Env: cs.NewEnv()}
addLogCmd(rootCmd, opts)
addListCmd(rootCmd, opts)
addSetEnvVarCmd(rootCmd, opts)
AddLogCmd(rootCmd, opts)
AddListCmd(rootCmd, opts)
AddSetEnvVarCmd(rootCmd, opts)
AddVersionCmd(rootCmd)
AddLicensesCmd(rootCmd)

opts.ApiUrl = rootCmd.PersistentFlags().StringP("api", "a", "https://codesphere.com/api", "URL of Codesphere API (can also be CS_API)")
opts.TeamId = rootCmd.PersistentFlags().IntP("team", "t", -1, "Team ID (relevant for some commands, can also be CS_TEAM_ID)")
Expand Down
8 changes: 4 additions & 4 deletions cli/cmd/set-env-vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ type SetEnvVarOptions struct {
EnvVar *[]string
}

func addSetEnvVarCmd(p *cobra.Command, opts GlobalOptions) {
func AddSetEnvVarCmd(p *cobra.Command, opts GlobalOptions) {
l := SetEnvVarCmd{
cmd: &cobra.Command{
Use: "set-env",
Short: "set env vars",
Long: `set environment variables for your workspace`,
Example: out.FormatExampleCommands("set-env", map[string]string{
"--workspace-id <workspace-id> --env foo=bar": "Set single environment variable",
"--workspace-id <workspace-id> --env foo=bar --env hello=world": "Set multiple environment variables",
Example: out.FormatExampleCommands("set-env", []out.Example{
{Cmd: "--workspace-id <workspace-id> --env foo=bar", Desc: "Set single environment variable"},
{Cmd: "--workspace-id <workspace-id> --env foo=bar --env hello=world", Desc: "Set multiple environment variables"},
}),
},
Opts: SetEnvVarOptions{GlobalOptions: opts},
Expand Down
36 changes: 36 additions & 0 deletions cli/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright © 2025 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"

"github.com/codesphere-cloud/cs-go/pkg/cs"
"github.com/spf13/cobra"
)

// VersionCmd represents the version command
type VersionCmd struct {
cmd *cobra.Command
}

func (c *VersionCmd) RunE(_ *cobra.Command, args []string) error {
fmt.Printf("Codesphere CLI version: %s\n", cs.Version())
fmt.Printf("Commit: %s\n", cs.Commit())
fmt.Printf("Build Date: %s\n", cs.BuildDate())

return nil
}

func AddVersionCmd(rootCmd *cobra.Command) {
version := VersionCmd{
cmd: &cobra.Command{
Use: "version",
Short: "Print version",
Long: `Prints current version of Codesphere CLI.`,
},
}
rootCmd.AddCommand(version.cmd)
version.cmd.RunE = version.RunE
}
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ Manage and debug resources deployed in Codesphere via command line.

### SEE ALSO

* [cs licenses](cs_licenses.md) - Print license information
* [cs list](cs_list.md) - list resources
* [cs log](cs_log.md) - Retrieve Run logs from services
* [cs set-env](cs_set-env.md) - set env vars
* [cs version](cs_version.md) - A brief description of your command

###### Auto generated by spf13/cobra on 3-Jun-2025
2 changes: 2 additions & 0 deletions docs/cs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ Manage and debug resources deployed in Codesphere via command line.

### SEE ALSO

* [cs licenses](cs_licenses.md) - Print license information
* [cs list](cs_list.md) - list resources
* [cs log](cs_log.md) - Retrieve Run logs from services
* [cs set-env](cs_set-env.md) - set env vars
* [cs version](cs_version.md) - A brief description of your command

###### Auto generated by spf13/cobra on 3-Jun-2025
31 changes: 31 additions & 0 deletions docs/cs_licenses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## cs licenses

Print license information

### Synopsis

Print information about the Codesphere CLI license and open source licenses of dependencies.

```
cs licenses [flags]
```

### Options

```
-h, --help help for licenses
```

### Options inherited from parent commands

```
-a, --api string URL of Codesphere API (can also be CS_API) (default "https://codesphere.com/api")
-t, --team int Team ID (relevant for some commands, can also be CS_TEAM_ID) (default -1)
-w, --workspace int Workspace ID (relevant for some commands, can also be CS_WORKSPACE_ID) (default -1)
```

### SEE ALSO

* [cs](cs.md) - The codesphere CLI

###### Auto generated by spf13/cobra on 3-Jun-2025
Loading