Skip to content

Commit 1acd949

Browse files
remove server
1 parent 43a498a commit 1acd949

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

codefresh/cfclient/gitops_environments.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ type GitopsEnvironment struct {
3131
// GitopsCluster represents a cluster within a GitOps environment.
3232
type GitopsEnvironmentCluster struct {
3333
Name string `json:"name"`
34-
Server string `json:"server"`
3534
RuntimeName string `json:"runtimeName"`
3635
Namespaces []string `json:"namespaces"`
3736
}
3837

3938
type GitopsEnvironmentResponse struct {
39+
Errors []GraphQLError `json:"errors,omitempty"`
4040
Data struct {
4141
Environment GitopsEnvironment `json:"environment,omitempty"`
4242
CreateEnvironment GitopsEnvironment `json:"createEnvironment,omitempty"`
@@ -124,6 +124,10 @@ func (client *Client) CreateGitopsEnvironment(environment *GitopsEnvironment) (*
124124
return nil, err
125125
}
126126

127+
if len(gitopsEnvironmentResponse.Errors) > 0 {
128+
return nil, fmt.Errorf("CreateGitopsEnvironment - %s", gitopsEnvironmentResponse.Errors)
129+
}
130+
127131
return &gitopsEnvironmentResponse.Data.CreateEnvironment, nil
128132
}
129133

@@ -161,6 +165,10 @@ func (client *Client) DeleteGitopsEnvironment(id string) (*GitopsEnvironment, er
161165
return nil, err
162166
}
163167

168+
if len(gitopsEnvironmentResponse.Errors) > 0 {
169+
return nil, fmt.Errorf("DeleteGitopsEnvironment - %s", gitopsEnvironmentResponse.Errors)
170+
}
171+
164172
return &gitopsEnvironmentResponse.Data.DeleteEnvironment, nil
165173
}
166174

@@ -190,5 +198,9 @@ func (client *Client) UpdateGitopsEnvironment(environment *GitopsEnvironment) (*
190198
return nil, err
191199
}
192200

201+
if len(gitopsEnvironmentResponse.Errors) > 0 {
202+
return nil, fmt.Errorf("UpdateGitopsEnvironment - %s", gitopsEnvironmentResponse.Errors)
203+
}
204+
193205
return &gitopsEnvironmentResponse.Data.UpdateEnvironment, nil
194206
}

codefresh/cfclient/gql_client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ type GraphQLRequest struct {
1414
Variables map[string]interface{} `json:"variables,omitempty"`
1515
}
1616

17+
type GraphQLError struct {
18+
Message string `json:"message,omitempty"`
19+
Extensions string `json:"extensions,omitempty"`
20+
}
21+
1722
func (client *Client) SendGqlRequest(request GraphQLRequest) ([]byte, error) {
1823
jsonRequest, err := json.Marshal(request)
1924
if err != nil {

codefresh/resource_gitops_environment.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ func resourceGitopsEnvironment() *schema.Resource {
4545
Required: true,
4646
Description: "Target cluster name",
4747
},
48-
"server": {
49-
Type: schema.TypeString,
50-
Optional: true,
51-
Description: "Target cluster server url. Defaults to `https://kubernetes.default.svc` which is the default in-cluster url",
52-
Default: "https://kubernetes.default.svc",
53-
},
5448
"runtime_name": {
5549
Type: schema.TypeString,
5650
Required: true,
@@ -196,7 +190,6 @@ func flattenClusters(clusters []cfclient.GitopsEnvironmentCluster) []map[string]
196190
for _, cluster := range clusters {
197191
m := make(map[string]interface{})
198192
m["name"] = cluster.Name
199-
m["server"] = cluster.Server
200193
m["runtime_name"] = cluster.RuntimeName
201194
m["namespaces"] = cluster.Namespaces
202195
res = append(res, m)
@@ -212,7 +205,6 @@ func expandClusters(list []interface{}) []cfclient.GitopsEnvironmentCluster {
212205
clusterMap := item.(map[string]interface{})
213206
cluster := cfclient.GitopsEnvironmentCluster{
214207
Name: clusterMap["name"].(string),
215-
Server: clusterMap["server"].(string),
216208
RuntimeName: clusterMap["runtime_name"].(string),
217209
Namespaces: datautil.ConvertStringArr(clusterMap["namespaces"].([]interface{})),
218210
}

codefresh/resource_gitops_environment_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func TestAccCodefreshGitopsEnvironmentsResource(t *testing.T) {
2424
"NON_PROD",
2525
[]cfclient.GitopsEnvironmentCluster{{
2626
Name: "in-cluster2",
27-
Server: "https://kubernetes.default.svc",
2827
RuntimeName: "test-runtime",
2928
Namespaces: []string{"test-ns-1", "test-ns2"},
3029
}},
@@ -50,13 +49,11 @@ func TestAccCodefreshGitopsEnvironmentsResource(t *testing.T) {
5049
[]cfclient.GitopsEnvironmentCluster{
5150
{
5251
Name: "in-cluster2",
53-
Server: "https://kubernetes.default.svc",
5452
RuntimeName: "test-runtime",
5553
Namespaces: []string{"test-ns-1", "test-ns2"},
5654
},
5755
{
5856
Name: "in-cluster3",
59-
Server: "https://kubernetes2.default.svc",
6057
RuntimeName: "test-runtime-2",
6158
Namespaces: []string{"test-ns-3"},
6259
},
@@ -115,10 +112,9 @@ func testAccCodefreshGitopsEnvironmentConfig(name, kind string, clusters []cfcli
115112
ns := fmt.Sprintf("[\"%s\"]", strings.Join(c.Namespaces, "\", \""))
116113
block := fmt.Sprintf(` cluster {
117114
name = "%s"
118-
server = "%s"
119115
runtime_name = "%s"
120116
namespaces = %s
121-
}`, c.Name, c.Server, c.RuntimeName, ns)
117+
}`, c.Name, c.RuntimeName, ns)
122118
clusterBlocks = append(clusterBlocks, block)
123119
}
124120
labelsStr := fmt.Sprintf("[\"%s\"]", strings.Join(labelPairs, "\", \""))

0 commit comments

Comments
 (0)