Skip to content

Commit a962647

Browse files
authored
Merge pull request #37 from nginxinc/mrajagopal
Issue 36: Add support for NGF - NGINX Gateway Fabric
2 parents e168617 + 5792264 commit a962647

File tree

6 files changed

+578
-397
lines changed

6 files changed

+578
-397
lines changed

cmd/nginx-supportpkg.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/nginxinc/nginx-k8s-supportpkg/pkg/version"
2626
"github.com/spf13/cobra"
2727
"os"
28+
"slices"
2829
)
2930

3031
func Execute() {
@@ -50,9 +51,11 @@ func Execute() {
5051

5152
switch product {
5253
case "nic":
53-
jobList = jobs.NICJobList()
54+
jobList = slices.Concat(jobs.CommonJobList(), jobs.NICJobList())
55+
case "ngf":
56+
jobList = slices.Concat(jobs.CommonJobList(), jobs.NGFJobList())
5457
default:
55-
fmt.Printf("Error: product must be in the following list: [nic]\n")
58+
fmt.Printf("Error: product must be in the following list: [nic, ngf]\n")
5659
os.Exit(1)
5760
}
5861

@@ -101,8 +104,8 @@ func Execute() {
101104
"Usage:" +
102105
"\n nginx-supportpkg -h|--help" +
103106
"\n nginx-supportpkg -v|--version" +
104-
"\n nginx-supportpkg [-n|--namespace] ns1 [-n|--namespace] ns2 [-p|--product] nic" +
105-
"\n nginx-supportpkg [-n|--namespace] ns1,ns2 [-p|--product] nic \n")
107+
"\n nginx-supportpkg [-n|--namespace] ns1 [-n|--namespace] ns2 [-p|--product] [nic,ngf]" +
108+
"\n nginx-supportpkg [-n|--namespace] ns1,ns2 [-p|--product] [nic,ngf] \n")
106109

107110
if err := rootCmd.Execute(); err != nil {
108111
fmt.Println(err)

pkg/crds/crd.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Crd struct {
2424
Version string
2525
}
2626

27-
func GetCRDList() []Crd {
27+
func GetNICCRDList() []Crd {
2828
crdList := []Crd{
2929
{
3030
Resource: "apdoslogconfs",
@@ -84,3 +84,29 @@ func GetCRDList() []Crd {
8484
}
8585
return crdList
8686
}
87+
88+
func GetNGFCRDList() []Crd {
89+
crdList := []Crd{
90+
{
91+
Resource: "clientsettingspolicies",
92+
Group: "gateway.nginx.org",
93+
Version: "v1alpha1",
94+
},
95+
{
96+
Resource: "nginxgateways",
97+
Group: "gateway.nginx.org",
98+
Version: "v1alpha1",
99+
},
100+
{
101+
Resource: "nginxproxies",
102+
Group: "gateway.nginx.org",
103+
Version: "v1alpha1",
104+
},
105+
{
106+
Resource: "observabilitypolicies",
107+
Group: "gateway.nginx.org",
108+
Version: "v1alpha1",
109+
},
110+
}
111+
return crdList
112+
}

pkg/data_collector/data_collector.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,19 @@ func (c *DataCollector) WrapUp(product string) (string, error) {
199199
return tarballName, nil
200200
}
201201

202-
func (c *DataCollector) PodExecutor(namespace string, pod string, command []string, ctx context.Context) ([]byte, error) {
202+
func (c *DataCollector) PodExecutor(namespace string, pod string, container string, command []string, ctx context.Context) ([]byte, error) {
203203
req := c.K8sCoreClientSet.CoreV1().RESTClient().Post().
204204
Namespace(namespace).
205205
Resource("pods").
206206
Name(pod).
207207
SubResource("exec").
208208
VersionedParams(&corev1.PodExecOptions{
209-
Command: command,
210-
Stdin: false,
211-
Stdout: true,
212-
Stderr: true,
213-
TTY: true,
209+
Command: command,
210+
Container: container,
211+
Stdin: false,
212+
Stdout: true,
213+
Stderr: true,
214+
TTY: true,
214215
}, scheme.ParameterCodec)
215216

216217
exec, err := remotecommand.NewSPDYExecutor(c.K8sRestConfig, "POST", req.URL())
@@ -240,7 +241,6 @@ func (c *DataCollector) QueryCRD(crd crds.Crd, namespace string, ctx context.Con
240241
c.K8sRestConfig.NegotiatedSerializer = negotiatedSerializer
241242

242243
client, err := rest.RESTClientFor(c.K8sRestConfig)
243-
244244
if err != nil {
245245
return nil, err
246246
}

0 commit comments

Comments
 (0)