github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/provisioner/query.go (about) 1 package provisioner 2 3 import "fmt" 4 5 type queryProvider struct{} 6 7 func (qp queryProvider) provisionRuntime(config string) string { 8 return fmt.Sprintf(`mutation { 9 result: provisionRuntime(config: %s) { 10 %s 11 } 12 }`, config, operationStatusData()) 13 } 14 15 func (qp queryProvider) upgradeRuntime(runtimeID string, config string) string { 16 return fmt.Sprintf(`mutation { 17 result: upgradeRuntime(id: "%s", config: %s) { 18 %s 19 } 20 }`, runtimeID, config, operationStatusData()) 21 } 22 23 func (qp queryProvider) upgradeShoot(runtimeID string, config string) string { 24 return fmt.Sprintf(`mutation { 25 result: upgradeShoot(id: "%s", config: %s) { 26 %s 27 } 28 }`, runtimeID, config, operationStatusData()) 29 } 30 31 func (qp queryProvider) deprovisionRuntime(runtimeID string) string { 32 return fmt.Sprintf(`mutation { 33 result: deprovisionRuntime(id: "%s") 34 }`, runtimeID) 35 } 36 37 func (qp queryProvider) reconnectRuntimeAgent(runtimeID string) string { 38 return fmt.Sprintf(`mutation { 39 result: reconnectRuntimeAgent(id: "%s") 40 }`, runtimeID) 41 } 42 43 func (qp queryProvider) runtimeStatus(runtimeID string) string { 44 return fmt.Sprintf(`query { 45 result: runtimeStatus(id: "%s") { 46 %s 47 } 48 }`, runtimeID, runtimeStatusData()) 49 } 50 51 func (qp queryProvider) runtimeOperationStatus(operationID string) string { 52 return fmt.Sprintf(`query { 53 result: runtimeOperationStatus(id: "%s") { 54 %s 55 } 56 }`, operationID, operationStatusData()) 57 } 58 59 func runtimeStatusData() string { 60 return fmt.Sprintf(`lastOperationStatus { 61 operation 62 state 63 message 64 lastError { errMessage reason component } 65 } 66 runtimeConnectionStatus { status } 67 runtimeConfiguration { 68 kubeconfig 69 clusterConfig { 70 %s 71 } 72 kymaConfig { version } 73 }`, clusterConfig()) 74 } 75 76 /* 77 type OIDCConfig { 78 clientID: String! 79 groupsClaim: String! 80 issuerURL: String! 81 signingAlgs: [String!]! 82 usernameClaim: String! 83 usernamePrefix: String! 84 } 85 */ 86 func clusterConfig() string { 87 return fmt.Sprintf(` 88 name 89 kubernetesVersion 90 volumeSizeGB 91 diskType 92 machineType 93 region 94 provider 95 seed 96 targetSecret 97 diskType 98 workerCidr 99 autoScalerMin 100 autoScalerMax 101 maxSurge 102 maxUnavailable 103 providerSpecificConfig { 104 %s 105 } 106 oidcConfig { 107 clientID 108 issuerURL 109 groupsClaim 110 signingAlgs 111 usernameClaim 112 usernamePrefix 113 } 114 `, providerSpecificConfig()) 115 } 116 117 func providerSpecificConfig() string { 118 return fmt.Sprint(` 119 ... on GCPProviderConfig { 120 zones 121 } 122 ... on AzureProviderConfig { 123 vnetCidr 124 } 125 ... on AWSProviderConfig { 126 awsZones { 127 ... on AWSZone { 128 name 129 publicCidr 130 workerCidr 131 internalCidr 132 } 133 } 134 vpcCidr 135 } 136 `) 137 } 138 139 func operationStatusData() string { 140 return `id 141 operation 142 state 143 message 144 runtimeID 145 lastError { errMessage reason component }` 146 }