Skip to content

Commit 1766067

Browse files
authored
Kr/upgrade opslevel go 2025 (#402)
* Upgrade CLI to opslevel-go 2025 * Cursor’s changed to upgrade opslevel-go * copilot review feedback * run task fix * Apply suggestions from code review * update submodule of opslevel-go * Fix lint * Fix Filters * Fix Mapstructure problem on event integrations * Setup e2e tests for some resources (#404) * Setup e2e tests for domain * PR feedback * Checkpoint * Expand test coverage * Add system test * First pass at fixing example command * more tweaks * Fix CI * Fix up all example commands * More fixes * fixes * more fixes for removal of old code * Update Taskfile.yml * fix e2e integration tests * few more tweaks after testing manually
1 parent 30b973f commit 1766067

43 files changed

Lines changed: 933 additions & 218 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Taskfile.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ tasks:
5656
cmds:
5757
- go test -race -coverprofile=coverage.txt -covermode=atomic -v ./cmd/... {{ .CLI_ARGS }}
5858

59+
test-e2e:
60+
desc: Run end to end Integration tests
61+
dir: "{{.SRC_DIR}}"
62+
cmds:
63+
- go test -v ./e2e/... {{ .CLI_ARGS }}
64+
5965
update-opslevel-go:
6066
desc: Update opslevel-go version to latest release
6167
dir: "{{.SRC_DIR}}"

src/cmd/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66

7-
"github.com/opslevel/opslevel-go/v2024"
7+
"github.com/opslevel/opslevel-go/v2025"
88

99
"github.com/opslevel/cli/common"
1010

src/cmd/action.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66

7-
"github.com/opslevel/opslevel-go/v2024"
7+
"github.com/opslevel/opslevel-go/v2025"
88

99
"github.com/opslevel/cli/common"
1010
"github.com/spf13/cobra"
@@ -17,7 +17,16 @@ var exampleActionCmd = &cobra.Command{
1717
Short: "Example action",
1818
Long: `Example action`,
1919
Run: func(cmd *cobra.Command, args []string) {
20-
fmt.Println(getExample[opslevel.CustomActionsWebhookActionCreateInput]())
20+
fmt.Println(getExample(opslevel.CustomActionsWebhookActionCreateInput{
21+
Name: "example_name",
22+
Description: opslevel.RefOf("example_description"),
23+
WebhookUrl: "example_webhook_url",
24+
HttpMethod: opslevel.CustomActionsHttpMethodEnumPost,
25+
Headers: &opslevel.JSON{
26+
"example_header": "example_value",
27+
},
28+
LiquidTemplate: opslevel.RefOf("example_liquid_template"),
29+
}))
2130
},
2231
}
2332

@@ -58,7 +67,7 @@ EOF`,
5867
cobra.CheckErr(err)
5968
result, err := getClientGQL().CreateWebhookAction(*input)
6069
cobra.CheckErr(err)
61-
fmt.Printf("created webhook action: %s\n", result.Id)
70+
fmt.Printf("created webhook action: %s\n", string(result.CustomActionsId.Id))
6271
default:
6372
err := fmt.Errorf("unknown action type: '%s'", actionType)
6473
cobra.CheckErr(err)
@@ -94,7 +103,7 @@ var listActionCmd = &cobra.Command{
94103
} else {
95104
w := common.NewTabWriter("ID", "NAME", "HTTP_METHOD", "WEBHOOK_URL")
96105
for _, item := range list {
97-
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", item.Id, item.Name, item.HTTPMethod, item.WebhookURL)
106+
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", string(item.CustomActionsId.Id), item.Name, item.HttpMethod, item.WebhookUrl)
98107
}
99108
w.Flush()
100109
}

src/cmd/alias.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"slices"
77
"strings"
88

9-
"github.com/opslevel/opslevel-go/v2024"
9+
"github.com/opslevel/opslevel-go/v2025"
1010
"github.com/rs/zerolog/log"
1111
"github.com/spf13/cobra"
1212
)
@@ -16,7 +16,10 @@ var exampleAliasCmd = &cobra.Command{
1616
Short: "Example alias",
1717
Long: `Example alias`,
1818
Run: func(cmd *cobra.Command, args []string) {
19-
fmt.Println(getExample[opslevel.AliasCreateInput]())
19+
fmt.Println(getExample(opslevel.AliasCreateInput{
20+
OwnerId: opslevel.ID("Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"),
21+
Alias: "example_alias",
22+
}))
2023
},
2124
}
2225

src/cmd/check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"slices"
77

8-
"github.com/opslevel/opslevel-go/v2024"
8+
"github.com/opslevel/opslevel-go/v2025"
99

1010
"github.com/opslevel/cli/common"
1111
"github.com/rs/zerolog/log"

src/cmd/dependency.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package cmd
33
import (
44
"fmt"
55

6-
"github.com/opslevel/opslevel-go/v2024"
6+
"github.com/opslevel/opslevel-go/v2025"
77
"github.com/spf13/cobra"
88
)
99

@@ -20,7 +20,13 @@ var exampleServiceDependencyCmd = &cobra.Command{
2020
Short: "Example service dependency",
2121
Long: `Example service dependency`,
2222
Run: func(cmd *cobra.Command, args []string) {
23-
fmt.Println(getExample[opslevel.ServiceDependencyCreateInput]())
23+
fmt.Println(getExample(opslevel.ServiceDependencyCreateInput{
24+
DependencyKey: opslevel.ServiceDependencyKey{
25+
SourceIdentifier: opslevel.NewIdentifier("example_source"),
26+
DestinationIdentifier: opslevel.NewIdentifier("example_destination"),
27+
},
28+
Notes: opslevel.RefOf("example_notes"),
29+
}))
2430
},
2531
}
2632

src/cmd/deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"time"
77

8-
"github.com/opslevel/opslevel-go/v2024"
8+
"github.com/opslevel/opslevel-go/v2025"
99

1010
"github.com/creasty/defaults"
1111
"github.com/go-git/go-git/v5"

src/cmd/document.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"strings"
77

8-
"github.com/opslevel/opslevel-go/v2024"
8+
"github.com/opslevel/opslevel-go/v2025"
99

1010
"github.com/rs/zerolog/log"
1111
"github.com/spf13/cobra"

src/cmd/domain.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99

1010
"github.com/opslevel/cli/common"
11-
"github.com/opslevel/opslevel-go/v2024"
11+
"github.com/opslevel/opslevel-go/v2025"
1212
"github.com/spf13/cobra"
1313
)
1414

@@ -17,7 +17,12 @@ var exampleDomainCmd = &cobra.Command{
1717
Short: "Example Domain",
1818
Long: `Example Domain`,
1919
Run: func(cmd *cobra.Command, args []string) {
20-
fmt.Println(getExample[opslevel.DomainInput]())
20+
fmt.Println(getExample(opslevel.DomainInput{
21+
Name: opslevel.RefOf("example_name"),
22+
Description: opslevel.RefOf("example_description"),
23+
OwnerId: opslevel.RefOf(opslevel.ID("Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk")),
24+
Note: opslevel.RefOf("example_note"),
25+
}))
2126
},
2227
}
2328

src/cmd/example.go

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cmd
33
import (
44
"encoding/json"
55

6-
"github.com/opslevel/opslevel-go/v2024"
76
"github.com/spf13/cobra"
87
"github.com/spf13/viper"
98
"gopkg.in/yaml.v2"
@@ -17,35 +16,16 @@ var exampleCmd = &cobra.Command{
1716
Long: "Examples of OpsLevel resources in different formats",
1817
}
1918

20-
func getExample[T any]() string {
19+
func getExample[T any](v T) string {
20+
var out []byte
21+
var err error
2122
if exampleIsJson {
22-
return getJson[T]()
23+
out, err = json.Marshal(v)
24+
} else {
25+
out, err = yaml.Marshal(v)
2326
}
24-
return getYaml[T]()
25-
}
26-
27-
func getJson[T any]() string {
28-
var (
29-
out []byte
30-
err error
31-
)
32-
t := opslevel.NewExampleOf[T]()
33-
out, err = json.Marshal(t)
34-
if err != nil {
35-
panic("unexpected error getting example json")
36-
}
37-
return string(out)
38-
}
39-
40-
func getYaml[T any]() string {
41-
var (
42-
out []byte
43-
err error
44-
)
45-
t := opslevel.NewExampleOf[T]()
46-
out, err = yaml.Marshal(t)
4727
if err != nil {
48-
panic("unexpected error getting example yaml")
28+
panic("unexpected error getting example")
4929
}
5030
return string(out)
5131
}

0 commit comments

Comments
 (0)