Skip to content

Commit

Permalink
Add display name for asset (#7893)
Browse files Browse the repository at this point in the history
* Use new rafter version

* Add DisplayName to rafter and schema, add test

* Format + test
  • Loading branch information
akucharska committed Apr 6, 2020
1 parent 1cb59e9 commit 0f106bc
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 36 deletions.
4 changes: 2 additions & 2 deletions components/console-backend-service/Gopkg.lock

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

2 changes: 1 addition & 1 deletion components/console-backend-service/Gopkg.toml
Expand Up @@ -47,7 +47,7 @@ required = [

[[constraint]]
name="github.com/kyma-project/rafter"
revision = "1b5e6fe41dabafd462de0cfce628184173ce01a3"
revision = "a0157e52e150b26f63c2ddc9f4e63c0cb7650ac7"

[[constraint]]
name="github.com/kyma-project/helm-broker"
Expand Down
Expand Up @@ -37,11 +37,12 @@ func (c *assetConverter) ToGQL(item *v1beta1.Asset) (*gqlschema.Asset, error) {
}

asset := gqlschema.Asset{
Name: item.Name,
Namespace: item.Namespace,
Type: item.Labels[TypeLabel],
Status: status,
Parameters: parameters,
Name: item.Name,
Namespace: item.Namespace,
Type: item.Labels[TypeLabel],
Status: status,
Parameters: parameters,
DisplayName: item.Spec.DisplayName,
}

return &asset, nil
Expand Down
Expand Up @@ -28,7 +28,8 @@ func TestAssetConverter_ToGQL(t *testing.T) {
Reason: "ExampleReason",
Message: "ExampleMessage",
},
Parameters: gqlschema.JSON{"complex": map[string]interface{}{"data": "true"}, "json": "true"},
Parameters: gqlschema.JSON{"complex": map[string]interface{}{"data": "true"}, "json": "true"},
DisplayName: "ExampleDisplayName",
}

result, err := converter.ToGQL(item)
Expand Down Expand Up @@ -107,7 +108,8 @@ func fixAsset() *v1beta1.Asset {
BucketRef: v1beta1.AssetBucketRef{
Name: "ExampleBucketRef",
},
Parameters: &runtime.RawExtension{Raw: []byte(`{"json":"true","complex":{"data":"true"}}`)},
Parameters: &runtime.RawExtension{Raw: []byte(`{"json":"true","complex":{"data":"true"}}`)},
DisplayName: "ExampleDisplayName",
},
},
Status: v1beta1.AssetStatus{
Expand Down
Expand Up @@ -37,10 +37,11 @@ func (c *clusterAssetConverter) ToGQL(item *v1beta1.ClusterAsset) (*gqlschema.Cl
}

clusterAsset := gqlschema.ClusterAsset{
Name: item.Name,
Type: item.Labels[TypeLabel],
Status: status,
Parameters: parameters,
Name: item.Name,
Type: item.Labels[TypeLabel],
Status: status,
Parameters: parameters,
DisplayName: item.Spec.DisplayName,
}

return &clusterAsset, nil
Expand Down
Expand Up @@ -27,7 +27,8 @@ func TestClusterAssetConverter_ToGQL(t *testing.T) {
Reason: "ExampleReason",
Message: "ExampleMessage",
},
Parameters: gqlschema.JSON{"complex": map[string]interface{}{"data": "true"}, "json": "true"},
Parameters: gqlschema.JSON{"complex": map[string]interface{}{"data": "true"}, "json": "true"},
DisplayName: "ExampleDisplayName",
}

result, err := converter.ToGQL(item)
Expand Down Expand Up @@ -105,7 +106,8 @@ func fixClusterAsset() *v1beta1.ClusterAsset {
BucketRef: v1beta1.AssetBucketRef{
Name: "ExampleBucketRef",
},
Parameters: &runtime.RawExtension{Raw: []byte(`{"json":"true","complex":{"data":"true"}}`)},
Parameters: &runtime.RawExtension{Raw: []byte(`{"json":"true","complex":{"data":"true"}}`)},
DisplayName: "ExampleDisplayName",
},
},
Status: v1beta1.ClusterAssetStatus{
Expand Down
11 changes: 6 additions & 5 deletions components/console-backend-service/internal/gqlschema/asset.go
@@ -1,9 +1,10 @@
package gqlschema

type Asset struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Type string `json:"type"`
Status AssetStatus `json:"status"`
Parameters JSON `json:"parameters"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Type string `json:"type"`
Status AssetStatus `json:"status"`
Parameters JSON `json:"parameters"`
DisplayName string `json:"displayName"`
}
@@ -1,8 +1,9 @@
package gqlschema

type ClusterAsset struct {
Name string `json:"name"`
Type string `json:"type"`
Status AssetStatus `json:"status"`
Parameters JSON `json:"parameters"`
Name string `json:"name"`
Type string `json:"type"`
Status AssetStatus `json:"status"`
Parameters JSON `json:"parameters"`
DisplayName string `json:"displayName"`
}
Expand Up @@ -40,6 +40,7 @@ type Asset {
type: String!
files(filterExtensions: [String!]): [File!]!
status: AssetStatus!
displayName: String
}

type AssetEvent {
Expand All @@ -53,6 +54,7 @@ type ClusterAsset {
type: String!
files(filterExtensions: [String!]): [File!]!
status: AssetStatus!
displayName: String
}

type ClusterAssetEvent {
Expand Down
92 changes: 81 additions & 11 deletions components/console-backend-service/internal/gqlschema/schema_gen.go

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

0 comments on commit 0f106bc

Please sign in to comment.