├── gateapi ├── .swagger-codegen │ └── VERSION ├── .travis.yml ├── docs │ ├── InputStream.md │ ├── Mapstringobject.md │ ├── Mapstringstring.md │ ├── UrlStreamHandler.md │ ├── HashMapstringobject.md │ ├── Version.md │ ├── GrantedAuthority.md │ ├── HttpEntity.md │ ├── RemoteExtensionTransportConfig.md │ ├── DeckPluginVersion.md │ ├── ReorderPipelinesCommand.md │ ├── Notification.md │ ├── PluginDependency.md │ ├── ResponseEntity.md │ ├── Headers.md │ ├── PipelineTemplateDependent.md │ ├── Http.md │ ├── EnvironmentArtifactVeto.md │ ├── ConstraintStatus.md │ ├── Account.md │ ├── EnvironmentArtifactPin.md │ ├── RemoteExtensionConfig.md │ ├── Environment.md │ ├── DeliveryConfig.md │ ├── SpinnakerPluginInfo.md │ ├── SpinnakerPluginRelease.md │ ├── Resource.md │ ├── VersionControllerApi.md │ ├── SpinnakerPluginDescriptor.md │ ├── ConstraintState.md │ ├── AccountDetails.md │ ├── PubsubSubscriptionControllerApi.md │ ├── User.md │ ├── Url.md │ ├── SubnetControllerApi.md │ ├── ReorderPipelinesControllerApi.md │ ├── Uri.md │ ├── ServerGroupManagerControllerApi.md │ ├── PluginPublishControllerApi.md │ ├── EcsServerGroupEventsControllerApi.md │ ├── File.md │ ├── CiControllerApi.md │ ├── PluginsInstalledControllerApi.md │ ├── JobControllerApi.md │ ├── SearchControllerApi.md │ ├── DeckPluginsControllerApi.md │ ├── WebhookControllerApi.md │ ├── SnapshotControllerApi.md │ ├── NetworkControllerApi.md │ ├── BakeControllerApi.md │ ├── InstanceControllerApi.md │ ├── PipelineConfigControllerApi.md │ ├── ConcourseControllerApi.md │ └── ServerGroupControllerApi.md ├── model_input_stream.go ├── model_mapstringobject.go ├── model_mapstringstring.go ├── model_url_stream_handler.go ├── model_hash_mapstringobject.go ├── .gitignore ├── model_version.go ├── model_http_entity.go ├── model_granted_authority.go ├── model_deck_plugin_version.go ├── model_remote_extension_transport_config.go ├── model_notification.go ├── model_reorder_pipelines_command.go ├── model_response_entity.go ├── model_plugin_dependency.go ├── model_headers.go ├── model_http.go ├── model_pipeline_template_dependent.go ├── model_remote_extension_config.go ├── model_environment_artifact_veto.go ├── model_account.go ├── model_constraint_status.go ├── model_environment_artifact_pin.go ├── model_environment.go ├── model_delivery_config.go ├── model_spinnaker_plugin_info.go ├── model_resource.go ├── model_spinnaker_plugin_release.go ├── model_spinnaker_plugin_descriptor.go ├── model_constraint_state.go ├── model_account_details.go ├── model_user.go ├── model_url.go ├── .swagger-codegen-ignore ├── model_uri.go ├── model_file.go ├── response.go ├── git_push.sh ├── configuration.go ├── api_plugin_publish_controller.go ├── api_version_controller.go ├── api_pubsub_subscription_controller.go └── api_subnet_controller.go ├── .gitignore ├── parser ├── fileloader │ ├── testdata │ │ ├── testfile.yml │ │ ├── testfile.yaml │ │ ├── testfile.json │ │ ├── testfile.invalid_ext │ │ ├── testfile.jsonnet │ │ └── testjsonnetlib.libsonnet │ ├── fileloader.go │ ├── yamlloader.go │ ├── jsonloader.go │ ├── jsonloader_test.go │ ├── jsonnetloader.go │ ├── yamlloader_test.go │ └── jsonnetloader_test.go └── testdata │ ├── pipelines │ └── testpipeline.json │ ├── applications │ ├── testapplication.jsonnet │ └── testapplication.json │ └── testlibraries │ └── testlib.libsonnet ├── images ├── Floodgate-logo.png ├── Floodgate-logo_full.png └── Floodgate-logo_full-fs8.png ├── .gitmodules ├── resourcemanager ├── resourcechange.go ├── options.go ├── graph.go └── graph_test.go ├── examples ├── resources │ ├── pipelines │ │ ├── jsonnetpipeline.jsonnet │ │ └── jsonnetpipelinept.jsonnet │ ├── applications │ │ ├── jsonnetapp.jsonnet │ │ ├── yamlapp.yaml │ │ └── jsonapp.json │ └── pipelinetemplates │ │ └── jsonnetpipelinetemplate.jsonnet └── config.yaml ├── main.go ├── spinnakerresource └── spinnaker_resources.go ├── .circleci └── libs │ ├── gate-local.yml │ ├── floodgate-config.yaml │ ├── spinnaker-ingress.yaml │ ├── kind-cluster-config.yaml │ ├── ingress-service-nodeport.yaml │ ├── install-and-run-spinnaker.sh │ └── minio-standalone.yaml ├── go.mod ├── cmd ├── version_test.go ├── version.go ├── hydrate.go ├── render.go ├── inspect.go ├── download.go ├── compare.go ├── render_test.go ├── sync.go ├── inspect_test.go ├── apply.go ├── compare_test.go ├── sync_test.go ├── root.go ├── execute_test.go ├── apply_test.go └── root_test.go ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── PULL_REQUEST_TEMPLATE.md ├── generate_swaggerapi.sh ├── util ├── utils.go ├── utils_test.go └── asserts.go ├── version └── version.go ├── config ├── auth │ ├── auth.go │ └── auth_test.go └── config.go ├── gateclient ├── x509.go └── gateclient.go ├── docs └── release-process.md └── test └── gate_mock.go /gateapi/.swagger-codegen/VERSION: -------------------------------------------------------------------------------- 1 | 2.4.12 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/launch.json 2 | config.yaml 3 | floodgate 4 | -------------------------------------------------------------------------------- /parser/fileloader/testdata/testfile.yml: -------------------------------------------------------------------------------- 1 | name: testyml 2 | variable: false 3 | -------------------------------------------------------------------------------- /parser/fileloader/testdata/testfile.yaml: -------------------------------------------------------------------------------- 1 | name: testyaml 2 | variable: false 3 | -------------------------------------------------------------------------------- /images/Floodgate-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codilime/floodgate/HEAD/images/Floodgate-logo.png -------------------------------------------------------------------------------- /parser/fileloader/testdata/testfile.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testjson", 3 | "variable": false 4 | } 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "sponnet"] 2 | path = sponnet 3 | url = https://github.com/spinnaker/sponnet.git 4 | -------------------------------------------------------------------------------- /images/Floodgate-logo_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codilime/floodgate/HEAD/images/Floodgate-logo_full.png -------------------------------------------------------------------------------- /gateapi/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | install: 4 | - go get -d -v . 5 | 6 | script: 7 | - go build -v ./ 8 | 9 | -------------------------------------------------------------------------------- /images/Floodgate-logo_full-fs8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codilime/floodgate/HEAD/images/Floodgate-logo_full-fs8.png -------------------------------------------------------------------------------- /parser/fileloader/testdata/testfile.invalid_ext: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testinvalidext", 3 | "variable": false 4 | } 5 | -------------------------------------------------------------------------------- /parser/fileloader/testdata/testfile.jsonnet: -------------------------------------------------------------------------------- 1 | local test = import 'testjsonnetlib.libsonnet'; 2 | 3 | test.test() 4 | .withName('testjsonnet') 5 | -------------------------------------------------------------------------------- /parser/fileloader/testdata/testjsonnetlib.libsonnet: -------------------------------------------------------------------------------- 1 | { 2 | test():: { 3 | // set default values 4 | variable: false, 5 | // set overrides 6 | withName(name):: self + { name: name }, 7 | }, 8 | } 9 | -------------------------------------------------------------------------------- /resourcemanager/resourcechange.go: -------------------------------------------------------------------------------- 1 | package resourcemanager 2 | 3 | // ResourceChange store resource change 4 | type ResourceChange struct { 5 | Type string 6 | ID string 7 | Name string 8 | Changes string 9 | } 10 | -------------------------------------------------------------------------------- /examples/resources/pipelines/jsonnetpipeline.jsonnet: -------------------------------------------------------------------------------- 1 | local pipelines = import 'pipeline.libsonnet'; 2 | 3 | pipelines.pipeline() 4 | .withName('Example pipeline from Jsonnet') 5 | .withId('jsonnetpipeline') 6 | .withApplication('jsonnetapp') 7 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/codilime/floodgate/cmd" 8 | ) 9 | 10 | func main() { 11 | if err := cmd.Execute(os.Stdout); err != nil { 12 | fmt.Fprintf(os.Stderr, "%v\n", err) 13 | os.Exit(1) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /parser/testdata/pipelines/testpipeline.json: -------------------------------------------------------------------------------- 1 | { 2 | "application": "testpipelineapplication", 3 | "keepWaitingPipelines": false, 4 | "limitConcurrent": true, 5 | "name": "testpipelinejson", 6 | "notifications": [ ], 7 | "stages": [ ], 8 | "triggers": [ ] 9 | } 10 | -------------------------------------------------------------------------------- /spinnakerresource/spinnaker_resources.go: -------------------------------------------------------------------------------- 1 | package spinnakerresource 2 | 3 | // SpinnakerResources Spinnaker resources collection 4 | type SpinnakerResources struct { 5 | Applications []*Application 6 | Pipelines []*Pipeline 7 | PipelineTemplates []*PipelineTemplate 8 | } 9 | -------------------------------------------------------------------------------- /parser/testdata/applications/testapplication.jsonnet: -------------------------------------------------------------------------------- 1 | local testlib = import 'testlib.libsonnet'; 2 | 3 | testlib.testApplication() 4 | .withName('testappjsonnet') 5 | .withUser('example@example.com') 6 | .withDescription('Test application from Jsonnet file.') 7 | .withEmail('example@example.com') 8 | .withCloudProviders('kubernetes') -------------------------------------------------------------------------------- /examples/resources/applications/jsonnetapp.jsonnet: -------------------------------------------------------------------------------- 1 | local sponnet = import 'application.libsonnet'; 2 | 3 | sponnet.application() 4 | .withName('jsonnetapp') 5 | .withDescription('Example application created from Jsonnet file.') 6 | .withUser('floodgate@example.com') 7 | .withEmail('example@example.com') 8 | .withCloudProviders('kubernetes') 9 | -------------------------------------------------------------------------------- /gateapi/docs/InputStream.md: -------------------------------------------------------------------------------- 1 | # InputStream 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /gateapi/docs/Mapstringobject.md: -------------------------------------------------------------------------------- 1 | # Mapstringobject 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /gateapi/docs/Mapstringstring.md: -------------------------------------------------------------------------------- 1 | # Mapstringstring 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /gateapi/docs/UrlStreamHandler.md: -------------------------------------------------------------------------------- 1 | # UrlStreamHandler 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /gateapi/docs/HashMapstringobject.md: -------------------------------------------------------------------------------- 1 | # HashMapstringobject 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | 10 | -------------------------------------------------------------------------------- /.circleci/libs/gate-local.yml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /api/v1 4 | tomcat: 5 | protocolHeader: X-Forwarded-Proto 6 | remoteIpHeader: X-Forwarded-For 7 | internalProxies: .* 8 | httpsServerPort: X-Forwarded-Port 9 | 10 | security: 11 | basicform: 12 | enabled: true 13 | user: 14 | name: admin 15 | password: GATE_PASS 16 | -------------------------------------------------------------------------------- /gateapi/model_input_stream.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type InputStream struct { 13 | } 14 | -------------------------------------------------------------------------------- /gateapi/model_mapstringobject.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Mapstringobject struct { 13 | } 14 | -------------------------------------------------------------------------------- /gateapi/model_mapstringstring.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Mapstringstring struct { 13 | } 14 | -------------------------------------------------------------------------------- /gateapi/model_url_stream_handler.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type UrlStreamHandler struct { 13 | } 14 | -------------------------------------------------------------------------------- /gateapi/model_hash_mapstringobject.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type HashMapstringobject struct { 13 | } 14 | -------------------------------------------------------------------------------- /gateapi/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /gateapi/docs/Version.md: -------------------------------------------------------------------------------- 1 | # Version 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Version** | **string** | | [optional] [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /gateapi/model_version.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Version struct { 13 | Version string `json:"version,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /.circleci/libs/floodgate-config.yaml: -------------------------------------------------------------------------------- 1 | endpoint: http://spinnaker/api/v1 2 | auth: 3 | basic: 4 | enabled: true 5 | user: admin 6 | password: GATE_PASS 7 | libraries: 8 | - /floodgate/libs/sponnet 9 | resources: 10 | - /floodgate/resources/examples/resources/applications 11 | - /floodgate/resources/examples/resources/pipelines 12 | - /floodgate/resources/examples/resources/pipelinetemplates 13 | 14 | -------------------------------------------------------------------------------- /gateapi/model_http_entity.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type HttpEntity struct { 13 | Body *interface{} `json:"body,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /gateapi/docs/GrantedAuthority.md: -------------------------------------------------------------------------------- 1 | # GrantedAuthority 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Authority** | **string** | | [optional] [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /gateapi/docs/HttpEntity.md: -------------------------------------------------------------------------------- 1 | # HttpEntity 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Body** | [***interface{}**](interface{}.md) | | [optional] [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /gateapi/model_granted_authority.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type GrantedAuthority struct { 13 | Authority string `json:"authority,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /gateapi/model_deck_plugin_version.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type DeckPluginVersion struct { 13 | Version string `json:"version"` 14 | Id string `json:"id"` 15 | } 16 | -------------------------------------------------------------------------------- /gateapi/model_remote_extension_transport_config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type RemoteExtensionTransportConfig struct { 13 | Http *Http `json:"http,omitempty"` 14 | } 15 | -------------------------------------------------------------------------------- /gateapi/docs/RemoteExtensionTransportConfig.md: -------------------------------------------------------------------------------- 1 | # RemoteExtensionTransportConfig 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Http** | [***Http**](Http.md) | | [optional] [default to null] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | 11 | -------------------------------------------------------------------------------- /gateapi/docs/DeckPluginVersion.md: -------------------------------------------------------------------------------- 1 | # DeckPluginVersion 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Version** | **string** | | [default to null] 7 | **Id** | **string** | | [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /.circleci/libs/spinnaker-ingress.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: extensions/v1beta1 3 | kind: Ingress 4 | metadata: 5 | labels: 6 | app: spin 7 | name: spin-ingress 8 | namespace: spinnaker 9 | spec: 10 | rules: 11 | - http: 12 | paths: 13 | - backend: 14 | serviceName: spin-deck 15 | servicePort: 9000 16 | path: / 17 | - backend: 18 | serviceName: spin-gate 19 | servicePort: 8084 20 | path: /api/v1 21 | 22 | -------------------------------------------------------------------------------- /examples/resources/pipelinetemplates/jsonnetpipelinetemplate.jsonnet: -------------------------------------------------------------------------------- 1 | local pipelineTemplates = import 'v2PipelineTemplate.libsonnet'; 2 | 3 | local metadata = pipelineTemplates.metadata() 4 | .withName('Example pipeline template from Jsonnet') 5 | .withDescription('Example pipeline template created from Jsonnet file.') 6 | .withOwner('floodgate@example.com') 7 | .withScopes(['global']); 8 | 9 | pipelineTemplates.pipelineTemplate() 10 | .withId('jsonnetpt') 11 | .withMetadata(metadata) 12 | -------------------------------------------------------------------------------- /examples/resources/applications/yamlapp.yaml: -------------------------------------------------------------------------------- 1 | cloudProviders: kubernetes 2 | dataSources: 3 | disabled: [] 4 | enabled: [] 5 | description: "Example application created from YAML file." 6 | email: "example@example.com" 7 | name: yamlapp 8 | platformHealthOnly: false 9 | platformHealthOnlyShowOverride: false 10 | providerSettings: 11 | aws: 12 | useAmiBlockDeviceMappings: false 13 | gce: 14 | associatePublicIpAddress: false 15 | trafficGuards: [] 16 | user: "floodgate@example.com" 17 | -------------------------------------------------------------------------------- /examples/resources/pipelines/jsonnetpipelinept.jsonnet: -------------------------------------------------------------------------------- 1 | local pipelines = import 'pipeline.libsonnet'; 2 | 3 | local artifact = pipelines.artifacts.front50PipelineTemplate() 4 | .withReference('spinnaker://jsonnetpt'); 5 | 6 | pipelines.pipeline() 7 | .withApplication('jsonnetapp') 8 | .withId('jsonnetpipelinept') 9 | .withName('Example pipeline v2 created from Jsonnet file.') 10 | .withTemplate(artifact) 11 | .withSchema('v2') 12 | .withInherit([]) 13 | .withNotifications([]) 14 | .withTriggers([]) -------------------------------------------------------------------------------- /gateapi/model_notification.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Notification struct { 13 | Address string `json:"address,omitempty"` 14 | Type_ string `json:"type,omitempty"` 15 | Frequency string `json:"frequency,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /gateapi/docs/ReorderPipelinesCommand.md: -------------------------------------------------------------------------------- 1 | # ReorderPipelinesCommand 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Application** | **string** | | [optional] [default to null] 7 | **IdsToIndices** | **map[string]int32** | | [optional] [default to null] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | 12 | -------------------------------------------------------------------------------- /gateapi/model_reorder_pipelines_command.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type ReorderPipelinesCommand struct { 13 | Application string `json:"application,omitempty"` 14 | IdsToIndices map[string]int32 `json:"idsToIndices,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /gateapi/docs/Notification.md: -------------------------------------------------------------------------------- 1 | # Notification 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Address** | **string** | | [optional] [default to null] 7 | **Type_** | **string** | | [optional] [default to null] 8 | **Frequency** | **string** | | [optional] [default to null] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /gateapi/model_response_entity.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type ResponseEntity struct { 13 | StatusCodeValue int32 `json:"statusCodeValue,omitempty"` 14 | Body *interface{} `json:"body,omitempty"` 15 | StatusCode string `json:"statusCode,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /gateapi/model_plugin_dependency.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type PluginDependency struct { 13 | Optional bool `json:"optional,omitempty"` 14 | PluginVersionSupport string `json:"pluginVersionSupport,omitempty"` 15 | PluginId string `json:"pluginId,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /gateapi/docs/PluginDependency.md: -------------------------------------------------------------------------------- 1 | # PluginDependency 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Optional** | **bool** | | [optional] [default to null] 7 | **PluginVersionSupport** | **string** | | [optional] [default to null] 8 | **PluginId** | **string** | | [optional] [default to null] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /gateapi/model_headers.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Headers struct { 13 | InvokeHeaders map[string]string `json:"invokeHeaders,omitempty"` 14 | ReadHeaders map[string]string `json:"readHeaders,omitempty"` 15 | WriteHeaders map[string]string `json:"writeHeaders,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /gateapi/model_http.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Http struct { 13 | Config map[string]string `json:"config,omitempty"` 14 | Url string `json:"url,omitempty"` 15 | QueryParams map[string]string `json:"queryParams,omitempty"` 16 | Headers *Headers `json:"headers,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /gateapi/docs/ResponseEntity.md: -------------------------------------------------------------------------------- 1 | # ResponseEntity 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **StatusCodeValue** | **int32** | | [optional] [default to null] 7 | **Body** | [***interface{}**](interface{}.md) | | [optional] [default to null] 8 | **StatusCode** | **string** | | [optional] [default to null] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /gateapi/model_pipeline_template_dependent.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type PipelineTemplateDependent struct { 13 | PipelineConfigId string `json:"pipelineConfigId,omitempty"` 14 | Application string `json:"application,omitempty"` 15 | PipelineName string `json:"pipelineName,omitempty"` 16 | } 17 | -------------------------------------------------------------------------------- /resourcemanager/options.go: -------------------------------------------------------------------------------- 1 | package resourcemanager 2 | 3 | import fl "github.com/codilime/floodgate/parser/fileloader" 4 | 5 | // Options store ResourceManager options 6 | type Options struct { 7 | fileLoaders []fl.FileLoader 8 | apiDisabled bool 9 | } 10 | 11 | // Option ResourceManager option 12 | type Option func(op *Options) 13 | 14 | // FileLoaders set file loaders 15 | func FileLoaders(apiDisabled bool, fileLoaders ...fl.FileLoader) Option { 16 | return func(op *Options) { 17 | op.fileLoaders = fileLoaders 18 | op.apiDisabled = apiDisabled 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /gateapi/docs/Headers.md: -------------------------------------------------------------------------------- 1 | # Headers 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **InvokeHeaders** | **map[string]string** | | [optional] [default to null] 7 | **ReadHeaders** | **map[string]string** | | [optional] [default to null] 8 | **WriteHeaders** | **map[string]string** | | [optional] [default to null] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /gateapi/docs/PipelineTemplateDependent.md: -------------------------------------------------------------------------------- 1 | # PipelineTemplateDependent 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **PipelineConfigId** | **string** | | [optional] [default to null] 7 | **Application** | **string** | | [optional] [default to null] 8 | **PipelineName** | **string** | | [optional] [default to null] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | 13 | -------------------------------------------------------------------------------- /parser/fileloader/fileloader.go: -------------------------------------------------------------------------------- 1 | package fileloader 2 | 3 | // FileLoader is the interface that wraps LoadFile and SupportedFileExtensions methods 4 | // 5 | // LoadFile loads file from given path. 6 | // It returns file content as map[string]interface{} and any error encountered that caused 7 | // the file loading to stop early. 8 | // 9 | // SupportedFileExtensions returns a slice of strings representing supported file format extensions 10 | type FileLoader interface { 11 | LoadFile(filePath string) ([]map[string]interface{}, error) 12 | SupportedFileExtensions() []string 13 | } 14 | -------------------------------------------------------------------------------- /.circleci/libs/kind-cluster-config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # source: https://kind.sigs.k8s.io/docs/user/ingress/ 3 | kind: Cluster 4 | apiVersion: kind.x-k8s.io/v1alpha4 5 | nodes: 6 | - role: control-plane 7 | kubeadmConfigPatches: 8 | - | 9 | kind: InitConfiguration 10 | nodeRegistration: 11 | kubeletExtraArgs: 12 | node-labels: "ingress-ready=true" 13 | authorization-mode: "AlwaysAllow" 14 | extraPortMappings: 15 | - containerPort: 80 16 | hostPort: 80 17 | protocol: TCP 18 | - containerPort: 443 19 | hostPort: 443 20 | protocol: TCP 21 | 22 | -------------------------------------------------------------------------------- /gateapi/model_remote_extension_config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type RemoteExtensionConfig struct { 13 | Type_ string `json:"type,omitempty"` 14 | Transport *RemoteExtensionTransportConfig `json:"transport,omitempty"` 15 | Config *interface{} `json:"config,omitempty"` 16 | Id string `json:"id,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /gateapi/model_environment_artifact_veto.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type EnvironmentArtifactVeto struct { 13 | Comment string `json:"comment,omitempty"` 14 | Version string `json:"version,omitempty"` 15 | TargetEnvironment string `json:"targetEnvironment,omitempty"` 16 | Reference string `json:"reference,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /gateapi/docs/Http.md: -------------------------------------------------------------------------------- 1 | # Http 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Config** | **map[string]string** | | [optional] [default to null] 7 | **Url** | **string** | | [optional] [default to null] 8 | **QueryParams** | **map[string]string** | | [optional] [default to null] 9 | **Headers** | [***Headers**](Headers.md) | | [optional] [default to null] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/codilime/floodgate 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/antihax/optional v1.0.0 7 | github.com/boscard/gateapi v0.0.0-20200701082216-4601ca769d77 8 | github.com/ghodss/yaml v1.0.0 9 | github.com/google/go-jsonnet v0.15.0 10 | github.com/hashicorp/terraform v0.12.26 11 | github.com/josephburnett/jd v0.0.0-20191228205456-aa1a7c66b42f 12 | github.com/mitchellh/go-homedir v1.1.0 13 | github.com/sirupsen/logrus v1.2.0 14 | github.com/spf13/cobra v0.0.6 15 | golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e 16 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d 17 | ) 18 | -------------------------------------------------------------------------------- /gateapi/docs/EnvironmentArtifactVeto.md: -------------------------------------------------------------------------------- 1 | # EnvironmentArtifactVeto 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Comment** | **string** | | [optional] [default to null] 7 | **Version** | **string** | | [optional] [default to null] 8 | **TargetEnvironment** | **string** | | [optional] [default to null] 9 | **Reference** | **string** | | [optional] [default to null] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /gateapi/model_account.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Account struct { 13 | RequiredGroupMembership []string `json:"requiredGroupMembership,omitempty"` 14 | Permissions map[string][]string `json:"permissions,omitempty"` 15 | Name string `json:"name,omitempty"` 16 | AccountId string `json:"accountId,omitempty"` 17 | Type_ string `json:"type,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /gateapi/model_constraint_status.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type ConstraintStatus struct { 13 | ArtifactReference string `json:"artifactReference,omitempty"` 14 | Type_ string `json:"type,omitempty"` 15 | Status string `json:"status,omitempty"` 16 | ArtifactVersion string `json:"artifactVersion,omitempty"` 17 | Comment string `json:"comment,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /gateapi/model_environment_artifact_pin.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type EnvironmentArtifactPin struct { 13 | TargetEnvironment string `json:"targetEnvironment,omitempty"` 14 | PinnedBy string `json:"pinnedBy,omitempty"` 15 | Reference string `json:"reference,omitempty"` 16 | Comment string `json:"comment,omitempty"` 17 | Version string `json:"version,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /examples/resources/applications/jsonapp.json: -------------------------------------------------------------------------------- 1 | { 2 | "cloudProviders": "kubernetes", 3 | "dataSources": { 4 | "disabled": [], 5 | "enabled": [] 6 | }, 7 | "description": "Example application created from JSON file.", 8 | "email": "example@example.com", 9 | "name": "jsonapp", 10 | "platformHealthOnly": false, 11 | "platformHealthOnlyShowOverride": false, 12 | "providerSettings": { 13 | "aws": { 14 | "useAmiBlockDeviceMappings": false 15 | }, 16 | "gce": { 17 | "associatePublicIpAddress": false 18 | } 19 | }, 20 | "trafficGuards": [], 21 | "user": "floodgate@example.com" 22 | } -------------------------------------------------------------------------------- /gateapi/model_environment.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Environment struct { 13 | Locations *interface{} `json:"locations,omitempty"` 14 | Constraints []Mapstringobject `json:"constraints,omitempty"` 15 | Resources []Resource `json:"resources,omitempty"` 16 | Notifications []Notification `json:"notifications,omitempty"` 17 | Name string `json:"name,omitempty"` 18 | } 19 | -------------------------------------------------------------------------------- /gateapi/docs/ConstraintStatus.md: -------------------------------------------------------------------------------- 1 | # ConstraintStatus 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **ArtifactReference** | **string** | | [optional] [default to null] 7 | **Type_** | **string** | | [optional] [default to null] 8 | **Status** | **string** | | [optional] [default to null] 9 | **ArtifactVersion** | **string** | | [optional] [default to null] 10 | **Comment** | **string** | | [optional] [default to null] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /parser/testdata/applications/testapplication.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testappjson", 3 | "description": "Test application from JSON file.", 4 | "email": "example@example.com", 5 | "trafficGuards": [], 6 | "platformHealthOnlyShowOverride": false, 7 | "platformHealthOnly": false, 8 | "cloudProviders": "kubernetes", 9 | "providerSettings": { 10 | "gce": { 11 | "associatePublicIpAddress": false 12 | }, 13 | "aws": { 14 | "useAmiBlockDeviceMappings": false 15 | } 16 | }, 17 | "user": "example@example.com", 18 | "dataSources": { 19 | "disabled": [], 20 | "enabled": [] 21 | } 22 | } -------------------------------------------------------------------------------- /gateapi/docs/Account.md: -------------------------------------------------------------------------------- 1 | # Account 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **RequiredGroupMembership** | **[]string** | | [optional] [default to null] 7 | **Permissions** | [**map[string][]string**](array.md) | | [optional] [default to null] 8 | **Name** | **string** | | [optional] [default to null] 9 | **AccountId** | **string** | | [optional] [default to null] 10 | **Type_** | **string** | | [optional] [default to null] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /gateapi/docs/EnvironmentArtifactPin.md: -------------------------------------------------------------------------------- 1 | # EnvironmentArtifactPin 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **TargetEnvironment** | **string** | | [optional] [default to null] 7 | **PinnedBy** | **string** | | [optional] [default to null] 8 | **Reference** | **string** | | [optional] [default to null] 9 | **Comment** | **string** | | [optional] [default to null] 10 | **Version** | **string** | | [optional] [default to null] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /gateapi/docs/RemoteExtensionConfig.md: -------------------------------------------------------------------------------- 1 | # RemoteExtensionConfig 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Type_** | **string** | | [optional] [default to null] 7 | **Transport** | [***RemoteExtensionTransportConfig**](RemoteExtensionTransportConfig.md) | | [optional] [default to null] 8 | **Config** | [***interface{}**](interface{}.md) | | [optional] [default to null] 9 | **Id** | **string** | | [optional] [default to null] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | 14 | -------------------------------------------------------------------------------- /cmd/version_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "github.com/codilime/floodgate/version" 6 | "io/ioutil" 7 | "testing" 8 | ) 9 | 10 | func TestVersion(t *testing.T) { 11 | b := bytes.NewBufferString("") 12 | 13 | cmd := NewRootCmd(b) 14 | cmd.SetOut(b) 15 | cmd.SetArgs([]string{"version"}) 16 | err := cmd.Execute() 17 | if err != nil { 18 | t.Errorf("cmd.Version() Execute err %v", err) 19 | } 20 | 21 | out, err := ioutil.ReadAll(b) 22 | if err != nil { 23 | t.Errorf("cmd.Version() Read output err %v", err) 24 | } 25 | 26 | if string(out) != version.BuildInfo() { 27 | t.Errorf("cmd.Version() got `%v` want `%v`", string(out), version.BuildInfo()) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /gateapi/model_delivery_config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type DeliveryConfig struct { 13 | Environments []Environment `json:"environments,omitempty"` 14 | ApiVersion string `json:"apiVersion,omitempty"` 15 | Name string `json:"name,omitempty"` 16 | Application string `json:"application,omitempty"` 17 | ServiceAccount string `json:"serviceAccount,omitempty"` 18 | Artifacts []Mapstringobject `json:"artifacts,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /generate_swaggerapi.sh: -------------------------------------------------------------------------------- 1 | # generate API libraries using swagger in docker 2 | 3 | SWAGGER_JSON=${1:-"gate-swagger.json"} 4 | SWAGGER_VERSION=$(cat gateapi/.swagger-codegen/VERSION) 5 | 6 | echo '* Using swagger-codegen-cli '${SWAGGER_VERSION} 7 | docker pull swaggerapi/swagger-codegen-cli:${SWAGGER_VERSION} 8 | 9 | echo '* Cleaning up gateapi directory' 10 | rm -rf gateapi/api gateapi/docs gateapi/*.go gateapi/*.md 11 | 12 | echo '* Generating new gateapi code using '${SWAGGER_JSON}' file...' 13 | docker run --rm -v ${PWD}:/local -u $(id -u):$(id -g) \ 14 | swaggerapi/swagger-codegen-cli:${SWAGGER_VERSION} \ 15 | generate \ 16 | -i /local/${SWAGGER_JSON} \ 17 | -l go \ 18 | -o /local/gateapi 19 | 20 | -------------------------------------------------------------------------------- /gateapi/model_spinnaker_plugin_info.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type SpinnakerPluginInfo struct { 13 | Description string `json:"description,omitempty"` 14 | Provider string `json:"provider,omitempty"` 15 | ProjectUrl string `json:"projectUrl,omitempty"` 16 | Name string `json:"name,omitempty"` 17 | Releases []SpinnakerPluginRelease `json:"releases"` 18 | RepositoryId string `json:"repositoryId,omitempty"` 19 | Id string `json:"id,omitempty"` 20 | } 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve floodgate 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Prepare following manifest: 16 | ``` 17 | ... 18 | ``` 19 | 2. Run following command: `...` 20 | 3. Observe error: 21 | ``` 22 | ... 23 | ``` 24 | 25 | **Expected behavior** 26 | A clear and concise description of what you expected to happen. 27 | 28 | **Screenshots** 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.circleci/libs/ingress-service-nodeport.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # source: https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml 3 | apiVersion: v1 4 | kind: Service 5 | metadata: 6 | name: ingress-nginx 7 | namespace: ingress-nginx 8 | labels: 9 | app.kubernetes.io/name: ingress-nginx 10 | app.kubernetes.io/part-of: ingress-nginx 11 | spec: 12 | type: NodePort 13 | ports: 14 | - name: http 15 | port: 80 16 | targetPort: 80 17 | protocol: TCP 18 | - name: https 19 | port: 443 20 | targetPort: 443 21 | protocol: TCP 22 | selector: 23 | app.kubernetes.io/name: ingress-nginx 24 | app.kubernetes.io/part-of: ingress-nginx 25 | 26 | --- 27 | 28 | -------------------------------------------------------------------------------- /gateapi/model_resource.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "os" 14 | ) 15 | 16 | type Resource struct { 17 | Uri *Uri `json:"uri,omitempty"` 18 | File **os.File `json:"file,omitempty"` 19 | Readable bool `json:"readable,omitempty"` 20 | Description string `json:"description,omitempty"` 21 | Open bool `json:"open,omitempty"` 22 | Filename string `json:"filename,omitempty"` 23 | InputStream *InputStream `json:"inputStream,omitempty"` 24 | Url *Url `json:"url,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /examples/config.yaml: -------------------------------------------------------------------------------- 1 | endpoint: https://127.0.0.1/api/v1 2 | timeout: 10 3 | insecure: true 4 | auth: 5 | basic: 6 | enabled: true 7 | user: admin 8 | password: VRCm9L80yO3FHTKeVthtxknfGq1b10WqInKoBFqozphGcrGi 9 | oauth2: 10 | enabled: false 11 | authUrl: https://github.com/login/oauth/authorize 12 | tokenUrl: https://github.com/login/oauth/access_token 13 | clientId: xxxxxxxxxxxxxx 14 | clientSecret: xxxxxxxxxxxxxxxxxxxxxxxxxxxx 15 | scopes: 16 | - profile 17 | x509: 18 | certPath: ~/.config/floodgate/floodgate.crt 19 | enabled: false 20 | keyPath: ~/.config/floodgate/floodgate.key 21 | libraries: 22 | - sponnet 23 | resources: 24 | - resources/applications 25 | - resources/pipelines 26 | - resources/pipelinetemplates -------------------------------------------------------------------------------- /gateapi/docs/Environment.md: -------------------------------------------------------------------------------- 1 | # Environment 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Locations** | [***interface{}**](interface{}.md) | | [optional] [default to null] 7 | **Constraints** | [**[]Mapstringobject**](Map«string,object».md) | | [optional] [default to null] 8 | **Resources** | [**[]Resource**](Resource.md) | | [optional] [default to null] 9 | **Notifications** | [**[]Notification**](Notification.md) | | [optional] [default to null] 10 | **Name** | **string** | | [optional] [default to null] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | 15 | -------------------------------------------------------------------------------- /gateapi/model_spinnaker_plugin_release.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "time" 14 | ) 15 | 16 | type SpinnakerPluginRelease struct { 17 | Version string `json:"version,omitempty"` 18 | Requires string `json:"requires,omitempty"` 19 | Preferred bool `json:"preferred,omitempty"` 20 | Date time.Time `json:"date,omitempty"` 21 | Url string `json:"url,omitempty"` 22 | Sha512sum string `json:"sha512sum,omitempty"` 23 | RemoteExtensions []RemoteExtensionConfig `json:"remoteExtensions,omitempty"` 24 | } 25 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Pull Request template 2 | Please, go through these steps before you submit a PR. 3 | 4 | 1. Make sure that your PR is not a duplicate. 5 | 2. If not, then make sure that: 6 | 7 | a. You have done your changes in a separate branch. Branches MUST have descriptive names. Good examples are: `fix-signin-issue` or `feature-issue-templates`. 8 | 9 | b. You have a descriptive commit message with a short title (first line). 10 | 11 | 3. **After** these steps, you're ready to open a pull request. 12 | 13 | a. Give a descriptive title to your PR. 14 | 15 | b. Provide a description of your changes. 16 | 17 | c. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). 18 | 19 | **PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING** 20 | -------------------------------------------------------------------------------- /gateapi/docs/DeliveryConfig.md: -------------------------------------------------------------------------------- 1 | # DeliveryConfig 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Environments** | [**[]Environment**](Environment.md) | | [optional] [default to null] 7 | **ApiVersion** | **string** | | [optional] [default to null] 8 | **Name** | **string** | | [optional] [default to null] 9 | **Application** | **string** | | [optional] [default to null] 10 | **ServiceAccount** | **string** | | [optional] [default to null] 11 | **Artifacts** | [**[]Mapstringobject**](Map«string,object».md) | | [optional] [default to null] 12 | 13 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | 16 | -------------------------------------------------------------------------------- /gateapi/docs/SpinnakerPluginInfo.md: -------------------------------------------------------------------------------- 1 | # SpinnakerPluginInfo 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Description** | **string** | | [optional] [default to null] 7 | **Provider** | **string** | | [optional] [default to null] 8 | **ProjectUrl** | **string** | | [optional] [default to null] 9 | **Name** | **string** | | [optional] [default to null] 10 | **Releases** | [**[]SpinnakerPluginRelease**](SpinnakerPluginRelease.md) | | [default to null] 11 | **RepositoryId** | **string** | | [optional] [default to null] 12 | **Id** | **string** | | [optional] [default to null] 13 | 14 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 15 | 16 | 17 | -------------------------------------------------------------------------------- /cmd/version.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "github.com/codilime/floodgate/version" 8 | "github.com/spf13/cobra" 9 | ) 10 | 11 | // renderOptions store render command options 12 | type versionOptions struct { 13 | } 14 | 15 | // NewVersionCmd create new render command 16 | func NewVersionCmd(out io.Writer) *cobra.Command { 17 | options := renderOptions{} 18 | cmd := &cobra.Command{ 19 | Use: "version", 20 | Short: "Print info about version", 21 | Long: "Prints information about version and build details", 22 | RunE: func(cmd *cobra.Command, args []string) error { 23 | return runVersion(cmd, options) 24 | }, 25 | } 26 | return cmd 27 | } 28 | 29 | func runVersion(cmd *cobra.Command, options renderOptions) error { 30 | fmt.Fprintf(cmd.OutOrStdout(), version.BuildInfo()) 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /gateapi/model_spinnaker_plugin_descriptor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type SpinnakerPluginDescriptor struct { 13 | PluginDescription string `json:"pluginDescription,omitempty"` 14 | Provider string `json:"provider,omitempty"` 15 | PluginClass string `json:"pluginClass,omitempty"` 16 | Unsafe bool `json:"unsafe"` 17 | License string `json:"license,omitempty"` 18 | PluginId string `json:"pluginId,omitempty"` 19 | Dependencies []PluginDependency `json:"dependencies,omitempty"` 20 | Requires string `json:"requires,omitempty"` 21 | Version string `json:"version,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /cmd/hydrate.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | // hydrateOptions store hydrate command options 11 | type hydrateOptions struct { 12 | } 13 | 14 | // NewHydrateCmd create new hydrate command 15 | func NewHydrateCmd(out io.Writer) *cobra.Command { 16 | options := hydrateOptions{} 17 | cmd := &cobra.Command{ 18 | Use: "hydrate", 19 | Short: "Hydrate pipeline templates with configurations and preview the result", 20 | Long: "Hydrate pipeline templates with configurations, without creating actual pipelines in Spinnaker", 21 | RunE: func(cmd *cobra.Command, args []string) error { 22 | return runHydrate(cmd, options) 23 | }, 24 | } 25 | return cmd 26 | } 27 | 28 | func runHydrate(cmd *cobra.Command, options hydrateOptions) error { 29 | return fmt.Errorf("not implemented") 30 | } 31 | -------------------------------------------------------------------------------- /gateapi/docs/SpinnakerPluginRelease.md: -------------------------------------------------------------------------------- 1 | # SpinnakerPluginRelease 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Version** | **string** | | [optional] [default to null] 7 | **Requires** | **string** | | [optional] [default to null] 8 | **Preferred** | **bool** | | [optional] [default to null] 9 | **Date** | [**time.Time**](time.Time.md) | | [optional] [default to null] 10 | **Url** | **string** | | [optional] [default to null] 11 | **Sha512sum** | **string** | | [optional] [default to null] 12 | **RemoteExtensions** | [**[]RemoteExtensionConfig**](RemoteExtensionConfig.md) | | [optional] [default to null] 13 | 14 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 15 | 16 | 17 | -------------------------------------------------------------------------------- /util/utils.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | // CombineErrors combine array of errors into one 9 | func CombineErrors(errors []error) error { 10 | var combinedErr error 11 | for idx, err := range errors { 12 | if err != nil { 13 | combinedErr = err 14 | errors = errors[idx+1:] 15 | break 16 | } 17 | } 18 | for _, err := range errors { 19 | if err != nil { 20 | combinedErr = fmt.Errorf("%v, %w", combinedErr.Error(), err) 21 | } 22 | } 23 | return combinedErr 24 | } 25 | 26 | // CreateDirs create directories 27 | func CreateDirs(dirPaths ...string) error { 28 | for _, dirPath := range dirPaths { 29 | if _, err := os.Stat(dirPath); os.IsNotExist(err) { 30 | if err := os.MkdirAll(dirPath, os.ModePerm); err != nil { 31 | return err 32 | } 33 | } else { 34 | return err 35 | } 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /gateapi/docs/Resource.md: -------------------------------------------------------------------------------- 1 | # Resource 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Uri** | [***Uri**](URI.md) | | [optional] [default to null] 7 | **File** | [****os.File**](*os.File.md) | | [optional] [default to null] 8 | **Readable** | **bool** | | [optional] [default to null] 9 | **Description** | **string** | | [optional] [default to null] 10 | **Open** | **bool** | | [optional] [default to null] 11 | **Filename** | **string** | | [optional] [default to null] 12 | **InputStream** | [***InputStream**](InputStream.md) | | [optional] [default to null] 13 | **Url** | [***Url**](URL.md) | | [optional] [default to null] 14 | 15 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 16 | 17 | 18 | -------------------------------------------------------------------------------- /parser/fileloader/yamlloader.go: -------------------------------------------------------------------------------- 1 | package fileloader 2 | 3 | import ( 4 | "io/ioutil" 5 | 6 | "github.com/ghodss/yaml" 7 | ) 8 | 9 | // NewYAMLLoader create new YAML file loader 10 | func NewYAMLLoader() *YAMLLoader { 11 | return &YAMLLoader{} 12 | } 13 | 14 | // YAMLLoader load YAML files 15 | type YAMLLoader struct{} 16 | 17 | // LoadFile load file 18 | func (yl *YAMLLoader) LoadFile(filePath string) ([]map[string]interface{}, error) { 19 | inputFile, err := ioutil.ReadFile(filePath) 20 | if err != nil { 21 | return nil, err 22 | } 23 | var output map[string]interface{} 24 | if err := yaml.Unmarshal(inputFile, &output); err != nil { 25 | return nil, err 26 | } 27 | return []map[string]interface{}{output}, nil 28 | } 29 | 30 | // SupportedFileExtensions get supported file extensions 31 | func (yl *YAMLLoader) SupportedFileExtensions() []string { 32 | return []string{".yaml", ".yml"} 33 | } 34 | -------------------------------------------------------------------------------- /gateapi/model_constraint_state.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type ConstraintState struct { 13 | Status string `json:"status,omitempty"` 14 | Type_ string `json:"type,omitempty"` 15 | DeliveryConfigName string `json:"deliveryConfigName,omitempty"` 16 | JudgedBy string `json:"judgedBy,omitempty"` 17 | Attributes *interface{} `json:"attributes,omitempty"` 18 | ArtifactVersion string `json:"artifactVersion,omitempty"` 19 | EnvironmentName string `json:"environmentName,omitempty"` 20 | CreatedAt string `json:"createdAt,omitempty"` 21 | JudgedAt string `json:"judgedAt,omitempty"` 22 | Comment string `json:"comment,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /parser/fileloader/jsonloader.go: -------------------------------------------------------------------------------- 1 | package fileloader 2 | 3 | import ( 4 | "encoding/json" 5 | "io/ioutil" 6 | ) 7 | 8 | // NewJSONLoader create loader that can load JSON files with extension ".json" 9 | func NewJSONLoader() *JSONLoader { 10 | return &JSONLoader{} 11 | } 12 | 13 | // JSONLoader load JSON files 14 | type JSONLoader struct{} 15 | 16 | // LoadFile load file 17 | func (jl *JSONLoader) LoadFile(filePath string) ([]map[string]interface{}, error) { 18 | inputFile, err := ioutil.ReadFile(filePath) 19 | if err != nil { 20 | return nil, err 21 | } 22 | var output map[string]interface{} 23 | if err := json.Unmarshal(inputFile, &output); err != nil { 24 | return nil, err 25 | } 26 | return []map[string]interface{}{output}, nil 27 | } 28 | 29 | // SupportedFileExtensions get supported file extensions 30 | func (jl *JSONLoader) SupportedFileExtensions() []string { 31 | return []string{".json"} 32 | } 33 | -------------------------------------------------------------------------------- /gateapi/docs/VersionControllerApi.md: -------------------------------------------------------------------------------- 1 | # \VersionControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetVersionUsingGET**](VersionControllerApi.md#GetVersionUsingGET) | **Get** /version | Fetch Gate's current version 8 | 9 | 10 | # **GetVersionUsingGET** 11 | > Version GetVersionUsingGET(ctx, ) 12 | Fetch Gate's current version 13 | 14 | ### Required Parameters 15 | This endpoint does not need any parameter. 16 | 17 | ### Return type 18 | 19 | [**Version**](Version.md) 20 | 21 | ### Authorization 22 | 23 | No authorization required 24 | 25 | ### HTTP request headers 26 | 27 | - **Content-Type**: Not defined 28 | - **Accept**: */* 29 | 30 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 31 | 32 | -------------------------------------------------------------------------------- /gateapi/model_account_details.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type AccountDetails struct { 13 | AccountType string `json:"accountType,omitempty"` 14 | AccountId string `json:"accountId,omitempty"` 15 | PrimaryAccount bool `json:"primaryAccount,omitempty"` 16 | ChallengeDestructiveActions bool `json:"challengeDestructiveActions,omitempty"` 17 | Environment string `json:"environment,omitempty"` 18 | CloudProvider string `json:"cloudProvider,omitempty"` 19 | Name string `json:"name,omitempty"` 20 | Permissions map[string][]string `json:"permissions,omitempty"` 21 | Type_ string `json:"type,omitempty"` 22 | RequiredGroupMembership []string `json:"requiredGroupMembership,omitempty"` 23 | } 24 | -------------------------------------------------------------------------------- /gateapi/model_user.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type User struct { 13 | Authorities []GrantedAuthority `json:"authorities,omitempty"` 14 | Username string `json:"username,omitempty"` 15 | CredentialsNonExpired bool `json:"credentialsNonExpired,omitempty"` 16 | Email string `json:"email,omitempty"` 17 | Roles []string `json:"roles,omitempty"` 18 | LastName string `json:"lastName,omitempty"` 19 | Enabled bool `json:"enabled,omitempty"` 20 | AllowedAccounts []string `json:"allowedAccounts,omitempty"` 21 | FirstName string `json:"firstName,omitempty"` 22 | AccountNonLocked bool `json:"accountNonLocked,omitempty"` 23 | AccountNonExpired bool `json:"accountNonExpired,omitempty"` 24 | } 25 | -------------------------------------------------------------------------------- /parser/testdata/testlibraries/testlib.libsonnet: -------------------------------------------------------------------------------- 1 | { 2 | testApplication():: { 3 | // set default values 4 | dataSources: { 5 | disabled: [], 6 | enabled: [], 7 | }, 8 | platformHealthOnly: false, 9 | platformHealthOnlyShowOverride: false, 10 | providerSettings: { 11 | aws: { 12 | useAmiBlockDeviceMappings: false, 13 | }, 14 | gce: { 15 | associatePublicIpAddress: false, 16 | }, 17 | }, 18 | trafficGuards: [], 19 | // set overrides 20 | withClusters(clusters):: self + if std.type(clusters) == 'array' then { clusters: clusters } else { clusters: [clusters] }, 21 | withCloudProviders(cloudProviders):: self + { cloudProviders: cloudProviders }, 22 | withDescription(description):: self + { description: description }, 23 | withEmail(email):: self + { email: email }, 24 | withName(name):: self + { name: name }, 25 | withUser(user):: self + { user: user }, 26 | }, 27 | } 28 | -------------------------------------------------------------------------------- /gateapi/docs/SpinnakerPluginDescriptor.md: -------------------------------------------------------------------------------- 1 | # SpinnakerPluginDescriptor 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **PluginDescription** | **string** | | [optional] [default to null] 7 | **Provider** | **string** | | [optional] [default to null] 8 | **PluginClass** | **string** | | [optional] [default to null] 9 | **Unsafe** | **bool** | | [default to null] 10 | **License** | **string** | | [optional] [default to null] 11 | **PluginId** | **string** | | [optional] [default to null] 12 | **Dependencies** | [**[]PluginDependency**](PluginDependency.md) | | [optional] [default to null] 13 | **Requires** | **string** | | [optional] [default to null] 14 | **Version** | **string** | | [optional] [default to null] 15 | 16 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 17 | 18 | 19 | -------------------------------------------------------------------------------- /gateapi/model_url.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Url struct { 13 | Query string `json:"query,omitempty"` 14 | Path string `json:"path,omitempty"` 15 | DeserializedFields *UrlStreamHandler `json:"deserializedFields,omitempty"` 16 | Port int32 `json:"port,omitempty"` 17 | DefaultPort int32 `json:"defaultPort,omitempty"` 18 | Ref string `json:"ref,omitempty"` 19 | Content *interface{} `json:"content,omitempty"` 20 | UserInfo string `json:"userInfo,omitempty"` 21 | File string `json:"file,omitempty"` 22 | Authority string `json:"authority,omitempty"` 23 | SerializedHashCode int32 `json:"serializedHashCode,omitempty"` 24 | Host string `json:"host,omitempty"` 25 | Protocol string `json:"protocol,omitempty"` 26 | } 27 | -------------------------------------------------------------------------------- /gateapi/docs/ConstraintState.md: -------------------------------------------------------------------------------- 1 | # ConstraintState 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Status** | **string** | | [optional] [default to null] 7 | **Type_** | **string** | | [optional] [default to null] 8 | **DeliveryConfigName** | **string** | | [optional] [default to null] 9 | **JudgedBy** | **string** | | [optional] [default to null] 10 | **Attributes** | [***interface{}**](interface{}.md) | | [optional] [default to null] 11 | **ArtifactVersion** | **string** | | [optional] [default to null] 12 | **EnvironmentName** | **string** | | [optional] [default to null] 13 | **CreatedAt** | **string** | | [optional] [default to null] 14 | **JudgedAt** | **string** | | [optional] [default to null] 15 | **Comment** | **string** | | [optional] [default to null] 16 | 17 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 18 | 19 | 20 | -------------------------------------------------------------------------------- /gateapi/docs/AccountDetails.md: -------------------------------------------------------------------------------- 1 | # AccountDetails 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **AccountType** | **string** | | [optional] [default to null] 7 | **AccountId** | **string** | | [optional] [default to null] 8 | **PrimaryAccount** | **bool** | | [optional] [default to null] 9 | **ChallengeDestructiveActions** | **bool** | | [optional] [default to null] 10 | **Environment** | **string** | | [optional] [default to null] 11 | **CloudProvider** | **string** | | [optional] [default to null] 12 | **Name** | **string** | | [optional] [default to null] 13 | **Permissions** | [**map[string][]string**](array.md) | | [optional] [default to null] 14 | **Type_** | **string** | | [optional] [default to null] 15 | **RequiredGroupMembership** | **[]string** | | [optional] [default to null] 16 | 17 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 18 | 19 | 20 | -------------------------------------------------------------------------------- /gateapi/docs/PubsubSubscriptionControllerApi.md: -------------------------------------------------------------------------------- 1 | # \PubsubSubscriptionControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**AllUsingGET4**](PubsubSubscriptionControllerApi.md#AllUsingGET4) | **Get** /pubsub/subscriptions | Retrieve the list of pub/sub subscriptions configured in Echo. 8 | 9 | 10 | # **AllUsingGET4** 11 | > []Mapstringstring AllUsingGET4(ctx, ) 12 | Retrieve the list of pub/sub subscriptions configured in Echo. 13 | 14 | ### Required Parameters 15 | This endpoint does not need any parameter. 16 | 17 | ### Return type 18 | 19 | [**[]Mapstringstring**](Map«string,string».md) 20 | 21 | ### Authorization 22 | 23 | No authorization required 24 | 25 | ### HTTP request headers 26 | 27 | - **Content-Type**: Not defined 28 | - **Accept**: */* 29 | 30 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 31 | 32 | -------------------------------------------------------------------------------- /gateapi/docs/User.md: -------------------------------------------------------------------------------- 1 | # User 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Authorities** | [**[]GrantedAuthority**](GrantedAuthority.md) | | [optional] [default to null] 7 | **Username** | **string** | | [optional] [default to null] 8 | **CredentialsNonExpired** | **bool** | | [optional] [default to null] 9 | **Email** | **string** | | [optional] [default to null] 10 | **Roles** | **[]string** | | [optional] [default to null] 11 | **LastName** | **string** | | [optional] [default to null] 12 | **Enabled** | **bool** | | [optional] [default to null] 13 | **AllowedAccounts** | **[]string** | | [optional] [default to null] 14 | **FirstName** | **string** | | [optional] [default to null] 15 | **AccountNonLocked** | **bool** | | [optional] [default to null] 16 | **AccountNonExpired** | **bool** | | [optional] [default to null] 17 | 18 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 19 | 20 | 21 | -------------------------------------------------------------------------------- /gateapi/.swagger-codegen-ignore: -------------------------------------------------------------------------------- 1 | # Swagger Codegen Ignore 2 | # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | -------------------------------------------------------------------------------- /gateapi/model_uri.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | type Uri struct { 13 | Opaque bool `json:"opaque,omitempty"` 14 | Absolute bool `json:"absolute,omitempty"` 15 | Authority string `json:"authority,omitempty"` 16 | UserInfo string `json:"userInfo,omitempty"` 17 | SchemeSpecificPart string `json:"schemeSpecificPart,omitempty"` 18 | Port int32 `json:"port,omitempty"` 19 | Path string `json:"path,omitempty"` 20 | RawQuery string `json:"rawQuery,omitempty"` 21 | RawAuthority string `json:"rawAuthority,omitempty"` 22 | Host string `json:"host,omitempty"` 23 | RawSchemeSpecificPart string `json:"rawSchemeSpecificPart,omitempty"` 24 | Fragment string `json:"fragment,omitempty"` 25 | Scheme string `json:"scheme,omitempty"` 26 | RawPath string `json:"rawPath,omitempty"` 27 | Query string `json:"query,omitempty"` 28 | RawFragment string `json:"rawFragment,omitempty"` 29 | RawUserInfo string `json:"rawUserInfo,omitempty"` 30 | } 31 | -------------------------------------------------------------------------------- /gateapi/docs/Url.md: -------------------------------------------------------------------------------- 1 | # Url 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Query** | **string** | | [optional] [default to null] 7 | **Path** | **string** | | [optional] [default to null] 8 | **DeserializedFields** | [***UrlStreamHandler**](URLStreamHandler.md) | | [optional] [default to null] 9 | **Port** | **int32** | | [optional] [default to null] 10 | **DefaultPort** | **int32** | | [optional] [default to null] 11 | **Ref** | **string** | | [optional] [default to null] 12 | **Content** | [***interface{}**](interface{}.md) | | [optional] [default to null] 13 | **UserInfo** | **string** | | [optional] [default to null] 14 | **File** | **string** | | [optional] [default to null] 15 | **Authority** | **string** | | [optional] [default to null] 16 | **SerializedHashCode** | **int32** | | [optional] [default to null] 17 | **Host** | **string** | | [optional] [default to null] 18 | **Protocol** | **string** | | [optional] [default to null] 19 | 20 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 21 | 22 | 23 | -------------------------------------------------------------------------------- /gateapi/docs/SubnetControllerApi.md: -------------------------------------------------------------------------------- 1 | # \SubnetControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**AllByCloudProviderUsingGET1**](SubnetControllerApi.md#AllByCloudProviderUsingGET1) | **Get** /subnets/{cloudProvider} | Retrieve a list of subnets for a given cloud provider 8 | 9 | 10 | # **AllByCloudProviderUsingGET1** 11 | > []interface{} AllByCloudProviderUsingGET1(ctx, cloudProvider) 12 | Retrieve a list of subnets for a given cloud provider 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **cloudProvider** | **string**| cloudProvider | 20 | 21 | ### Return type 22 | 23 | [**[]interface{}**](interface{}.md) 24 | 25 | ### Authorization 26 | 27 | No authorization required 28 | 29 | ### HTTP request headers 30 | 31 | - **Content-Type**: Not defined 32 | - **Accept**: */* 33 | 34 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 35 | 36 | -------------------------------------------------------------------------------- /gateapi/docs/ReorderPipelinesControllerApi.md: -------------------------------------------------------------------------------- 1 | # \ReorderPipelinesControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**ReorderPipelinesUsingPOST**](ReorderPipelinesControllerApi.md#ReorderPipelinesUsingPOST) | **Post** /actions/pipelines/reorder | Re-order pipelines 8 | 9 | 10 | # **ReorderPipelinesUsingPOST** 11 | > interface{} ReorderPipelinesUsingPOST(ctx, reorderPipelinesCommand) 12 | Re-order pipelines 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **reorderPipelinesCommand** | [**ReorderPipelinesCommand**](ReorderPipelinesCommand.md)| reorderPipelinesCommand | 20 | 21 | ### Return type 22 | 23 | [**interface{}**](interface{}.md) 24 | 25 | ### Authorization 26 | 27 | No authorization required 28 | 29 | ### HTTP request headers 30 | 31 | - **Content-Type**: application/json 32 | - **Accept**: */* 33 | 34 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 35 | 36 | -------------------------------------------------------------------------------- /gateapi/model_file.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "os" 14 | ) 15 | 16 | type File struct { 17 | Executable bool `json:"executable,omitempty"` 18 | LastModified int64 `json:"lastModified,omitempty"` 19 | Directory bool `json:"directory,omitempty"` 20 | Writable bool `json:"writable,omitempty"` 21 | TotalSpace int64 `json:"totalSpace,omitempty"` 22 | Readable bool `json:"readable,omitempty"` 23 | CanonicalFile **os.File `json:"canonicalFile,omitempty"` 24 | FreeSpace int64 `json:"freeSpace,omitempty"` 25 | File bool `json:"file,omitempty"` 26 | Path string `json:"path,omitempty"` 27 | UsableSpace int64 `json:"usableSpace,omitempty"` 28 | AbsolutePath string `json:"absolutePath,omitempty"` 29 | Parent string `json:"parent,omitempty"` 30 | Hidden bool `json:"hidden,omitempty"` 31 | ParentFile **os.File `json:"parentFile,omitempty"` 32 | Absolute bool `json:"absolute,omitempty"` 33 | AbsoluteFile **os.File `json:"absoluteFile,omitempty"` 34 | Name string `json:"name,omitempty"` 35 | CanonicalPath string `json:"canonicalPath,omitempty"` 36 | } 37 | -------------------------------------------------------------------------------- /version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import "fmt" 4 | 5 | // GitCommit string 6 | var GitCommit string 7 | 8 | // Release string 9 | var Release string 10 | 11 | // GateVersion string 12 | var GateVersion string 13 | 14 | // BuiltDate string 15 | var BuiltDate string 16 | 17 | // GoVersion string 18 | var GoVersion string 19 | 20 | type version struct { 21 | major int 22 | minor int 23 | patch int 24 | } 25 | 26 | func (v version) BuildInfo() string { 27 | gateAPIInfo := "\nGate API version:\t" + GateVersion 28 | goInfo := "\nGo version:\t\t" + GoVersion 29 | gitCommitInfo := "\nGit commit:\t\t" + GitCommit 30 | builtDateInfo := "\nBuilt:\t\t\t" + BuiltDate + "\n" 31 | 32 | return "Version:\t\t" + v.Short() + gateAPIInfo + goInfo + gitCommitInfo + builtDateInfo 33 | 34 | } 35 | 36 | func (v version) Short() string { 37 | versionInfo := fmt.Sprintf("%d.%d.%d", v.major, v.minor, v.patch) 38 | if Release != "" { 39 | versionInfo = versionInfo + "-" + Release 40 | } 41 | 42 | return versionInfo 43 | } 44 | 45 | var floodgateVersion = version{ 46 | major: 0, 47 | minor: 3, 48 | patch: 0, 49 | } 50 | 51 | // Short get Floodgate version string 52 | func Short() string { 53 | return floodgateVersion.Short() 54 | } 55 | 56 | // BuildInfo get Floodgate build info 57 | func BuildInfo() string { 58 | return floodgateVersion.BuildInfo() 59 | } 60 | -------------------------------------------------------------------------------- /gateapi/docs/Uri.md: -------------------------------------------------------------------------------- 1 | # Uri 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Opaque** | **bool** | | [optional] [default to null] 7 | **Absolute** | **bool** | | [optional] [default to null] 8 | **Authority** | **string** | | [optional] [default to null] 9 | **UserInfo** | **string** | | [optional] [default to null] 10 | **SchemeSpecificPart** | **string** | | [optional] [default to null] 11 | **Port** | **int32** | | [optional] [default to null] 12 | **Path** | **string** | | [optional] [default to null] 13 | **RawQuery** | **string** | | [optional] [default to null] 14 | **RawAuthority** | **string** | | [optional] [default to null] 15 | **Host** | **string** | | [optional] [default to null] 16 | **RawSchemeSpecificPart** | **string** | | [optional] [default to null] 17 | **Fragment** | **string** | | [optional] [default to null] 18 | **Scheme** | **string** | | [optional] [default to null] 19 | **RawPath** | **string** | | [optional] [default to null] 20 | **Query** | **string** | | [optional] [default to null] 21 | **RawFragment** | **string** | | [optional] [default to null] 22 | **RawUserInfo** | **string** | | [optional] [default to null] 23 | 24 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 25 | 26 | 27 | -------------------------------------------------------------------------------- /gateapi/docs/ServerGroupManagerControllerApi.md: -------------------------------------------------------------------------------- 1 | # \ServerGroupManagerControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetServerGroupManagersForApplicationUsingGET**](ServerGroupManagerControllerApi.md#GetServerGroupManagersForApplicationUsingGET) | **Get** /applications/{application}/serverGroupManagers | Retrieve a list of server group managers for an application 8 | 9 | 10 | # **GetServerGroupManagersForApplicationUsingGET** 11 | > []interface{} GetServerGroupManagersForApplicationUsingGET(ctx, application) 12 | Retrieve a list of server group managers for an application 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **application** | **string**| application | 20 | 21 | ### Return type 22 | 23 | [**[]interface{}**](interface{}.md) 24 | 25 | ### Authorization 26 | 27 | No authorization required 28 | 29 | ### HTTP request headers 30 | 31 | - **Content-Type**: Not defined 32 | - **Accept**: */* 33 | 34 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 35 | 36 | -------------------------------------------------------------------------------- /gateapi/response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | type APIResponse struct { 17 | *http.Response `json:"-"` 18 | Message string `json:"message,omitempty"` 19 | // Operation is the name of the swagger operation. 20 | Operation string `json:"operation,omitempty"` 21 | // RequestURL is the request URL. This value is always available, even if the 22 | // embedded *http.Response is nil. 23 | RequestURL string `json:"url,omitempty"` 24 | // Method is the HTTP method used for the request. This value is always 25 | // available, even if the embedded *http.Response is nil. 26 | Method string `json:"method,omitempty"` 27 | // Payload holds the contents of the response body (which may be nil or empty). 28 | // This is provided here as the raw response.Body() reader will have already 29 | // been drained. 30 | Payload []byte `json:"-"` 31 | } 32 | 33 | func NewAPIResponse(r *http.Response) *APIResponse { 34 | 35 | response := &APIResponse{Response: r} 36 | return response 37 | } 38 | 39 | func NewAPIResponseWithError(errorMessage string) *APIResponse { 40 | 41 | response := &APIResponse{Message: errorMessage} 42 | return response 43 | } 44 | -------------------------------------------------------------------------------- /gateapi/docs/PluginPublishControllerApi.md: -------------------------------------------------------------------------------- 1 | # \PluginPublishControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**PublishPluginUsingPOST**](PluginPublishControllerApi.md#PublishPluginUsingPOST) | **Post** /plugins/publish/{pluginId}/{pluginVersion} | Publish a plugin binary and the plugin info metadata. 8 | 9 | 10 | # **PublishPluginUsingPOST** 11 | > PublishPluginUsingPOST(ctx, plugin, pluginId, pluginInfo, pluginVersion) 12 | Publish a plugin binary and the plugin info metadata. 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **plugin** | ***os.File**| plugin | 20 | **pluginId** | **string**| pluginId | 21 | **pluginInfo** | [**interface{}**](.md)| pluginInfo | 22 | **pluginVersion** | **string**| pluginVersion | 23 | 24 | ### Return type 25 | 26 | (empty response body) 27 | 28 | ### Authorization 29 | 30 | No authorization required 31 | 32 | ### HTTP request headers 33 | 34 | - **Content-Type**: multipart/form-data 35 | - **Accept**: */* 36 | 37 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 38 | 39 | -------------------------------------------------------------------------------- /cmd/render.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "io" 5 | 6 | c "github.com/codilime/floodgate/config" 7 | fl "github.com/codilime/floodgate/parser/fileloader" 8 | rm "github.com/codilime/floodgate/resourcemanager" 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // renderOptions store render command options 13 | type renderOptions struct { 14 | outDir string 15 | } 16 | 17 | // NewRenderCmd create new render command 18 | func NewRenderCmd(out io.Writer) *cobra.Command { 19 | options := renderOptions{} 20 | cmd := &cobra.Command{ 21 | Use: "render", 22 | Short: "Render Jsonnet files", 23 | Long: "Render Jsonnet files", 24 | RunE: func(cmd *cobra.Command, args []string) error { 25 | return runRender(cmd, options) 26 | }, 27 | } 28 | cmd.Flags().StringVarP(&options.outDir, "output-dir", "o", "", "output directory (required)") 29 | cmd.MarkFlagRequired("output-dir") 30 | return cmd 31 | } 32 | 33 | func runRender(cmd *cobra.Command, options renderOptions) error { 34 | flags := cmd.InheritedFlags() 35 | configPath, err := flags.GetString("config") 36 | if err != nil { 37 | return err 38 | } 39 | config, err := c.LoadConfig(configPath) 40 | if err != nil { 41 | return err 42 | } 43 | config.Merge(cfg) 44 | resourceManager := rm.ResourceManager{} 45 | resourceManager.Init(config, rm.FileLoaders(true, fl.NewJsonnetLoader(config.Libraries...))) 46 | if err := resourceManager.SaveResources(options.outDir); err != nil { 47 | return err 48 | } 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /gateapi/docs/EcsServerGroupEventsControllerApi.md: -------------------------------------------------------------------------------- 1 | # \EcsServerGroupEventsControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetEventsUsingGET**](EcsServerGroupEventsControllerApi.md#GetEventsUsingGET) | **Get** /applications/{application}/serverGroups/{account}/{serverGroupName}/events | Retrieves a list of events for a server group 8 | 9 | 10 | # **GetEventsUsingGET** 11 | > []interface{} GetEventsUsingGET(ctx, account, application, provider, region, serverGroupName) 12 | Retrieves a list of events for a server group 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **account** | **string**| account | 20 | **application** | **string**| application | 21 | **provider** | **string**| provider | 22 | **region** | **string**| region | 23 | **serverGroupName** | **string**| serverGroupName | 24 | 25 | ### Return type 26 | 27 | [**[]interface{}**](interface{}.md) 28 | 29 | ### Authorization 30 | 31 | No authorization required 32 | 33 | ### HTTP request headers 34 | 35 | - **Content-Type**: Not defined 36 | - **Accept**: */* 37 | 38 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 39 | 40 | -------------------------------------------------------------------------------- /gateapi/docs/File.md: -------------------------------------------------------------------------------- 1 | # File 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **Executable** | **bool** | | [optional] [default to null] 7 | **LastModified** | **int64** | | [optional] [default to null] 8 | **Directory** | **bool** | | [optional] [default to null] 9 | **Writable** | **bool** | | [optional] [default to null] 10 | **TotalSpace** | **int64** | | [optional] [default to null] 11 | **Readable** | **bool** | | [optional] [default to null] 12 | **CanonicalFile** | [****os.File**](*os.File.md) | | [optional] [default to null] 13 | **FreeSpace** | **int64** | | [optional] [default to null] 14 | **File** | **bool** | | [optional] [default to null] 15 | **Path** | **string** | | [optional] [default to null] 16 | **UsableSpace** | **int64** | | [optional] [default to null] 17 | **AbsolutePath** | **string** | | [optional] [default to null] 18 | **Parent** | **string** | | [optional] [default to null] 19 | **Hidden** | **bool** | | [optional] [default to null] 20 | **ParentFile** | [****os.File**](*os.File.md) | | [optional] [default to null] 21 | **Absolute** | **bool** | | [optional] [default to null] 22 | **AbsoluteFile** | [****os.File**](*os.File.md) | | [optional] [default to null] 23 | **Name** | **string** | | [optional] [default to null] 24 | **CanonicalPath** | **string** | | [optional] [default to null] 25 | 26 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 27 | 28 | 29 | -------------------------------------------------------------------------------- /gateapi/docs/CiControllerApi.md: -------------------------------------------------------------------------------- 1 | # \CiControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetBuildsUsingGET1**](CiControllerApi.md#GetBuildsUsingGET1) | **Get** /ci/builds | getBuilds 8 | 9 | 10 | # **GetBuildsUsingGET1** 11 | > []interface{} GetBuildsUsingGET1(ctx, projectKey, repoSlug, optional) 12 | getBuilds 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **projectKey** | **string**| projectKey | 20 | **repoSlug** | **string**| repoSlug | 21 | **optional** | ***GetBuildsUsingGET1Opts** | optional parameters | nil if no parameters 22 | 23 | ### Optional Parameters 24 | Optional parameters are passed through a pointer to a GetBuildsUsingGET1Opts struct 25 | 26 | Name | Type | Description | Notes 27 | ------------- | ------------- | ------------- | ------------- 28 | 29 | 30 | **completionStatus** | **optional.String**| completionStatus | 31 | 32 | ### Return type 33 | 34 | [**[]interface{}**](interface{}.md) 35 | 36 | ### Authorization 37 | 38 | No authorization required 39 | 40 | ### HTTP request headers 41 | 42 | - **Content-Type**: Not defined 43 | - **Accept**: */* 44 | 45 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 46 | 47 | -------------------------------------------------------------------------------- /parser/fileloader/jsonloader_test.go: -------------------------------------------------------------------------------- 1 | package fileloader 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestJSONLoader_LoadFile(t *testing.T) { 9 | type args struct { 10 | filePath string 11 | } 12 | tests := []struct { 13 | name string 14 | args args 15 | want []map[string]interface{} 16 | wantErr bool 17 | }{ 18 | { 19 | name: "load json file", 20 | args: args{ 21 | filePath: "testdata/testfile.json", 22 | }, 23 | want: testJSONFIle, 24 | wantErr: false, 25 | }, 26 | } 27 | for _, tt := range tests { 28 | t.Run(tt.name, func(t *testing.T) { 29 | jl := &JSONLoader{} 30 | got, err := jl.LoadFile(tt.args.filePath) 31 | if (err != nil) != tt.wantErr { 32 | t.Errorf("JSONLoader.LoadFile() error = %v, wantErr %v", err, tt.wantErr) 33 | return 34 | } 35 | if !reflect.DeepEqual(got, tt.want) { 36 | t.Errorf("JSONLoader.LoadFile() = %v, want %v", got, tt.want) 37 | } 38 | }) 39 | } 40 | } 41 | 42 | func TestJSONLoader_SupportedFileExtensions(t *testing.T) { 43 | tests := []struct { 44 | name string 45 | want []string 46 | }{ 47 | { 48 | name: "support .json file extension", 49 | want: []string{".json"}, 50 | }, 51 | } 52 | for _, tt := range tests { 53 | t.Run(tt.name, func(t *testing.T) { 54 | jl := &JSONLoader{} 55 | if got := jl.SupportedFileExtensions(); !reflect.DeepEqual(got, tt.want) { 56 | t.Errorf("JSONLoader.SupportedFileExtensions() = %v, want %v", got, tt.want) 57 | } 58 | }) 59 | } 60 | } 61 | 62 | var testJSONFIle = []map[string]interface{}{{ 63 | "name": "testjson", 64 | "variable": false, 65 | }} 66 | -------------------------------------------------------------------------------- /gateapi/docs/PluginsInstalledControllerApi.md: -------------------------------------------------------------------------------- 1 | # \PluginsInstalledControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetInstalledPluginsUsingGET**](PluginsInstalledControllerApi.md#GetInstalledPluginsUsingGET) | **Get** /plugins/installed | Get all installed Spinnaker plugins 8 | 9 | 10 | # **GetInstalledPluginsUsingGET** 11 | > map[string][]SpinnakerPluginDescriptor GetInstalledPluginsUsingGET(ctx, optional) 12 | Get all installed Spinnaker plugins 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **optional** | ***GetInstalledPluginsUsingGETOpts** | optional parameters | nil if no parameters 20 | 21 | ### Optional Parameters 22 | Optional parameters are passed through a pointer to a GetInstalledPluginsUsingGETOpts struct 23 | 24 | Name | Type | Description | Notes 25 | ------------- | ------------- | ------------- | ------------- 26 | **service** | **optional.String**| service | 27 | 28 | ### Return type 29 | 30 | [**map[string][]SpinnakerPluginDescriptor**](array.md) 31 | 32 | ### Authorization 33 | 34 | No authorization required 35 | 36 | ### HTTP request headers 37 | 38 | - **Content-Type**: Not defined 39 | - **Accept**: */* 40 | 41 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 42 | 43 | -------------------------------------------------------------------------------- /config/auth/auth.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import "golang.org/x/oauth2" 4 | 5 | // Config represents object for authentication 6 | type Config struct { 7 | Basic Basic `json:"basic"` 8 | OAuth2 OAuth2 `json:"oauth2"` 9 | X509 X509 `json:"x509"` 10 | } 11 | 12 | // Basic represents object for basic authentication 13 | type Basic struct { 14 | Enabled bool `json:"enabled"` 15 | User string `json:"user"` 16 | Password string `json:"password"` 17 | } 18 | 19 | // OAuth2 represents object for oauth2 authentication 20 | type OAuth2 struct { 21 | Enabled bool `json:"enabled"` 22 | TokenURL string `json:"tokenUrl"` 23 | AuthURL string `json:"authUrl"` 24 | ClientID string `json:"clientId"` 25 | ClientSecret string `json:"clientSecret"` 26 | Scopes []string `json:"scopes"` 27 | CachedToken oauth2.Token `json:"cachedToken,omitempty"` 28 | } 29 | 30 | // X509 represents object for x509 authentication 31 | type X509 struct { 32 | Enabled bool `json:"enabled"` 33 | CertPath string `json:"certPath"` 34 | KeyPath string `json:"keyPath"` 35 | Cert string `json:"cert"` 36 | Key string `json:"key"` 37 | } 38 | 39 | // IsValid is used to check if is only one auth method selected 40 | func (config *Config) IsValid() bool { 41 | if config.Basic.Enabled && config.OAuth2.Enabled { 42 | return false 43 | } 44 | 45 | if config.Basic.Enabled && config.X509.Enabled { 46 | return false 47 | } 48 | 49 | if config.OAuth2.Enabled && config.X509.Enabled { 50 | return false 51 | } 52 | 53 | if !config.Basic.Enabled && !config.OAuth2.Enabled && !config.X509.Enabled { 54 | return false 55 | } 56 | 57 | return true 58 | } 59 | -------------------------------------------------------------------------------- /cmd/inspect.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | c "github.com/codilime/floodgate/config" 8 | rm "github.com/codilime/floodgate/resourcemanager" 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // inspectOptions store inspect command options 13 | type inspectOptions struct { 14 | } 15 | 16 | // NewInspectCmd create new inspect command 17 | func NewInspectCmd(out io.Writer) *cobra.Command { 18 | options := inspectOptions{} 19 | cmd := &cobra.Command{ 20 | Use: "inspect", 21 | Short: "Inspect resources' status on Spinnaker", 22 | Long: "Inspect resources' status on Spinnaker", 23 | RunE: func(cmd *cobra.Command, args []string) error { 24 | return runInspect(cmd, options) 25 | }, 26 | } 27 | return cmd 28 | } 29 | 30 | func runInspect(cmd *cobra.Command, options inspectOptions) error { 31 | flags := cmd.InheritedFlags() 32 | configPath, err := flags.GetString("config") 33 | if err != nil { 34 | return err 35 | } 36 | config, err := c.LoadConfig(configPath) 37 | if err != nil { 38 | return err 39 | } 40 | config.Merge(cfg) 41 | resourceManager := &rm.ResourceManager{} 42 | if err := resourceManager.Init(config); err != nil { 43 | return err 44 | } 45 | fmt.Fprintln(cmd.OutOrStdout(), "Current Spinnaker resource status:") 46 | fmt.Fprintln(cmd.OutOrStdout(), "\nApplications:") 47 | fmt.Fprintln(cmd.OutOrStdout(), resourceManager.GetAllApplicationsRemoteState()) 48 | fmt.Fprintln(cmd.OutOrStdout(), "\nPipelines:") 49 | fmt.Fprintln(cmd.OutOrStdout(), resourceManager.GetAllPipelinesRemoteState()) 50 | fmt.Fprintln(cmd.OutOrStdout(), "\nPipeline templates:") 51 | fmt.Fprintln(cmd.OutOrStdout(), resourceManager.GetAllPipelineTemplatesRemoteState()) 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /cmd/download.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | c "github.com/codilime/floodgate/config" 5 | pm "github.com/codilime/floodgate/projectmanager" 6 | "github.com/spf13/cobra" 7 | "io" 8 | ) 9 | 10 | // downloadOptions store download command options 11 | type downloadOptions struct { 12 | projectName string 13 | outDir string 14 | } 15 | 16 | // NewDownloadCmd create new download command 17 | func NewDownloadCmd(out io.Writer) *cobra.Command { 18 | options := downloadOptions{} 19 | cmd := &cobra.Command{ 20 | Use: "download", 21 | Short: "Download all resources related to provided project name", 22 | Long: "Download all resources related to provided project name", 23 | RunE: func(cmd *cobra.Command, args []string) error { 24 | return runDownload(cmd, options) 25 | }, 26 | } 27 | cmd.Flags().StringVarP(&options.projectName, "project-name", "p", "", "project name (required)") 28 | cmd.Flags().StringVarP(&options.outDir, "output-dir", "o", "", "output directory (required)") 29 | 30 | cmd.MarkFlagRequired("project-name") 31 | cmd.MarkFlagRequired("output-dir") 32 | return cmd 33 | } 34 | 35 | func runDownload(cmd *cobra.Command, options downloadOptions) error { 36 | flags := cmd.InheritedFlags() 37 | configPath, err := flags.GetString("config") 38 | if err != nil { 39 | return err 40 | } 41 | 42 | config, err := c.LoadConfig(configPath) 43 | if err != nil { 44 | return err 45 | } 46 | config.Merge(cfg) 47 | 48 | projectManager := pm.ProjectManager{} 49 | 50 | if err := projectManager.Init(config, options.projectName); err != nil { 51 | return err 52 | } 53 | 54 | if err := projectManager.SaveResources(options.outDir); err != nil { 55 | return err 56 | } 57 | 58 | return nil 59 | } 60 | -------------------------------------------------------------------------------- /parser/fileloader/jsonnetloader.go: -------------------------------------------------------------------------------- 1 | package fileloader 2 | 3 | import ( 4 | "encoding/json" 5 | "io/ioutil" 6 | 7 | "github.com/google/go-jsonnet" 8 | ) 9 | 10 | // NewJsonnetLoader create loader 11 | func NewJsonnetLoader(librariesPaths ...string) *JsonnetLoader { 12 | parser := &JsonnetLoader{} 13 | parser.VM = jsonnet.MakeVM() 14 | parser.VM.Importer(&jsonnet.FileImporter{JPaths: librariesPaths}) 15 | return parser 16 | } 17 | 18 | // JsonnetLoader load jsonnet files 19 | type JsonnetLoader struct { 20 | *jsonnet.VM 21 | } 22 | 23 | // LoadFile load file 24 | func (jl *JsonnetLoader) LoadFile(filePath string) ([]map[string]interface{}, error) { 25 | inputFile, err := ioutil.ReadFile(filePath) 26 | if err != nil { 27 | return nil, err 28 | } 29 | // EvaluateSnippetStream fails if generated output does not fit into a slice... 30 | snippetStream, err := jl.EvaluateSnippetStream(filePath, string(inputFile)) 31 | if err != nil { 32 | // ...at which point we evaluate it as a single object and let further processing take care 33 | evaluatedSingleSnippet, err := jl.EvaluateSnippet(filePath, string(inputFile)) 34 | if err != nil { 35 | return nil, err 36 | } 37 | // wrap the single object in slice to keep interface intact 38 | snippetStream = []string{evaluatedSingleSnippet} 39 | } 40 | var output []map[string]interface{} 41 | for i := range snippetStream { 42 | var partial map[string]interface{} 43 | json.Unmarshal([]byte(snippetStream[i]), &partial) 44 | output = append(output, partial) 45 | } 46 | return output, nil 47 | } 48 | 49 | // SupportedFileExtensions get list of supported file extensions 50 | func (jl *JsonnetLoader) SupportedFileExtensions() []string { 51 | return []string{".jsonnet"} 52 | } 53 | -------------------------------------------------------------------------------- /gateclient/x509.go: -------------------------------------------------------------------------------- 1 | package gateclient 2 | 3 | import ( 4 | "crypto/tls" 5 | "crypto/x509" 6 | "errors" 7 | "github.com/codilime/floodgate/config" 8 | "github.com/mitchellh/go-homedir" 9 | "io/ioutil" 10 | "net/http" 11 | ) 12 | 13 | // X509Authenticate is used to authenticate using x509 14 | func X509Authenticate(httpClient *http.Client, floodgateConfig *config.Config) (*http.Client, error) { 15 | x509Config := floodgateConfig.Auth.X509 16 | 17 | var cert tls.Certificate 18 | var clientCA []byte 19 | var err error 20 | certPool := x509.NewCertPool() 21 | 22 | if x509Config.CertPath != "" || x509Config.KeyPath != "" { 23 | certFullPath, err := homedir.Expand(x509Config.CertPath) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | keyFullPath, err := homedir.Expand(x509Config.KeyPath) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | cert, err = tls.LoadX509KeyPair(certFullPath, keyFullPath) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | clientCA, err = ioutil.ReadFile(certFullPath) 39 | if err != nil { 40 | return nil, err 41 | } 42 | } 43 | 44 | if x509Config.Cert != "" || x509Config.Key != "" { 45 | clientCA = []byte(x509Config.Cert) 46 | 47 | cert, err = tls.X509KeyPair(clientCA, []byte(x509Config.Key)) 48 | if err != nil { 49 | return nil, err 50 | } 51 | } 52 | 53 | ok := certPool.AppendCertsFromPEM(clientCA) 54 | if !ok { 55 | return nil, errors.New("certificate is not valid") 56 | } 57 | 58 | clientTransport := httpClient.Transport.(*http.Transport) 59 | clientTransport.TLSClientConfig.MinVersion = tls.VersionTLS12 60 | clientTransport.TLSClientConfig.PreferServerCipherSuites = true 61 | clientTransport.TLSClientConfig.Certificates = []tls.Certificate{cert} 62 | 63 | return httpClient, nil 64 | } 65 | -------------------------------------------------------------------------------- /gateapi/docs/JobControllerApi.md: -------------------------------------------------------------------------------- 1 | # \JobControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetJobUsingGET**](JobControllerApi.md#GetJobUsingGET) | **Get** /applications/{applicationName}/jobs/{account}/{region}/{name} | Get job 8 | 9 | 10 | # **GetJobUsingGET** 11 | > map[string]interface{} GetJobUsingGET(ctx, account, applicationName, name, region, optional) 12 | Get job 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **account** | **string**| account | 20 | **applicationName** | **string**| applicationName | 21 | **name** | **string**| name | 22 | **region** | **string**| region | 23 | **optional** | ***GetJobUsingGETOpts** | optional parameters | nil if no parameters 24 | 25 | ### Optional Parameters 26 | Optional parameters are passed through a pointer to a GetJobUsingGETOpts struct 27 | 28 | Name | Type | Description | Notes 29 | ------------- | ------------- | ------------- | ------------- 30 | 31 | 32 | 33 | 34 | **xRateLimitApp** | **optional.String**| X-RateLimit-App | 35 | **expand** | **optional.String**| expand | [default to false] 36 | 37 | ### Return type 38 | 39 | [**map[string]interface{}**](interface{}.md) 40 | 41 | ### Authorization 42 | 43 | No authorization required 44 | 45 | ### HTTP request headers 46 | 47 | - **Content-Type**: Not defined 48 | - **Accept**: */* 49 | 50 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 51 | 52 | -------------------------------------------------------------------------------- /gateapi/docs/SearchControllerApi.md: -------------------------------------------------------------------------------- 1 | # \SearchControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**SearchUsingGET**](SearchControllerApi.md#SearchUsingGET) | **Get** /search | Search infrastructure 8 | 9 | 10 | # **SearchUsingGET** 11 | > []interface{} SearchUsingGET(ctx, type_, optional) 12 | Search infrastructure 13 | 14 | ### Required Parameters 15 | 16 | Name | Type | Description | Notes 17 | ------------- | ------------- | ------------- | ------------- 18 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 19 | **type_** | **string**| type | 20 | **optional** | ***SearchUsingGETOpts** | optional parameters | nil if no parameters 21 | 22 | ### Optional Parameters 23 | Optional parameters are passed through a pointer to a SearchUsingGETOpts struct 24 | 25 | Name | Type | Description | Notes 26 | ------------- | ------------- | ------------- | ------------- 27 | 28 | **xRateLimitApp** | **optional.String**| X-RateLimit-App | 29 | **allowShortQuery** | **optional.Bool**| allowShortQuery | [default to false] 30 | **page** | **optional.Int32**| page | [default to 1] 31 | **pageSize** | **optional.Int32**| pageSize | [default to 10000] 32 | **platform** | **optional.String**| platform | 33 | **q** | **optional.String**| q | 34 | 35 | ### Return type 36 | 37 | [**[]interface{}**](interface{}.md) 38 | 39 | ### Authorization 40 | 41 | No authorization required 42 | 43 | ### HTTP request headers 44 | 45 | - **Content-Type**: Not defined 46 | - **Accept**: */* 47 | 48 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 49 | 50 | -------------------------------------------------------------------------------- /util/utils_test.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestCombineErrors(t *testing.T) { 9 | tests := []struct { 10 | name string 11 | errors []error 12 | want error 13 | }{ 14 | { 15 | name: "no errors", 16 | errors: []error{}, 17 | want: nil, 18 | }, 19 | { 20 | name: "one nil error", 21 | errors: []error{nil}, 22 | want: nil, 23 | }, 24 | { 25 | name: "multiple nil errors", 26 | errors: []error{nil, nil}, 27 | want: nil, 28 | }, 29 | { 30 | name: "one error", 31 | errors: []error{fmt.Errorf("test error")}, 32 | want: fmt.Errorf("test error"), 33 | }, 34 | { 35 | name: "error followed by nil error", 36 | errors: []error{fmt.Errorf("test error"), nil}, 37 | want: fmt.Errorf("test error"), 38 | }, 39 | { 40 | name: "nil error followed by error", 41 | errors: []error{nil, fmt.Errorf("test error")}, 42 | want: fmt.Errorf("test error"), 43 | }, 44 | { 45 | name: "multiple errors", 46 | errors: []error{fmt.Errorf("first test error"), fmt.Errorf("second test error")}, 47 | want: fmt.Errorf("first test error, second test error"), 48 | }, 49 | } 50 | 51 | for _, tt := range tests { 52 | t.Run(tt.name, func(t *testing.T) { 53 | got := CombineErrors(tt.errors) 54 | assertError(t, got, tt.want) 55 | }) 56 | } 57 | } 58 | 59 | func assertNoError(t *testing.T, got error) { 60 | t.Helper() 61 | if got != nil { 62 | t.Fatal("got an error but didn't want one") 63 | } 64 | } 65 | 66 | func assertError(t *testing.T, got error, want error) { 67 | t.Helper() 68 | if want == nil { 69 | assertNoError(t, got) 70 | return 71 | } 72 | if got == nil { 73 | t.Fatal("didn't get an error but wanted one") 74 | } 75 | 76 | if got.Error() != want.Error() { 77 | t.Errorf("got %q, want %q", got, want) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /gateapi/git_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ 3 | # 4 | # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" 5 | 6 | git_user_id=$1 7 | git_repo_id=$2 8 | release_note=$3 9 | 10 | if [ "$git_user_id" = "" ]; then 11 | git_user_id="GIT_USER_ID" 12 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" 13 | fi 14 | 15 | if [ "$git_repo_id" = "" ]; then 16 | git_repo_id="GIT_REPO_ID" 17 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" 18 | fi 19 | 20 | if [ "$release_note" = "" ]; then 21 | release_note="Minor update" 22 | echo "[INFO] No command line input provided. Set \$release_note to $release_note" 23 | fi 24 | 25 | # Initialize the local directory as a Git repository 26 | git init 27 | 28 | # Adds the files in the local repository and stages them for commit. 29 | git add . 30 | 31 | # Commits the tracked changes and prepares them to be pushed to a remote repository. 32 | git commit -m "$release_note" 33 | 34 | # Sets the new remote 35 | git_remote=`git remote` 36 | if [ "$git_remote" = "" ]; then # git remote not defined 37 | 38 | if [ "$GIT_TOKEN" = "" ]; then 39 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." 40 | git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git 41 | else 42 | git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git 43 | fi 44 | 45 | fi 46 | 47 | git pull origin master 48 | 49 | # Pushes (Forces) the changes in the local repository up to the remote repository 50 | echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" 51 | git push origin master 2>&1 | grep -v 'To https' 52 | 53 | -------------------------------------------------------------------------------- /cmd/compare.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "io" 7 | 8 | c "github.com/codilime/floodgate/config" 9 | rm "github.com/codilime/floodgate/resourcemanager" 10 | "github.com/spf13/cobra" 11 | ) 12 | 13 | // compareOptions store compare command options 14 | type compareOptions struct { 15 | } 16 | 17 | // NewCompareCmd create new compare command 18 | func NewCompareCmd(out io.Writer) *cobra.Command { 19 | options := compareOptions{} 20 | cmd := &cobra.Command{ 21 | Use: "compare", 22 | Short: "Compare local resources' definitions with Spinnaker and show discrepancies", 23 | Long: "Compare local resources' definitions with Spinnaker and show discrepancies", 24 | RunE: func(cmd *cobra.Command, args []string) error { 25 | return runCompare(cmd, options) 26 | }, 27 | } 28 | return cmd 29 | } 30 | 31 | func runCompare(cmd *cobra.Command, options compareOptions) error { 32 | flags := cmd.InheritedFlags() 33 | configPath, err := flags.GetString("config") 34 | if err != nil { 35 | return err 36 | } 37 | config, err := c.LoadConfig(configPath) 38 | if err != nil { 39 | return err 40 | } 41 | config.Merge(cfg) 42 | resourceManager := &rm.ResourceManager{} 43 | if err := resourceManager.Init(config); err != nil { 44 | return err 45 | } 46 | changes := resourceManager.GetChanges() 47 | if len(changes) == 0 { 48 | return nil 49 | } 50 | 51 | printCompareDiff(cmd.OutOrStdout(), changes) 52 | return errors.New("end diff") 53 | } 54 | 55 | func printCompareDiff(out io.Writer, changes []rm.ResourceChange) { 56 | for _, change := range changes { 57 | var line string 58 | if change.ID != "" { 59 | line = fmt.Sprintf("%s (%s) (%s)", change.ID, change.Name, change.Type) 60 | } else { 61 | line = fmt.Sprintf("%s (%s)", change.Name, change.Type) 62 | } 63 | fmt.Fprintln(out, line) 64 | fmt.Fprintln(out, change.Changes) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /parser/fileloader/yamlloader_test.go: -------------------------------------------------------------------------------- 1 | package fileloader 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestYAMLLoader_LoadFile(t *testing.T) { 9 | type args struct { 10 | filePath string 11 | } 12 | tests := []struct { 13 | name string 14 | args args 15 | want []map[string]interface{} 16 | wantErr bool 17 | }{ 18 | { 19 | name: "load .yaml file", 20 | args: args{ 21 | filePath: "testdata/testfile.yaml", 22 | }, 23 | want: testYAMLFile, 24 | wantErr: false, 25 | }, 26 | { 27 | name: "load .yml file", 28 | args: args{ 29 | filePath: "testdata/testfile.yml", 30 | }, 31 | want: testYMLFile, 32 | wantErr: false, 33 | }, 34 | } 35 | for _, tt := range tests { 36 | t.Run(tt.name, func(t *testing.T) { 37 | yl := &YAMLLoader{} 38 | got, err := yl.LoadFile(tt.args.filePath) 39 | if (err != nil) != tt.wantErr { 40 | t.Errorf("YAMLLoader.LoadFile() error = %v, wantErr %v", err, tt.wantErr) 41 | return 42 | } 43 | if !reflect.DeepEqual(got, tt.want) { 44 | t.Errorf("YAMLLoader.LoadFile() = %v, want %v", got, tt.want) 45 | } 46 | }) 47 | } 48 | } 49 | 50 | func TestYAMLLoader_SupportedFileExtensions(t *testing.T) { 51 | tests := []struct { 52 | name string 53 | want []string 54 | }{ 55 | { 56 | name: "support .yaml and .yml file extensions", 57 | want: []string{".yaml", ".yml"}, 58 | }, 59 | } 60 | for _, tt := range tests { 61 | t.Run(tt.name, func(t *testing.T) { 62 | yl := &YAMLLoader{} 63 | if got := yl.SupportedFileExtensions(); !reflect.DeepEqual(got, tt.want) { 64 | t.Errorf("YAMLLoader.SupportedFileExtensions() = %v, want %v", got, tt.want) 65 | } 66 | }) 67 | } 68 | } 69 | 70 | var testYAMLFile = []map[string]interface{}{{ 71 | "name": "testyaml", 72 | "variable": false, 73 | }} 74 | 75 | var testYMLFile = []map[string]interface{}{{ 76 | "name": "testyml", 77 | "variable": false, 78 | }} 79 | -------------------------------------------------------------------------------- /util/asserts.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // AssertMapKeyExists check wheter or not map contains a key 9 | func AssertMapKeyExists(object map[string]interface{}, key string) error { 10 | _, exists := object[key] 11 | if exists != true { 12 | return fmt.Errorf("required key '%v' missing", key) 13 | } 14 | return nil 15 | } 16 | 17 | // AssertMapKeyIsString check wheter or not map contains a key 18 | func AssertMapKeyIsString(object map[string]interface{}, key string, notEmpty bool) error { 19 | if err := AssertMapKeyExists(object, key); err != nil { 20 | return err 21 | } 22 | value, ok := object[key].(string) 23 | if ok != true { 24 | return fmt.Errorf("required key '%v' must be a string", key) 25 | } 26 | if notEmpty && strings.TrimSpace(value) == "" { 27 | return fmt.Errorf("required key '%v' must not be empty or be a string consisting only of spaces", key) 28 | } 29 | return nil 30 | } 31 | 32 | // AssertMapKeyIsStringMap check whether or not map contains a key 33 | func AssertMapKeyIsStringMap(object map[string]interface{}, key string, notEmpty bool) error { 34 | if err := AssertMapKeyExists(object, key); err != nil { 35 | return err 36 | } 37 | value, ok := object[key].(map[string]interface{}) 38 | if ok != true { 39 | return fmt.Errorf("required key '%v' must be a map", key) 40 | } 41 | if notEmpty && len(value) == 0 { 42 | return fmt.Errorf("required key '%v' must not be empty", key) 43 | } 44 | return nil 45 | } 46 | 47 | // AssertMapKeyIsInterfaceArray check whether or not map contains a key 48 | func AssertMapKeyIsInterfaceArray(object map[string]interface{}, key string, notEmpty bool) error { 49 | if err := AssertMapKeyExists(object, key); err != nil { 50 | return err 51 | } 52 | value, ok := object[key].([]interface{}) 53 | if ok != true { 54 | return fmt.Errorf("required key '%v' must be an array", key) 55 | } 56 | if notEmpty && len(value) == 0 { 57 | return fmt.Errorf("required key '%v' must not be empty", key) 58 | } 59 | return nil 60 | } 61 | -------------------------------------------------------------------------------- /cmd/render_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "github.com/codilime/floodgate/test" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "path" 10 | "strings" 11 | "testing" 12 | ) 13 | 14 | func TestRender(t *testing.T) { 15 | mux := http.NewServeMux() 16 | mux.HandleFunc("/auth/loggedOut", test.MockGateServerAuthLoggedOutHandler) 17 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 18 | w.Write([]byte("{}")) 19 | }) 20 | 21 | ts := httptest.NewServer(mux) 22 | 23 | dir, config, err := CreateTempFiles(ts.URL, true) 24 | if err != nil { 25 | t.Errorf("cmd.Render() Error while creating temp config %v", err) 26 | } 27 | defer RemoveTempDir(dir) 28 | 29 | b := bytes.NewBufferString("") 30 | cmd := NewRootCmd(b) 31 | cmd.SetOut(b) 32 | 33 | cmd.SetArgs([]string{"--verbose", "--config=" + config, "render", "-o", path.Join(dir, "renderOutput")}) 34 | 35 | err = cmd.Execute() 36 | if err != nil { 37 | t.Fatalf("cmd.Render() Execute err: %v", err) 38 | } 39 | 40 | renderDir := path.Join(dir, "renderOutput") 41 | files, err := ioutil.ReadDir(path.Join(renderDir, "pipelines")) 42 | if err != nil { 43 | t.Fatalf("cmd.Render() Read dir err: %v", err) 44 | } 45 | 46 | renderPipelineFile := "jsonnetpipeline.json" 47 | for _, file := range files { 48 | if file.Name() != renderPipelineFile { 49 | t.Errorf("cmd.Render() Could not find jsonnetpipeline.json in render directory") 50 | } 51 | 52 | content, err := ioutil.ReadFile(path.Join(renderDir, "pipelines", renderPipelineFile)) 53 | if err != nil { 54 | t.Fatalf("cmd.Render() Cannot read file %s err: %v", renderPipelineFile, err) 55 | } 56 | 57 | contentStr := strings.TrimSpace(string(content)) 58 | if contentStr != renderWant { 59 | t.Errorf("cmd.Render() got:\n %s want:\n %s", contentStr, inspectWant) 60 | } 61 | } 62 | } 63 | 64 | var renderWant = "{\n\t\"application\": \"jsonnetapp\",\n\t\"id\": \"jsonnetpipeline\",\n\t\"keepWaitingPipelines\": false,\n\t\"limitConcurrent\": true,\n\t\"name\": \"Example pipeline from Jsonnet\",\n\t\"notifications\": [],\n\t\"stages\": [],\n\t\"triggers\": []\n}" 65 | -------------------------------------------------------------------------------- /parser/fileloader/jsonnetloader_test.go: -------------------------------------------------------------------------------- 1 | package fileloader 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | 7 | "github.com/google/go-jsonnet" 8 | ) 9 | 10 | func TestJsonnetLoader_LoadFile(t *testing.T) { 11 | type fields struct { 12 | VM *jsonnet.VM 13 | } 14 | type args struct { 15 | filePath string 16 | } 17 | vmWithLib := jsonnet.MakeVM() 18 | vmWithLib.Importer(&jsonnet.FileImporter{JPaths: []string{"testdata/testjsonnetlib.libsonnet"}}) 19 | tests := []struct { 20 | name string 21 | fields fields 22 | args args 23 | want []map[string]interface{} 24 | wantErr bool 25 | }{ 26 | { 27 | name: "load .jsonnet file", 28 | fields: fields{ 29 | VM: vmWithLib, 30 | }, 31 | args: args{ 32 | filePath: "testdata/testfile.jsonnet", 33 | }, 34 | want: testJsonnetFile, 35 | wantErr: false, 36 | }, 37 | } 38 | for _, tt := range tests { 39 | t.Run(tt.name, func(t *testing.T) { 40 | jl := &JsonnetLoader{ 41 | VM: tt.fields.VM, 42 | } 43 | got, err := jl.LoadFile(tt.args.filePath) 44 | if (err != nil) != tt.wantErr { 45 | t.Errorf("JsonnetLoader.LoadFile() error = %v, wantErr %v", err, tt.wantErr) 46 | return 47 | } 48 | if !reflect.DeepEqual(got, tt.want) { 49 | t.Errorf("JsonnetLoader.LoadFile() = %v, want %v", got, tt.want) 50 | } 51 | }) 52 | } 53 | } 54 | 55 | func TestJsonnetLoader_SupportedFileExtensions(t *testing.T) { 56 | type fields struct { 57 | VM *jsonnet.VM 58 | } 59 | tests := []struct { 60 | name string 61 | fields fields 62 | want []string 63 | }{ 64 | { 65 | name: "support .jsonnet file extension", 66 | want: []string{".jsonnet"}, 67 | }, 68 | } 69 | for _, tt := range tests { 70 | t.Run(tt.name, func(t *testing.T) { 71 | jl := &JsonnetLoader{ 72 | VM: tt.fields.VM, 73 | } 74 | if got := jl.SupportedFileExtensions(); !reflect.DeepEqual(got, tt.want) { 75 | t.Errorf("JsonnetLoader.SupportedFileExtensions() = %v, want %v", got, tt.want) 76 | } 77 | }) 78 | } 79 | } 80 | 81 | var testJsonnetFile = []map[string]interface{}{{ 82 | "name": "testjsonnet", 83 | "variable": false, 84 | }} 85 | -------------------------------------------------------------------------------- /gateapi/docs/DeckPluginsControllerApi.md: -------------------------------------------------------------------------------- 1 | # \DeckPluginsControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetPluginAssetUsingGET**](DeckPluginsControllerApi.md#GetPluginAssetUsingGET) | **Get** /plugins/deck/{pluginId}/{pluginVersion}/{asset} | Retrieve a single plugin asset by version 8 | [**GetPluginManifestUsingGET**](DeckPluginsControllerApi.md#GetPluginManifestUsingGET) | **Get** /plugins/deck/plugin-manifest.json | Retrieve a plugin manifest 9 | 10 | 11 | # **GetPluginAssetUsingGET** 12 | > string GetPluginAssetUsingGET(ctx, asset, pluginId, pluginVersion) 13 | Retrieve a single plugin asset by version 14 | 15 | ### Required Parameters 16 | 17 | Name | Type | Description | Notes 18 | ------------- | ------------- | ------------- | ------------- 19 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 20 | **asset** | **string**| asset | 21 | **pluginId** | **string**| pluginId | 22 | **pluginVersion** | **string**| pluginVersion | 23 | 24 | ### Return type 25 | 26 | **string** 27 | 28 | ### Authorization 29 | 30 | No authorization required 31 | 32 | ### HTTP request headers 33 | 34 | - **Content-Type**: Not defined 35 | - **Accept**: */* 36 | 37 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 38 | 39 | # **GetPluginManifestUsingGET** 40 | > []DeckPluginVersion GetPluginManifestUsingGET(ctx, ) 41 | Retrieve a plugin manifest 42 | 43 | ### Required Parameters 44 | This endpoint does not need any parameter. 45 | 46 | ### Return type 47 | 48 | [**[]DeckPluginVersion**](DeckPluginVersion.md) 49 | 50 | ### Authorization 51 | 52 | No authorization required 53 | 54 | ### HTTP request headers 55 | 56 | - **Content-Type**: Not defined 57 | - **Accept**: */* 58 | 59 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 60 | 61 | -------------------------------------------------------------------------------- /cmd/sync.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | c "github.com/codilime/floodgate/config" 8 | rm "github.com/codilime/floodgate/resourcemanager" 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // syncOptions store synchronize command options 13 | type syncOptions struct { 14 | dryRun bool 15 | } 16 | 17 | // NewSyncCmd create synchronize command 18 | func NewSyncCmd(out io.Writer) *cobra.Command { 19 | options := syncOptions{} 20 | cmd := &cobra.Command{ 21 | Use: "synchronize", 22 | Aliases: []string{"sync"}, 23 | Short: "Synchronize resources to Spinnaker", 24 | Long: "Synchronize resources to Spinnaker", 25 | RunE: func(cmd *cobra.Command, args []string) error { 26 | return runSync(cmd, options) 27 | }, 28 | } 29 | cmd.Flags().BoolVarP(&options.dryRun, "dry-run", "d", false, "process resources and preview the result but don't sync with Spinnaker") 30 | return cmd 31 | } 32 | 33 | func runSync(cmd *cobra.Command, options syncOptions) error { 34 | flags := cmd.InheritedFlags() 35 | configPath, err := flags.GetString("config") 36 | if err != nil { 37 | return err 38 | } 39 | config, err := c.LoadConfig(configPath) 40 | if err != nil { 41 | return err 42 | } 43 | config.Merge(cfg) 44 | resourceManager := &rm.ResourceManager{} 45 | if err := resourceManager.Init(config); err != nil { 46 | return err 47 | } 48 | if options.dryRun { 49 | changes := resourceManager.GetChanges() 50 | printChangedResources(cmd.OutOrStdout(), changes) 51 | } else { 52 | if err := resourceManager.SyncResources(); err != nil { 53 | return err 54 | } 55 | } 56 | return nil 57 | } 58 | 59 | func printChangedResources(out io.Writer, changes []rm.ResourceChange) { 60 | fmt.Fprintln(out, "Following resources are changed:") 61 | for _, change := range changes { 62 | var line string 63 | if change.ID != "" { 64 | line = fmt.Sprintf("Resource: %s (%s)", change.ID, change.Name) 65 | } else { 66 | line = fmt.Sprintf("Resource: %s", change.Name) 67 | } 68 | fmt.Fprintln(out, line) 69 | fmt.Fprintln(out, "Type:", change.Type) 70 | fmt.Fprintln(out, "Changes:") 71 | fmt.Fprintln(out, change.Changes) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /cmd/inspect_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "github.com/codilime/floodgate/test" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "strings" 10 | "testing" 11 | ) 12 | 13 | func TestInspect(t *testing.T) { 14 | mux := http.NewServeMux() 15 | mux.HandleFunc("/auth/loggedOut", test.MockGateServerAuthLoggedOutHandler) 16 | mux.HandleFunc("/applications/jsonapp", func(w http.ResponseWriter, r *http.Request) { 17 | w.Header().Set("Content-Type", "application/json") 18 | w.Write([]byte("{\"name\": \"jsonapp\",\"attributes\": {\"name\": \"jsonapp\"},\"clusters\": {}}")) 19 | }) 20 | mux.HandleFunc("/applications/jsonnetapp/pipelineConfigs/", func(w http.ResponseWriter, r *http.Request) { 21 | w.Header().Set("Content-Type", "application/json") 22 | w.Write([]byte("{\n \"application\": \"jsonnetapp\",\n \"id\": \"jsonnetpipeline\"\n}")) 23 | }) 24 | mux.HandleFunc("/v2/pipelineTemplates/jsonnetpt", func(w http.ResponseWriter, r *http.Request) { 25 | w.Header().Set("Content-Type", "application/json") 26 | w.Write([]byte("{\n \"application\": \"jsonnetpt\",\n \"id\": \"jsonnetpt\"\n}")) 27 | }) 28 | 29 | ts := httptest.NewServer(mux) 30 | 31 | dir, config, err := CreateTempFiles(ts.URL, false) 32 | if err != nil { 33 | t.Errorf("cmd.Inspect() Error while creating temp config %v", err) 34 | } 35 | defer RemoveTempDir(dir) 36 | 37 | b := bytes.NewBufferString("") 38 | cmd := NewRootCmd(b) 39 | cmd.SetOut(b) 40 | 41 | cmd.SetArgs([]string{"--config=" + config, "inspect"}) 42 | 43 | err = cmd.Execute() 44 | if err != nil { 45 | t.Fatalf("cmd.Inspect() Execute err: %v", err) 46 | } 47 | 48 | out, err := ioutil.ReadAll(b) 49 | if err != nil { 50 | t.Fatalf("cmd.Inspect() Read output err: %v", err) 51 | } 52 | 53 | outStr := strings.TrimSpace(string(out)) 54 | if outStr != inspectWant { 55 | t.Errorf("cmd.Inspect() got:\n %s want:\n %s", outStr, inspectWant) 56 | } 57 | } 58 | 59 | var inspectWant = "Current Spinnaker resource status:\n\nApplications:\n{\"name\":\"jsonapp\"}\n\nPipelines:\n{\"application\":\"jsonnetapp\",\"id\":\"jsonnetpipeline\"}\n\nPipeline templates:\n{\"application\":\"jsonnetpt\",\"id\":\"jsonnetpt\"}" 60 | -------------------------------------------------------------------------------- /cmd/apply.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | c "github.com/codilime/floodgate/config" 5 | rm "github.com/codilime/floodgate/resourcemanager" 6 | "github.com/spf13/cobra" 7 | "io" 8 | "io/ioutil" 9 | "log" 10 | ) 11 | 12 | // applyOptions store apply command options 13 | type applyOptions struct { 14 | graph bool 15 | outputPath string 16 | maxConcurrentConnections int 17 | } 18 | 19 | // NewApplyCmd create new apply command 20 | func NewApplyCmd(out io.Writer) *cobra.Command { 21 | options := applyOptions{} 22 | cmd := &cobra.Command{ 23 | Use: "apply", 24 | Short: "Apply resources' by going through dependency graph", 25 | Long: "Apply resources' by going through dependency graph", 26 | RunE: func(cmd *cobra.Command, args []string) error { 27 | return runApply(cmd, options) 28 | }, 29 | } 30 | cmd.Flags().BoolVarP(&options.graph, "dot", "d", false, "export dependency graph to dot format") 31 | cmd.Flags().StringVarP(&options.outputPath, "output-path", "o", "graph.dot", "dot output path") 32 | cmd.Flags().IntVarP(&options.maxConcurrentConnections, "maxConcurrentConnections", "c", 5, "max concurrent connections to spinnaker") 33 | return cmd 34 | } 35 | 36 | func runApply(cmd *cobra.Command, options applyOptions) error { 37 | flags := cmd.InheritedFlags() 38 | configPath, err := flags.GetString("config") 39 | if err != nil { 40 | return err 41 | } 42 | config, err := c.LoadConfig(configPath) 43 | if err != nil { 44 | return err 45 | } 46 | config.Merge(cfg) 47 | 48 | resourceManager := &rm.ResourceManager{} 49 | 50 | if err := resourceManager.Init(config); err != nil { 51 | return err 52 | } 53 | 54 | resources := resourceManager.GetResources() 55 | resourceGraph := &rm.ResourceGraph{Resources: resources} 56 | resourceGraph.Create() 57 | 58 | if options.graph { 59 | dot := resourceGraph.Graph.Dot(nil) 60 | 61 | err = ioutil.WriteFile(options.outputPath, dot, 0644) 62 | if err != nil { 63 | log.Fatal(err) 64 | } 65 | } else { 66 | if err := resourceGraph.Apply(resourceManager.GetClient(), options.maxConcurrentConnections); err != nil { 67 | log.Fatal(err) 68 | } 69 | } 70 | 71 | return nil 72 | } 73 | -------------------------------------------------------------------------------- /cmd/compare_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "github.com/codilime/floodgate/test" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "strings" 10 | "testing" 11 | ) 12 | 13 | func TestCompare(t *testing.T) { 14 | mux := http.NewServeMux() 15 | mux.HandleFunc("/auth/loggedOut", test.MockGateServerAuthLoggedOutHandler) 16 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 17 | w.Write([]byte("{}")) 18 | }) 19 | 20 | ts := httptest.NewServer(mux) 21 | 22 | dir, config, err := CreateTempFiles(ts.URL, false) 23 | if err != nil { 24 | t.Errorf("cmd.Compare() Error while creating temp config %v", err) 25 | } 26 | defer RemoveTempDir(dir) 27 | 28 | b := bytes.NewBufferString("") 29 | cmd := NewRootCmd(b) 30 | cmd.SetOut(b) 31 | 32 | cmd.SetArgs([]string{"--config=" + config, "compare"}) 33 | 34 | err = cmd.Execute() 35 | if err != nil && err.Error() != "end diff" { 36 | t.Fatalf("cmd.Compare() Execute err: %v", err) 37 | } 38 | 39 | out, err := ioutil.ReadAll(b) 40 | if err != nil { 41 | t.Fatalf("cmd.Compare() Read output err: %v", err) 42 | } 43 | 44 | outStr := strings.TrimSpace(string(out)) 45 | if outStr != compareWant { 46 | t.Errorf("cmd.Compare() got: %s want: %s", outStr, compareWant) 47 | } 48 | } 49 | 50 | var compareWant = "jsonapp (application)\n@ []\n- null\n+ {\"cloudProviders\":\"kubernetes\",\"dataSources\":{\"disabled\":[],\"enabled\":[]},\"description\":\"Example application created from JSON file.\",\"email\":\"example@example.com\",\"name\":\"jsonapp\",\"platformHealthOnly\":false,\"platformHealthOnlyShowOverride\":false,\"providerSettings\":{\"aws\":{\"useAmiBlockDeviceMappings\":false},\"gce\":{\"associatePublicIpAddress\":false}},\"trafficGuards\":[],\"user\":\"floodgate@example.com\"}\n\njsonnetpipeline (Example pipeline from Jsonnet) (pipeline)\n@ []\n- null\n+ {\"application\":\"jsonnetapp\",\"id\":\"jsonnetpipeline\",\"keepWaitingPipelines\":false,\"limitConcurrent\":true,\"name\":\"Example pipeline from Jsonnet\",\"notifications\":[],\"stages\":[],\"triggers\":[]}\n\njsonnetpt (Example pipeline template from Jsonnet) (pipelinetemplate)\n@ []\n- null\n+ {\"id\":\"jsonnetpt\",\"metadata\":{\"description\":\"Example pipeline template created from Jsonnet file.\",\"name\":\"Example pipeline template from Jsonnet\",\"owner\":\"floodgate@example.com\",\"scopes\":[\"global\"]},\"protect\":false,\"schema\":\"v2\",\"variables\":[]}" 51 | -------------------------------------------------------------------------------- /gateapi/configuration.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "net/http" 14 | ) 15 | 16 | // contextKeys are used to identify the type of value in the context. 17 | // Since these are string, it is possible to get a short description of the 18 | // context key for logging and debugging using key.String(). 19 | 20 | type contextKey string 21 | 22 | func (c contextKey) String() string { 23 | return "auth " + string(c) 24 | } 25 | 26 | var ( 27 | // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. 28 | ContextOAuth2 = contextKey("token") 29 | 30 | // ContextBasicAuth takes BasicAuth as authentication for the request. 31 | ContextBasicAuth = contextKey("basic") 32 | 33 | // ContextAccessToken takes a string oauth2 access token as authentication for the request. 34 | ContextAccessToken = contextKey("accesstoken") 35 | 36 | // ContextAPIKey takes an APIKey as authentication for the request 37 | ContextAPIKey = contextKey("apikey") 38 | ) 39 | 40 | // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth 41 | type BasicAuth struct { 42 | UserName string `json:"userName,omitempty"` 43 | Password string `json:"password,omitempty"` 44 | } 45 | 46 | // APIKey provides API key based authentication to a request passed via context using ContextAPIKey 47 | type APIKey struct { 48 | Key string 49 | Prefix string 50 | } 51 | 52 | type Configuration struct { 53 | BasePath string `json:"basePath,omitempty"` 54 | Host string `json:"host,omitempty"` 55 | Scheme string `json:"scheme,omitempty"` 56 | DefaultHeader map[string]string `json:"defaultHeader,omitempty"` 57 | UserAgent string `json:"userAgent,omitempty"` 58 | HTTPClient *http.Client 59 | } 60 | 61 | func NewConfiguration() *Configuration { 62 | cfg := &Configuration{ 63 | BasePath: "https://localhost", 64 | DefaultHeader: make(map[string]string), 65 | UserAgent: "Swagger-Codegen/1.0.0/go", 66 | } 67 | return cfg 68 | } 69 | 70 | func (c *Configuration) AddDefaultHeader(key string, value string) { 71 | c.DefaultHeader[key] = value 72 | } 73 | -------------------------------------------------------------------------------- /docs/release-process.md: -------------------------------------------------------------------------------- 1 | # Release process for Floodgate 2 | 3 | ## Preparations before creating first release candidate for new version 4 | * make sure that all required tasks are completed 5 | * make sure that all CI tasks are executed on with success on master branch 6 | * (optional) create branch with proper name: 7 | * prefix should be `release-` phrase 8 | * middle part should be composed from `v` letters and major and minor version number: `v0.1` 9 | * suffix should always be `.x` 10 | * example proper release branch name: `release-v0.1.x` 11 | * make sure that all CI tasks are executed on with success on new branch 12 | 13 | ## Creating new release candidate 14 | * create new release in GitHub 15 | * release name should include full version number and following release candidate number 16 | * we are starting counting releases from `1` 17 | * example of proper release candidate name: `v0.1.0-rc1` 18 | * release should be marked as `pre-release` in GitHub 19 | * compiled binaries should be build using CI system and added after CI system completes all task started after creating new release 20 | 21 | ## Creating proper release 22 | * create new release in GitHub 23 | * release name should start with letter `v` and proper full version number, for example: `v0.1.0` 24 | * binaries should be added after all tasks started in CI system are completed 25 | 26 | ## Master version update 27 | * application version on master should be updated after first stable release for last version 28 | * if we have released version `v0.1.0` then we should update master version to `v0.2.0` 29 | 30 | ## Bug fixing 31 | * if bug exists on master branch and supported released versions: 32 | * first we should fix master branch 33 | * fix from master should be cherry-picked to all supported versions branches 34 | * if there is no release branch, it should be created from version tag we want to fix 35 | * after CI pipelines are successfully finished, new patch version should be released 36 | * if bug exists only in certain version: 37 | * fix should be merge directly to version on which bug exists 38 | * if there is no release branch, it should be created from version tag we want to fix 39 | * if bug exists on more than one released and supported versions 40 | * bug should be fixed on latest supported version and fix should be cherry-picked to rest of supported versions 41 | * after CI pipelines are successfully finished, new patch version should be released 42 | -------------------------------------------------------------------------------- /cmd/sync_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "github.com/codilime/floodgate/test" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "strings" 10 | "testing" 11 | ) 12 | 13 | func TestSyncDryRun(t *testing.T) { 14 | mux := http.NewServeMux() 15 | mux.HandleFunc("/auth/loggedOut", test.MockGateServerAuthLoggedOutHandler) 16 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 17 | w.Write([]byte("{}")) 18 | }) 19 | 20 | ts := httptest.NewServer(mux) 21 | 22 | dir, config, err := CreateTempFiles(ts.URL, false) 23 | if err != nil { 24 | t.Errorf("cmd.SyncDryRun() Error while creating temp config %v", err) 25 | } 26 | defer RemoveTempDir(dir) 27 | 28 | b := bytes.NewBufferString("") 29 | cmd := NewRootCmd(b) 30 | cmd.SetOut(b) 31 | 32 | cmd.SetArgs([]string{"--config=" + config, "sync", "-d"}) 33 | 34 | err = cmd.Execute() 35 | if err != nil { 36 | t.Fatalf("cmd.SyncDryRun() Execute err: %v", err) 37 | } 38 | 39 | out, err := ioutil.ReadAll(b) 40 | if err != nil { 41 | t.Fatalf("cmd.SyncDryRun() Read output err: %v", err) 42 | } 43 | 44 | outStr := strings.TrimSpace(string(out)) 45 | if outStr != syncDryRunWant { 46 | t.Errorf("cmd.SyncDryRun() got:\n %s\n want:\n %s\n", outStr, syncDryRunWant) 47 | } 48 | } 49 | 50 | var syncDryRunWant = "Following resources are changed:\nResource: jsonapp\nType: application\nChanges:\n@ []\n- null\n+ {\"cloudProviders\":\"kubernetes\",\"dataSources\":{\"disabled\":[],\"enabled\":[]},\"description\":\"Example application created from JSON file.\",\"email\":\"example@example.com\",\"name\":\"jsonapp\",\"platformHealthOnly\":false,\"platformHealthOnlyShowOverride\":false,\"providerSettings\":{\"aws\":{\"useAmiBlockDeviceMappings\":false},\"gce\":{\"associatePublicIpAddress\":false}},\"trafficGuards\":[],\"user\":\"floodgate@example.com\"}\n\nResource: jsonnetpipeline (Example pipeline from Jsonnet)\nType: pipeline\nChanges:\n@ []\n- null\n+ {\"application\":\"jsonnetapp\",\"id\":\"jsonnetpipeline\",\"keepWaitingPipelines\":false,\"limitConcurrent\":true,\"name\":\"Example pipeline from Jsonnet\",\"notifications\":[],\"stages\":[],\"triggers\":[]}\n\nResource: jsonnetpt (Example pipeline template from Jsonnet)\nType: pipelinetemplate\nChanges:\n@ []\n- null\n+ {\"id\":\"jsonnetpt\",\"metadata\":{\"description\":\"Example pipeline template created from Jsonnet file.\",\"name\":\"Example pipeline template from Jsonnet\",\"owner\":\"floodgate@example.com\",\"scopes\":[\"global\"]},\"protect\":false,\"schema\":\"v2\",\"variables\":[]}" 51 | -------------------------------------------------------------------------------- /test/gate_mock.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "net/http/httptest" 7 | 8 | gateapi "github.com/codilime/floodgate/gateapi" 9 | "github.com/codilime/floodgate/gateclient" 10 | ) 11 | 12 | // MockGateServerFunction is a handler to a function for Gate server mock 13 | type MockGateServerFunction func(string) *httptest.Server 14 | 15 | // MockGateapiClient creates a basic API client without authentication. 16 | func MockGateapiClient(gateURL string) *gateclient.GateapiClient { 17 | cfg := gateapi.NewConfiguration() 18 | cfg.BasePath = gateURL 19 | client := gateapi.NewAPIClient(cfg) 20 | 21 | return &gateclient.GateapiClient{ 22 | APIClient: client, 23 | Context: context.Background(), 24 | } 25 | } 26 | 27 | // MockGateServerReturn200 creates a HTTP server which returns code 200 and data. 28 | func MockGateServerReturn200(data string) *httptest.Server { 29 | return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 30 | w.Header().Set("Content-Type", "application/json") 31 | w.Write([]byte(data)) 32 | })) 33 | } 34 | 35 | // MockGateServerReturn202 creates a HTTP server which returns code 202. 36 | func MockGateServerReturn202(data string) *httptest.Server { 37 | return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 38 | w.Header().Set("Content-Type", "application/json") 39 | w.WriteHeader(http.StatusAccepted) 40 | })) 41 | } 42 | 43 | // MockGateServerReturn404 creates a HTTP server which returns code 404 and data. 44 | func MockGateServerReturn404(data string) *httptest.Server { 45 | return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 46 | w.Header().Set("Content-Type", "application/json") 47 | w.WriteHeader(http.StatusNotFound) 48 | })) 49 | } 50 | 51 | // MockGateServerReturn500 creates a HTTP server which returns code 500 and data. 52 | func MockGateServerReturn500(data string) *httptest.Server { 53 | return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 54 | w.Header().Set("Content-Type", "application/json") 55 | w.WriteHeader(http.StatusInternalServerError) 56 | })) 57 | } 58 | 59 | // MockGateServerAuthLoggedOutHandler defines handler for spinnaker /auth/loggedOut endpoint 60 | func MockGateServerAuthLoggedOutHandler(w http.ResponseWriter, r *http.Request) { 61 | w.Header().Set("Content-Type", "application/json;charset=UTF-8") 62 | w.Write([]byte("\"Louis, I think this is a start of a beautiful friendship!\"")) 63 | } 64 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "github.com/codilime/floodgate/config" 5 | "io" 6 | 7 | "github.com/codilime/floodgate/version" 8 | "github.com/sirupsen/logrus" 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | // RootOptions store root command options 13 | type RootOptions struct { 14 | configFile string 15 | quiet bool 16 | verbose bool 17 | } 18 | 19 | var cfg config.Config 20 | 21 | // Execute execute command 22 | func Execute(out io.Writer) error { 23 | rootCmd := NewRootCmd(out) 24 | return rootCmd.Execute() 25 | } 26 | 27 | // NewRootCmd create new root command 28 | func NewRootCmd(out io.Writer) *cobra.Command { 29 | options := RootOptions{} 30 | 31 | cmd := &cobra.Command{ 32 | SilenceUsage: true, 33 | SilenceErrors: true, 34 | Version: version.Short(), 35 | } 36 | cmd.PersistentFlags().StringVar(&options.configFile, "config", "", "path to config file (default $HOME/.config/floodgate/config.yaml)") 37 | cmd.PersistentFlags().BoolVarP(&options.quiet, "quiet", "q", false, "hide non-essential output") 38 | cmd.PersistentFlags().BoolVarP(&options.verbose, "verbose", "v", false, "show extended output") 39 | 40 | cmd.PersistentFlags().StringVar(&cfg.Endpoint, "endpoint", "", "URL to spinnaker API") 41 | cmd.PersistentFlags().BoolVar(&cfg.Insecure, "insecure", false, "insecure connection to spinnaker API") 42 | cmd.PersistentFlags().StringSliceVar(&cfg.Libraries, "libraries", []string{}, "path to floodgate libraries") 43 | cmd.PersistentFlags().StringSliceVar(&cfg.Resources, "resources", []string{}, "path to floodgate resources'") 44 | 45 | cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error { 46 | level := "info" 47 | if options.verbose { 48 | level = "trace" 49 | } 50 | if options.quiet { 51 | level = "error" 52 | } 53 | if err := setUpLogs(out, level); err != nil { 54 | return err 55 | } 56 | return nil 57 | } 58 | 59 | cmd.AddCommand(NewSyncCmd(out)) 60 | cmd.AddCommand(NewCompareCmd(out)) 61 | cmd.AddCommand(NewHydrateCmd(out)) 62 | cmd.AddCommand(NewInspectCmd(out)) 63 | cmd.AddCommand(NewRenderCmd(out)) 64 | cmd.AddCommand(NewVersionCmd(out)) 65 | cmd.AddCommand(NewDownloadCmd(out)) 66 | cmd.AddCommand(NewApplyCmd(out)) 67 | cmd.AddCommand(NewExecuteCmd(out)) 68 | 69 | return cmd 70 | } 71 | 72 | // setUpLogs set the log output and the log level 73 | func setUpLogs(out io.Writer, level string) error { 74 | logrus.SetOutput(out) 75 | lvl, err := logrus.ParseLevel(level) 76 | if err != nil { 77 | return err 78 | } 79 | logrus.SetLevel(lvl) 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "github.com/codilime/floodgate/config/auth" 7 | "io/ioutil" 8 | "os" 9 | "os/user" 10 | "path/filepath" 11 | 12 | log "github.com/sirupsen/logrus" 13 | 14 | "github.com/ghodss/yaml" 15 | ) 16 | 17 | var location string 18 | 19 | // Config is the default configuration for the app 20 | type Config struct { 21 | Endpoint string `json:"endpoint"` 22 | Timeout int64 `json:"timeout"` 23 | Insecure bool `json:"insecure"` 24 | Auth auth.Config `json:"auth"` 25 | Libraries []string `json:"libraries"` 26 | Resources []string `json:"resources"` 27 | } 28 | 29 | // LoadConfig function is used to load configuration from file 30 | func LoadConfig(locations ...string) (*Config, error) { 31 | if len(locations) == 0 { 32 | return nil, fmt.Errorf("no config file provided") 33 | } 34 | location = locations[0] 35 | if location == "" { 36 | userHome := "" 37 | usr, err := user.Current() 38 | if err != nil { 39 | // Fallback by trying to read $HOME 40 | userHome = os.Getenv("HOME") 41 | if userHome != "" { 42 | err = nil 43 | } else { 44 | return nil, fmt.Errorf("failed to read current user from environment: %w", err) 45 | } 46 | } else { 47 | userHome = usr.HomeDir 48 | } 49 | location = filepath.Join(userHome, ".config", "floodgate", "config.yaml") 50 | } 51 | 52 | conf := &Config{} 53 | 54 | configFile, err := ioutil.ReadFile(location) 55 | if err != nil { 56 | return nil, err 57 | } 58 | err = yaml.Unmarshal(configFile, &conf) 59 | if err != nil { 60 | return nil, err 61 | } 62 | 63 | if !conf.Auth.IsValid() { 64 | return nil, errors.New("incorrect auth configuration") 65 | } 66 | 67 | return conf, nil 68 | } 69 | 70 | // Merge method is used to override current config with new one 71 | func (c *Config) Merge(cfg Config) { 72 | if cfg.Endpoint != "" { 73 | c.Endpoint = cfg.Endpoint 74 | } 75 | 76 | if cfg.Insecure { 77 | c.Insecure = cfg.Insecure 78 | } 79 | 80 | if len(cfg.Resources) > 0 { 81 | c.Resources = cfg.Resources 82 | } 83 | 84 | if len(cfg.Libraries) > 0 { 85 | c.Libraries = cfg.Libraries 86 | } 87 | } 88 | 89 | // SaveConfig function is used to save configuration file 90 | func SaveConfig(config *Config) error { 91 | configFile, err := yaml.Marshal(&config) 92 | if err != nil { 93 | log.Fatal(err) 94 | return err 95 | } 96 | 97 | err = ioutil.WriteFile(location, configFile, 0644) 98 | if err != nil { 99 | log.Fatal(err) 100 | return err 101 | } 102 | 103 | return nil 104 | } 105 | -------------------------------------------------------------------------------- /gateapi/docs/WebhookControllerApi.md: -------------------------------------------------------------------------------- 1 | # \WebhookControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**PreconfiguredWebhooksUsingGET**](WebhookControllerApi.md#PreconfiguredWebhooksUsingGET) | **Get** /webhooks/preconfigured | Retrieve a list of preconfigured webhooks in Orca 8 | [**WebhooksUsingPOST**](WebhookControllerApi.md#WebhooksUsingPOST) | **Post** /webhooks/{type}/{source} | Endpoint for posting webhooks to Spinnaker's webhook service 9 | 10 | 11 | # **PreconfiguredWebhooksUsingGET** 12 | > []interface{} PreconfiguredWebhooksUsingGET(ctx, ) 13 | Retrieve a list of preconfigured webhooks in Orca 14 | 15 | ### Required Parameters 16 | This endpoint does not need any parameter. 17 | 18 | ### Return type 19 | 20 | [**[]interface{}**](interface{}.md) 21 | 22 | ### Authorization 23 | 24 | No authorization required 25 | 26 | ### HTTP request headers 27 | 28 | - **Content-Type**: Not defined 29 | - **Accept**: */* 30 | 31 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 32 | 33 | # **WebhooksUsingPOST** 34 | > interface{} WebhooksUsingPOST(ctx, source, type_, optional) 35 | Endpoint for posting webhooks to Spinnaker's webhook service 36 | 37 | ### Required Parameters 38 | 39 | Name | Type | Description | Notes 40 | ------------- | ------------- | ------------- | ------------- 41 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 42 | **source** | **string**| source | 43 | **type_** | **string**| type | 44 | **optional** | ***WebhooksUsingPOSTOpts** | optional parameters | nil if no parameters 45 | 46 | ### Optional Parameters 47 | Optional parameters are passed through a pointer to a WebhooksUsingPOSTOpts struct 48 | 49 | Name | Type | Description | Notes 50 | ------------- | ------------- | ------------- | ------------- 51 | 52 | 53 | **xEventKey** | **optional.String**| X-Event-Key | 54 | **xHubSignature** | **optional.String**| X-Hub-Signature | 55 | **event** | [**optional.Interface of interface{}**](interface{}.md)| event | 56 | 57 | ### Return type 58 | 59 | [**interface{}**](interface{}.md) 60 | 61 | ### Authorization 62 | 63 | No authorization required 64 | 65 | ### HTTP request headers 66 | 67 | - **Content-Type**: application/json 68 | - **Accept**: */* 69 | 70 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 71 | 72 | -------------------------------------------------------------------------------- /config/auth/auth_test.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import "testing" 4 | 5 | func TestConfig_IsValid(t *testing.T) { 6 | type args struct { 7 | config Config 8 | } 9 | 10 | tests := []struct { 11 | name string 12 | args args 13 | wantBool bool 14 | }{ 15 | { 16 | name: "basic is enabled", 17 | args: args{ 18 | config: Config{ 19 | Basic: Basic{ 20 | Enabled: true, 21 | }, 22 | OAuth2: OAuth2{ 23 | Enabled: false, 24 | }, 25 | X509: X509{ 26 | Enabled: false, 27 | }, 28 | }, 29 | }, 30 | wantBool: true, 31 | }, 32 | { 33 | name: "oauth2 is enabled", 34 | args: args{ 35 | config: Config{ 36 | Basic: Basic{ 37 | Enabled: false, 38 | }, 39 | OAuth2: OAuth2{ 40 | Enabled: true, 41 | }, 42 | X509: X509{ 43 | Enabled: false, 44 | }, 45 | }, 46 | }, 47 | wantBool: true, 48 | }, 49 | { 50 | name: "x509 auth is enabled", 51 | args: args{ 52 | config: Config{ 53 | Basic: Basic{ 54 | Enabled: false, 55 | }, 56 | OAuth2: OAuth2{ 57 | Enabled: false, 58 | }, 59 | X509: X509{ 60 | Enabled: true, 61 | }, 62 | }, 63 | }, 64 | wantBool: true, 65 | }, 66 | { 67 | name: "basic and oauth2 is enabled", 68 | args: args{ 69 | config: Config{ 70 | Basic: Basic{ 71 | Enabled: true, 72 | }, 73 | OAuth2: OAuth2{ 74 | Enabled: true, 75 | }, 76 | X509: X509{ 77 | Enabled: false, 78 | }, 79 | }, 80 | }, 81 | wantBool: false, 82 | }, 83 | { 84 | name: "oauth2 and x509 is enabled", 85 | args: args{ 86 | config: Config{ 87 | Basic: Basic{ 88 | Enabled: false, 89 | }, 90 | OAuth2: OAuth2{ 91 | Enabled: true, 92 | }, 93 | X509: X509{ 94 | Enabled: true, 95 | }, 96 | }, 97 | }, 98 | wantBool: false, 99 | }, 100 | { 101 | name: "basic and x509 is enabled", 102 | args: args{ 103 | config: Config{ 104 | Basic: Basic{ 105 | Enabled: true, 106 | }, 107 | OAuth2: OAuth2{ 108 | Enabled: false, 109 | }, 110 | X509: X509{ 111 | Enabled: true, 112 | }, 113 | }, 114 | }, 115 | wantBool: false, 116 | }, 117 | { 118 | name: "auth is not configured", 119 | args: args{ 120 | config: Config{}, 121 | }, 122 | wantBool: false, 123 | }, 124 | } 125 | 126 | for _, tt := range tests { 127 | t.Run(tt.name, func(t *testing.T) { 128 | valid := tt.args.config.IsValid() 129 | if valid != tt.wantBool { 130 | t.Errorf("Config.IsValid() want = %v, got %v", tt.wantBool, valid) 131 | } 132 | }) 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /gateapi/docs/SnapshotControllerApi.md: -------------------------------------------------------------------------------- 1 | # \SnapshotControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetCurrentSnapshotUsingGET**](SnapshotControllerApi.md#GetCurrentSnapshotUsingGET) | **Get** /applications/{application}/snapshots/{account} | Get current snapshot 8 | [**GetSnapshotHistoryUsingGET**](SnapshotControllerApi.md#GetSnapshotHistoryUsingGET) | **Get** /applications/{application}/snapshots/{account}/history | Get snapshot history 9 | 10 | 11 | # **GetCurrentSnapshotUsingGET** 12 | > map[string]interface{} GetCurrentSnapshotUsingGET(ctx, account, application) 13 | Get current snapshot 14 | 15 | ### Required Parameters 16 | 17 | Name | Type | Description | Notes 18 | ------------- | ------------- | ------------- | ------------- 19 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 20 | **account** | **string**| account | 21 | **application** | **string**| application | 22 | 23 | ### Return type 24 | 25 | [**map[string]interface{}**](interface{}.md) 26 | 27 | ### Authorization 28 | 29 | No authorization required 30 | 31 | ### HTTP request headers 32 | 33 | - **Content-Type**: Not defined 34 | - **Accept**: */* 35 | 36 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 37 | 38 | # **GetSnapshotHistoryUsingGET** 39 | > []interface{} GetSnapshotHistoryUsingGET(ctx, account, application, optional) 40 | Get snapshot history 41 | 42 | ### Required Parameters 43 | 44 | Name | Type | Description | Notes 45 | ------------- | ------------- | ------------- | ------------- 46 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 47 | **account** | **string**| account | 48 | **application** | **string**| application | 49 | **optional** | ***GetSnapshotHistoryUsingGETOpts** | optional parameters | nil if no parameters 50 | 51 | ### Optional Parameters 52 | Optional parameters are passed through a pointer to a GetSnapshotHistoryUsingGETOpts struct 53 | 54 | Name | Type | Description | Notes 55 | ------------- | ------------- | ------------- | ------------- 56 | 57 | 58 | **limit** | **optional.Int32**| limit | [default to 20] 59 | 60 | ### Return type 61 | 62 | [**[]interface{}**](interface{}.md) 63 | 64 | ### Authorization 65 | 66 | No authorization required 67 | 68 | ### HTTP request headers 69 | 70 | - **Content-Type**: Not defined 71 | - **Accept**: */* 72 | 73 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 74 | 75 | -------------------------------------------------------------------------------- /resourcemanager/graph.go: -------------------------------------------------------------------------------- 1 | package resourcemanager 2 | 3 | import ( 4 | gc "github.com/codilime/floodgate/gateclient" 5 | spr "github.com/codilime/floodgate/spinnakerresource" 6 | "github.com/hashicorp/terraform/dag" 7 | "github.com/hashicorp/terraform/tfdiags" 8 | log "github.com/sirupsen/logrus" 9 | "net/url" 10 | ) 11 | 12 | // ResourceGraph stores resources and graph to be able to save it in spinnaker 13 | type ResourceGraph struct { 14 | Resources spr.SpinnakerResources 15 | 16 | Graph dag.AcyclicGraph 17 | } 18 | 19 | // Create creates graph from resources 20 | func (rg *ResourceGraph) Create() { 21 | start := rg.Graph.Add("Start") 22 | 23 | for _, application := range rg.Resources.Applications { 24 | appVert := rg.Graph.Add(application) 25 | rg.Graph.Connect(dag.BasicEdge(appVert, start)) 26 | 27 | for _, pipeline := range rg.Resources.Pipelines { 28 | pipelineVert := rg.Graph.Add(pipeline) 29 | 30 | if pipeline.Application() == application.Name() { 31 | rg.Graph.Connect(dag.BasicEdge(pipelineVert, appVert)) 32 | 33 | templateRef, _ := url.Parse(pipeline.TemplateReference()) 34 | for _, pipelineTemplate := range rg.Resources.PipelineTemplates { 35 | if templateRef.Host == pipelineTemplate.ID() { 36 | ptVert := rg.Graph.Add(pipelineTemplate) 37 | rg.Graph.Connect(dag.BasicEdge(ptVert, start)) 38 | rg.Graph.Connect(dag.BasicEdge(pipelineVert, ptVert)) 39 | } 40 | } 41 | } 42 | } 43 | } 44 | } 45 | 46 | // Apply walks through graph and saves local state in spinnaker 47 | func (rg *ResourceGraph) Apply(spinnakerAPI *gc.GateapiClient, maxConcurrentConn int) error { 48 | var sem = make(chan int, maxConcurrentConn) 49 | 50 | w := &dag.Walker{ 51 | Callback: func(v dag.Vertex) tfdiags.Diagnostics { 52 | sem <- 1 53 | 54 | switch vertex := v.(type) { 55 | case *spr.Application: 56 | log.Infof("Saving Application: %s", vertex.Name()) 57 | err := vertex.SaveLocalState(spinnakerAPI) 58 | if err != nil { 59 | log.Errorf("Error while saving application: %s\n%v", vertex.Name(), err) 60 | } 61 | 62 | case *spr.Pipeline: 63 | log.Infof("Saving Pipeline: %s", vertex.Name()) 64 | err := vertex.SaveLocalState(spinnakerAPI) 65 | if err != nil { 66 | log.Errorf("Error while saving pipeline: %s\n%v", vertex.Name(), err) 67 | } 68 | case *spr.PipelineTemplate: 69 | log.Infof("Saving PipelineTemplate: %s", vertex.Name()) 70 | err := vertex.SaveLocalState(spinnakerAPI) 71 | if err != nil { 72 | log.Errorf("Error while saving pipeline template: %s\n%v", vertex.Name(), err) 73 | } 74 | case string: 75 | break 76 | default: 77 | log.Infof("Unsupported type %T!\n", v) 78 | } 79 | 80 | <-sem 81 | return nil 82 | }, 83 | Reverse: true, 84 | } 85 | w.Update(&rg.Graph) 86 | 87 | return w.Wait().Err() 88 | } 89 | -------------------------------------------------------------------------------- /gateapi/docs/NetworkControllerApi.md: -------------------------------------------------------------------------------- 1 | # \NetworkControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**AllByCloudProviderUsingGET**](NetworkControllerApi.md#AllByCloudProviderUsingGET) | **Get** /networks/{cloudProvider} | Retrieve a list of networks for a given cloud provider 8 | [**AllUsingGET2**](NetworkControllerApi.md#AllUsingGET2) | **Get** /networks | Retrieve a list of networks, grouped by cloud provider 9 | 10 | 11 | # **AllByCloudProviderUsingGET** 12 | > []interface{} AllByCloudProviderUsingGET(ctx, cloudProvider, optional) 13 | Retrieve a list of networks for a given cloud provider 14 | 15 | ### Required Parameters 16 | 17 | Name | Type | Description | Notes 18 | ------------- | ------------- | ------------- | ------------- 19 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 20 | **cloudProvider** | **string**| cloudProvider | 21 | **optional** | ***AllByCloudProviderUsingGETOpts** | optional parameters | nil if no parameters 22 | 23 | ### Optional Parameters 24 | Optional parameters are passed through a pointer to a AllByCloudProviderUsingGETOpts struct 25 | 26 | Name | Type | Description | Notes 27 | ------------- | ------------- | ------------- | ------------- 28 | 29 | **xRateLimitApp** | **optional.String**| X-RateLimit-App | 30 | 31 | ### Return type 32 | 33 | [**[]interface{}**](interface{}.md) 34 | 35 | ### Authorization 36 | 37 | No authorization required 38 | 39 | ### HTTP request headers 40 | 41 | - **Content-Type**: Not defined 42 | - **Accept**: */* 43 | 44 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 45 | 46 | # **AllUsingGET2** 47 | > map[string]interface{} AllUsingGET2(ctx, optional) 48 | Retrieve a list of networks, grouped by cloud provider 49 | 50 | ### Required Parameters 51 | 52 | Name | Type | Description | Notes 53 | ------------- | ------------- | ------------- | ------------- 54 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 55 | **optional** | ***AllUsingGET2Opts** | optional parameters | nil if no parameters 56 | 57 | ### Optional Parameters 58 | Optional parameters are passed through a pointer to a AllUsingGET2Opts struct 59 | 60 | Name | Type | Description | Notes 61 | ------------- | ------------- | ------------- | ------------- 62 | **xRateLimitApp** | **optional.String**| X-RateLimit-App | 63 | 64 | ### Return type 65 | 66 | [**map[string]interface{}**](interface{}.md) 67 | 68 | ### Authorization 69 | 70 | No authorization required 71 | 72 | ### HTTP request headers 73 | 74 | - **Content-Type**: Not defined 75 | - **Accept**: */* 76 | 77 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 78 | 79 | -------------------------------------------------------------------------------- /resourcemanager/graph_test.go: -------------------------------------------------------------------------------- 1 | package resourcemanager 2 | 3 | import ( 4 | "github.com/codilime/floodgate/gateclient" 5 | spr "github.com/codilime/floodgate/spinnakerresource" 6 | "github.com/codilime/floodgate/test" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | func initResourceGraph(api *gateclient.GateapiClient) (*ResourceGraph, error) { 12 | a := &spr.Application{} 13 | err := a.Init(api, testApplication) 14 | if err != nil { 15 | return nil, err 16 | } 17 | 18 | p := &spr.Pipeline{} 19 | err = p.Init(api, testPipeline) 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | pt := &spr.PipelineTemplate{} 25 | err = pt.Init(api, testPipelineTemplate) 26 | if err != nil { 27 | return nil, err 28 | } 29 | 30 | resourceGraph := ResourceGraph{ 31 | Resources: spr.SpinnakerResources{ 32 | Applications: []*spr.Application{ 33 | a, 34 | }, 35 | Pipelines: []*spr.Pipeline{ 36 | p, 37 | }, 38 | PipelineTemplates: []*spr.PipelineTemplate{ 39 | pt, 40 | }, 41 | }, 42 | } 43 | 44 | return &resourceGraph, nil 45 | } 46 | 47 | func TestResourceGraph_Create(t *testing.T) { 48 | ts := test.MockGateServerReturn200("") 49 | api := test.MockGateapiClient(ts.URL) 50 | 51 | resourceGraph, err := initResourceGraph(api) 52 | if err != nil { 53 | t.Errorf("ResourceGraph.Create() got error %v", err) 54 | } 55 | resourceGraph.Create() 56 | 57 | graphStr := strings.TrimSpace(resourceGraph.Graph.String()) 58 | if graphStr != createWant { 59 | t.Errorf("ResourceGraph.Create() got %s, want %s", graphStr, createWant) 60 | } 61 | } 62 | 63 | func TestResourceGraph_Apply(t *testing.T) { 64 | ts := test.MockGateServerReturn200("") 65 | api := test.MockGateapiClient(ts.URL) 66 | 67 | resourceGraph, err := initResourceGraph(api) 68 | if err != nil { 69 | t.Errorf("ResourceGraph.Apply() got error %v", err) 70 | } 71 | resourceGraph.Create() 72 | 73 | err = resourceGraph.Apply(api, 5) 74 | if err != nil { 75 | t.Errorf("ResourceGraph.Apply() got error %v", err) 76 | } 77 | } 78 | 79 | var testApplication = map[string]interface{}{ 80 | "name": "testapplication", 81 | "email": "test@floodgate.com", 82 | } 83 | 84 | var testPipeline = map[string]interface{}{ 85 | "name": "Test pipeline.", 86 | "application": "testapplication", 87 | "id": "testpipeline", 88 | "schema": "v2", 89 | "template": map[string]interface{}{ 90 | "reference": "spinnaker://test-pipeline-template", 91 | }, 92 | } 93 | 94 | var testPipelineTemplate = map[string]interface{}{ 95 | "id": "test-pipeline-template", 96 | "metadata": map[string]interface{}{ 97 | "name": "Test pipeline template", 98 | "description": "Test pipeline template.", 99 | "owner": "example@example.com", 100 | "scopes": []interface{}{ 101 | "", 102 | }, 103 | }, 104 | "schema": "v2", 105 | } 106 | 107 | var createWant = "Start\nTest pipeline template\n Start\nTest pipeline.\n Test pipeline template\n testapplication\ntestapplication\n Start" 108 | -------------------------------------------------------------------------------- /gateapi/docs/BakeControllerApi.md: -------------------------------------------------------------------------------- 1 | # \BakeControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**BakeOptionsUsingGET**](BakeControllerApi.md#BakeOptionsUsingGET) | **Get** /bakery/options/{cloudProvider} | Retrieve a list of available bakery base images for a given cloud provider 8 | [**BakeOptionsUsingGET1**](BakeControllerApi.md#BakeOptionsUsingGET1) | **Get** /bakery/options | Retrieve a list of available bakery base images, grouped by cloud provider 9 | [**LookupLogsUsingGET**](BakeControllerApi.md#LookupLogsUsingGET) | **Get** /bakery/logs/{region}/{statusId} | Retrieve the logs for a given bake 10 | 11 | 12 | # **BakeOptionsUsingGET** 13 | > interface{} BakeOptionsUsingGET(ctx, cloudProvider) 14 | Retrieve a list of available bakery base images for a given cloud provider 15 | 16 | ### Required Parameters 17 | 18 | Name | Type | Description | Notes 19 | ------------- | ------------- | ------------- | ------------- 20 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 21 | **cloudProvider** | **string**| cloudProvider | 22 | 23 | ### Return type 24 | 25 | [**interface{}**](interface{}.md) 26 | 27 | ### Authorization 28 | 29 | No authorization required 30 | 31 | ### HTTP request headers 32 | 33 | - **Content-Type**: Not defined 34 | - **Accept**: */* 35 | 36 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 37 | 38 | # **BakeOptionsUsingGET1** 39 | > interface{} BakeOptionsUsingGET1(ctx, ) 40 | Retrieve a list of available bakery base images, grouped by cloud provider 41 | 42 | ### Required Parameters 43 | This endpoint does not need any parameter. 44 | 45 | ### Return type 46 | 47 | [**interface{}**](interface{}.md) 48 | 49 | ### Authorization 50 | 51 | No authorization required 52 | 53 | ### HTTP request headers 54 | 55 | - **Content-Type**: Not defined 56 | - **Accept**: */* 57 | 58 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 59 | 60 | # **LookupLogsUsingGET** 61 | > interface{} LookupLogsUsingGET(ctx, region, statusId) 62 | Retrieve the logs for a given bake 63 | 64 | ### Required Parameters 65 | 66 | Name | Type | Description | Notes 67 | ------------- | ------------- | ------------- | ------------- 68 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 69 | **region** | **string**| region | 70 | **statusId** | **string**| statusId | 71 | 72 | ### Return type 73 | 74 | [**interface{}**](interface{}.md) 75 | 76 | ### Authorization 77 | 78 | No authorization required 79 | 80 | ### HTTP request headers 81 | 82 | - **Content-Type**: Not defined 83 | - **Accept**: */* 84 | 85 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 86 | 87 | -------------------------------------------------------------------------------- /cmd/execute_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "github.com/codilime/floodgate/test" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "strings" 10 | "testing" 11 | ) 12 | 13 | func TestExecute(t *testing.T) { 14 | mux := http.NewServeMux() 15 | mux.HandleFunc("/auth/loggedOut", test.MockGateServerAuthLoggedOutHandler) 16 | mux.HandleFunc("/webhooks/webhook/test", func(w http.ResponseWriter, r *http.Request) { 17 | w.Header().Set("Content-Type", "application/json") 18 | w.Write([]byte("{\"eventId\": \"123\",\"eventProcessed\": true}")) 19 | }) 20 | mux.HandleFunc("/applications/jsonnetapp/pipelineConfigs/", func(w http.ResponseWriter, r *http.Request) { 21 | w.Header().Set("Content-Type", "application/json") 22 | w.Write([]byte("{\n \"application\": \"jsonnetapp\",\n \"id\": \"jsonnetpipeline\"\n}")) 23 | }) 24 | ts := httptest.NewServer(mux) 25 | 26 | dir, config, err := CreateTempFiles(ts.URL, false) 27 | if err != nil { 28 | t.Errorf("cmd.Execute() Error while creating temp config %v", err) 29 | } 30 | defer RemoveTempDir(dir) 31 | 32 | b := bytes.NewBufferString("") 33 | cmd := NewRootCmd(b) 34 | cmd.SetOut(b) 35 | 36 | cmd.SetArgs([]string{"--config=" + config, "execute", "test"}) 37 | 38 | err = cmd.Execute() 39 | if err != nil { 40 | t.Fatalf("cmd.Execute() Execute err: %v", err) 41 | } 42 | 43 | out, err := ioutil.ReadAll(b) 44 | if err != nil { 45 | t.Fatalf("cmd.Execute() Read output err: %v", err) 46 | } 47 | 48 | outStr := strings.TrimSpace(string(out)) 49 | if outStr != executeWant { 50 | t.Errorf("cmd.Execute() got:\n %s want:\n %s", outStr, executeWant) 51 | } 52 | } 53 | 54 | func TestExecuteWait(t *testing.T) { 55 | mux := http.NewServeMux() 56 | mux.HandleFunc("/auth/loggedOut", test.MockGateServerAuthLoggedOutHandler) 57 | mux.HandleFunc("/webhooks/webhook/test", func(w http.ResponseWriter, r *http.Request) { 58 | w.Header().Set("Content-Type", "application/json") 59 | w.Write([]byte("{\"eventId\": \"123\",\"eventProcessed\": true}")) 60 | }) 61 | mux.HandleFunc("/applications/*/executions/search", func(w http.ResponseWriter, r *http.Request) { 62 | w.Header().Set("Content-Type", "application/json") 63 | w.Write([]byte("[{\n \"status\": \"SUCCEEDED\"}]")) 64 | }) 65 | ts := httptest.NewServer(mux) 66 | 67 | dir, config, err := CreateTempFiles(ts.URL, false) 68 | if err != nil { 69 | t.Errorf("cmd.Execute() Error while creating temp config %v", err) 70 | } 71 | defer RemoveTempDir(dir) 72 | 73 | b := bytes.NewBufferString("") 74 | cmd := NewRootCmd(b) 75 | cmd.SetOut(b) 76 | 77 | cmd.SetArgs([]string{"--config=" + config, "execute", "test", "-w", "--wait-time=1"}) 78 | 79 | err = cmd.Execute() 80 | if err != nil { 81 | t.Fatalf("cmd.Execute() Execute err: %v", err) 82 | } 83 | 84 | out, err := ioutil.ReadAll(b) 85 | if err != nil { 86 | t.Fatalf("cmd.Execute() Read output err: %v", err) 87 | } 88 | 89 | outStr := strings.TrimSpace(string(out)) 90 | if outStr != executeWaitWant { 91 | t.Errorf("cmd.Execute() got:\n %s want:\n %s", outStr, executeWant) 92 | } 93 | } 94 | 95 | var executeWant = "triggering 'test'\nevent processed successfully\nexecution id is 123" 96 | var executeWaitWant = "triggering 'test'\nevent processed successfully\nexecution id is 123\npipeline succeeded" 97 | -------------------------------------------------------------------------------- /gateapi/docs/InstanceControllerApi.md: -------------------------------------------------------------------------------- 1 | # \InstanceControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetConsoleOutputUsingGET**](InstanceControllerApi.md#GetConsoleOutputUsingGET) | **Get** /instances/{account}/{region}/{instanceId}/console | Retrieve an instance's console output 8 | [**GetInstanceDetailsUsingGET**](InstanceControllerApi.md#GetInstanceDetailsUsingGET) | **Get** /instances/{account}/{region}/{instanceId} | Retrieve an instance's details 9 | 10 | 11 | # **GetConsoleOutputUsingGET** 12 | > interface{} GetConsoleOutputUsingGET(ctx, account, instanceId, region, optional) 13 | Retrieve an instance's console output 14 | 15 | ### Required Parameters 16 | 17 | Name | Type | Description | Notes 18 | ------------- | ------------- | ------------- | ------------- 19 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 20 | **account** | **string**| account | 21 | **instanceId** | **string**| instanceId | 22 | **region** | **string**| region | 23 | **optional** | ***GetConsoleOutputUsingGETOpts** | optional parameters | nil if no parameters 24 | 25 | ### Optional Parameters 26 | Optional parameters are passed through a pointer to a GetConsoleOutputUsingGETOpts struct 27 | 28 | Name | Type | Description | Notes 29 | ------------- | ------------- | ------------- | ------------- 30 | 31 | 32 | 33 | **xRateLimitApp** | **optional.String**| X-RateLimit-App | 34 | **provider** | **optional.String**| provider | [default to aws] 35 | 36 | ### Return type 37 | 38 | [**interface{}**](interface{}.md) 39 | 40 | ### Authorization 41 | 42 | No authorization required 43 | 44 | ### HTTP request headers 45 | 46 | - **Content-Type**: Not defined 47 | - **Accept**: */* 48 | 49 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 50 | 51 | # **GetInstanceDetailsUsingGET** 52 | > interface{} GetInstanceDetailsUsingGET(ctx, account, instanceId, region, optional) 53 | Retrieve an instance's details 54 | 55 | ### Required Parameters 56 | 57 | Name | Type | Description | Notes 58 | ------------- | ------------- | ------------- | ------------- 59 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 60 | **account** | **string**| account | 61 | **instanceId** | **string**| instanceId | 62 | **region** | **string**| region | 63 | **optional** | ***GetInstanceDetailsUsingGETOpts** | optional parameters | nil if no parameters 64 | 65 | ### Optional Parameters 66 | Optional parameters are passed through a pointer to a GetInstanceDetailsUsingGETOpts struct 67 | 68 | Name | Type | Description | Notes 69 | ------------- | ------------- | ------------- | ------------- 70 | 71 | 72 | 73 | **xRateLimitApp** | **optional.String**| X-RateLimit-App | 74 | 75 | ### Return type 76 | 77 | [**interface{}**](interface{}.md) 78 | 79 | ### Authorization 80 | 81 | No authorization required 82 | 83 | ### HTTP request headers 84 | 85 | - **Content-Type**: Not defined 86 | - **Accept**: */* 87 | 88 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 89 | 90 | -------------------------------------------------------------------------------- /.circleci/libs/install-and-run-spinnaker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -xe 2 | 3 | EXEC_DIR=$(dirname "$0") 4 | HAL_VERSION=${HAL_VERSION:-1.35.0} 5 | 6 | # Install Halyard 7 | curl -O https://raw.githubusercontent.com/spinnaker/halyard/master/install/debian/InstallHalyard.sh 8 | USERNAME=`whoami` 9 | sudo bash InstallHalyard.sh --version ${HAL_VERSION} --user $USERNAME -y 10 | hal -v 11 | 12 | # Create Kind cluster 13 | kind create cluster --config="${EXEC_DIR}/kind-cluster-config.yaml" 14 | kubectl config use-context kind-kind 15 | kubectl cluster-info 16 | 17 | # Configure Spinnaker installation 18 | ## Generate random password 19 | GATE_PASS=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '') 20 | 21 | ## Configure default provider 22 | hal -q config provider kubernetes enable 23 | CONTEXT=$(kubectl config current-context) 24 | hal -q config provider kubernetes account add my-k8s-v2-account --provider-version v2 --context $CONTEXT 25 | hal -q config deploy edit --type distributed --account-name my-k8s-v2-account 26 | 27 | ## Install minio 28 | kubectl create namespace spinnaker 29 | sed -i 's/LoadBalancer/ClusterIP/g' "${EXEC_DIR}/minio-standalone.yaml" 30 | kubectl -n spinnaker create -f "${EXEC_DIR}/minio-standalone.yaml" 31 | mkdir -p ~/.hal/default/profiles 32 | echo "spinnaker.s3.versioning: false" >> ~/.hal/default/profiles/front50-local.yml 33 | 34 | ## Configure Spinnaker 35 | export MINIO_ACCESS_KEY=minio 36 | export MINIO_SECRET_KEY=minio123 37 | echo $MINIO_SECRET_KEY | hal -q config storage s3 edit --path-style-access=true --endpoint "http://minio-service:9000" --access-key-id $MINIO_ACCESS_KEY --secret-access-key 38 | hal -q config storage edit --type s3 39 | hal -q config features edit --pipeline-templates true 40 | export NEED_SPINNAKER_VERSION=${NEED_SPINNAKER_VERSION:-1.19} 41 | hal -q version list 42 | hal -q config version edit --version $(hal -q version list | grep "^ -" | awk '{ print $2 }' | grep ${NEED_SPINNAKER_VERSION}) 43 | hal config security ui edit --override-base-url='http://spinnaker' 44 | hal config security api edit --override-base-url='http://spinnaker/api/v1' 45 | 46 | ### Extra parameters for Gate and Deck 47 | echo 'window.spinnakerSettings.authEnabled = true;' > ~/.hal/default/profiles/settings-local.js 48 | mkdir -p ~/.hal/default/service-settings 49 | echo 'healthEndpoint: /api/v1/health' > ~/.hal/default/service-settings/gate.yml 50 | sed -i "s/GATE_PASS/${GATE_PASS}/g" "${EXEC_DIR}/gate-local.yml" 51 | cp "${EXEC_DIR}/gate-local.yml" ~/.hal/default/profiles/gate-local.yml 52 | 53 | # Install Spinnaker 54 | hal -q deploy apply 55 | until kubectl -n spinnaker wait --for=condition=Ready pod --all > /dev/null 56 | do 57 | kubectl -n spinnaker get pods 58 | done 59 | 60 | # Install Ingress controller 61 | kubectl apply -f "${EXEC_DIR}/ingress-mandatory.yaml" 62 | kubectl apply -f "${EXEC_DIR}/ingress-service-nodeport.yaml" 63 | kubectl patch deployments -n ingress-nginx nginx-ingress-controller -p '{"spec":{"template":{"spec":{"containers":[{"name":"nginx-ingress-controller","ports":[{"containerPort":80,"hostPort":80},{"containerPort":443,"hostPort":443}]}],"nodeSelector":{"ingress-ready":"true"},"tolerations":[{"key":"node-role.kubernetes.io/master","operator":"Equal","effect":"NoSchedule"}]}}}}' 64 | kubectl -n spinnaker apply -f "${EXEC_DIR}/spinnaker-ingress.yaml" 65 | 66 | # Generate Floodgate config file 67 | sed -i "s/GATE_PASS/${GATE_PASS}/g" "${EXEC_DIR}/floodgate-config.yaml" 68 | cp "${EXEC_DIR}/floodgate-config.yaml" ~/floodgate.yaml 69 | -------------------------------------------------------------------------------- /cmd/apply_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "bytes" 5 | "github.com/codilime/floodgate/test" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "path" 10 | "testing" 11 | ) 12 | 13 | func TestApply(t *testing.T) { 14 | mux := http.NewServeMux() 15 | mux.HandleFunc("/auth/loggedOut", test.MockGateServerAuthLoggedOutHandler) 16 | mux.HandleFunc("/tasks/test", func(w http.ResponseWriter, r *http.Request) { 17 | w.Header().Set("Content-Type", "application/json") 18 | w.Write([]byte("{\"status\": \"SUCCEEDED\"}")) 19 | }) 20 | mux.HandleFunc("/tasks", func(w http.ResponseWriter, r *http.Request) { 21 | w.Header().Set("Content-Type", "application/json") 22 | w.Write([]byte("{\"ref\": \"test/test/test\"}")) 23 | }) 24 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 25 | w.Write([]byte("{}")) 26 | }) 27 | 28 | ts := httptest.NewServer(mux) 29 | 30 | dir, config, err := CreateTempFiles(ts.URL, false) 31 | if err != nil { 32 | t.Errorf("cmd.Apply() Error while creating temp config %v", err) 33 | } 34 | defer RemoveTempDir(dir) 35 | 36 | b := bytes.NewBufferString("") 37 | cmd := NewRootCmd(b) 38 | cmd.SetOut(b) 39 | 40 | cmd.SetArgs([]string{"--config=" + config, "apply"}) 41 | 42 | err = cmd.Execute() 43 | if err != nil { 44 | t.Fatalf("cmd.Apply() Execute err: %v", err) 45 | } 46 | 47 | _, err = ioutil.ReadAll(b) 48 | if err != nil { 49 | t.Fatalf("cmd.Apply() Read output err: %v", err) 50 | } 51 | } 52 | 53 | func TestApplyGraph(t *testing.T) { 54 | mux := http.NewServeMux() 55 | mux.HandleFunc("/auth/loggedOut", test.MockGateServerAuthLoggedOutHandler) 56 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 57 | w.Write([]byte("{}")) 58 | }) 59 | 60 | ts := httptest.NewServer(mux) 61 | 62 | dir, config, err := CreateTempFiles(ts.URL, false) 63 | if err != nil { 64 | t.Errorf("cmd.ApplyGraph() Error while creating temp config %v", err) 65 | } 66 | defer RemoveTempDir(dir) 67 | 68 | graphFileName := "graph.dot" 69 | 70 | b := bytes.NewBufferString("") 71 | cmd := NewRootCmd(b) 72 | cmd.SetOut(b) 73 | 74 | cmd.SetArgs([]string{"--config=" + config, "apply", "-dot", "-o", path.Join(dir, graphFileName)}) 75 | 76 | err = cmd.Execute() 77 | if err != nil { 78 | t.Fatalf("cmd.ApplyGraph() Execute err: %v", err) 79 | } 80 | 81 | _, err = ioutil.ReadAll(b) 82 | if err != nil { 83 | t.Fatalf("cmd.ApplyGraph() Read output err: %v", err) 84 | } 85 | 86 | files, err := ioutil.ReadDir(dir) 87 | if err != nil { 88 | t.Fatalf("cmd.ApplyGraph() Read dir err: %v", err) 89 | } 90 | 91 | for _, file := range files { 92 | if file.Name() == graphFileName { 93 | content, err := ioutil.ReadFile(path.Join(dir, graphFileName)) 94 | if err != nil { 95 | t.Fatalf("cmd.ApplyGraph() Cannot read file %s err: %v", graphFileName, err) 96 | } 97 | 98 | if !bytes.Equal(content, graphFileWant) { 99 | t.Errorf("cmd.ApplyGraph() dot file content is incorrect") 100 | } 101 | } 102 | } 103 | } 104 | 105 | var graphFileWant = []byte{100, 105, 103, 114, 97, 112, 104, 32, 123, 10, 9, 99, 111, 109, 112, 111, 117, 110, 100, 32, 61, 32, 34, 116, 114, 117, 101, 34, 10, 9, 110, 101, 119, 114, 97, 110, 107, 32, 61, 32, 34, 116, 114, 117, 101, 34, 10, 9, 115, 117, 98, 103, 114, 97, 112, 104, 32, 34, 114, 111, 111, 116, 34, 32, 123, 10, 9, 9, 34, 91, 114, 111, 111, 116, 93, 32, 106, 115, 111, 110, 97, 112, 112, 34, 32, 45, 62, 32, 34, 91, 114, 111, 111, 116, 93, 32, 83, 116, 97, 114, 116, 34, 10, 9, 125, 10, 125, 10} 106 | -------------------------------------------------------------------------------- /.circleci/libs/minio-standalone.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-pvc.yaml 3 | apiVersion: v1 4 | kind: PersistentVolumeClaim 5 | metadata: 6 | # This name uniquely identifies the PVC. This is used in deployment. 7 | name: minio-pv-claim 8 | spec: 9 | # Read more about access modes here: http://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes 10 | accessModes: 11 | # The volume is mounted as read-write by a single node 12 | - ReadWriteOnce 13 | resources: 14 | # This is the request for storage. Should be available in the cluster. 15 | requests: 16 | storage: 10Gi 17 | --- 18 | # source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-service.yaml 19 | apiVersion: v1 20 | kind: Service 21 | metadata: 22 | # This name uniquely identifies the service 23 | name: minio-service 24 | spec: 25 | type: LoadBalancer 26 | ports: 27 | - port: 9000 28 | targetPort: 9000 29 | protocol: TCP 30 | selector: 31 | # Looks for labels `app:minio` in the namespace and applies the spec 32 | app: minio 33 | --- 34 | # source: https://raw.githubusercontent.com/minio/minio/master/docs/orchestration/kubernetes/minio-standalone-deployment.yaml 35 | apiVersion: apps/v1 36 | kind: Deployment 37 | metadata: 38 | # This name uniquely identifies the Deployment 39 | name: minio 40 | spec: 41 | selector: 42 | matchLabels: 43 | app: minio # has to match .spec.template.metadata.labels 44 | strategy: 45 | # Specifies the strategy used to replace old Pods by new ones 46 | # Refer: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy 47 | type: Recreate 48 | template: 49 | metadata: 50 | labels: 51 | # This label is used as a selector in Service definition 52 | app: minio 53 | spec: 54 | # Volumes used by this deployment 55 | volumes: 56 | - name: data 57 | # This volume is based on PVC 58 | persistentVolumeClaim: 59 | # Name of the PVC created earlier 60 | claimName: minio-pv-claim 61 | containers: 62 | - name: minio 63 | # Volume mounts for this container 64 | volumeMounts: 65 | # Volume 'data' is mounted to path '/data' 66 | - name: data 67 | mountPath: "/data" 68 | # Pulls the lastest Minio image from Docker Hub 69 | image: minio/minio:RELEASE.2020-04-15T19-42-18Z 70 | args: 71 | - server 72 | - /data 73 | env: 74 | # MinIO access key and secret key 75 | - name: MINIO_ACCESS_KEY 76 | value: "minio" 77 | - name: MINIO_SECRET_KEY 78 | value: "minio123" 79 | ports: 80 | - containerPort: 9000 81 | # Readiness probe detects situations when MinIO server instance 82 | # is not ready to accept traffic. Kubernetes doesn't forward 83 | # traffic to the pod while readiness checks fail. 84 | readinessProbe: 85 | httpGet: 86 | path: /minio/health/ready 87 | port: 9000 88 | initialDelaySeconds: 120 89 | periodSeconds: 20 90 | # Liveness probe detects situations where MinIO server instance 91 | # is not working properly and needs restart. Kubernetes automatically 92 | # restarts the pods if liveness checks fail. 93 | livenessProbe: 94 | httpGet: 95 | path: /minio/health/live 96 | port: 9000 97 | initialDelaySeconds: 120 98 | periodSeconds: 20 99 | -------------------------------------------------------------------------------- /gateapi/docs/PipelineConfigControllerApi.md: -------------------------------------------------------------------------------- 1 | # \PipelineConfigControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**ConvertPipelineConfigToPipelineTemplateUsingGET**](PipelineConfigControllerApi.md#ConvertPipelineConfigToPipelineTemplateUsingGET) | **Get** /pipelineConfigs/{pipelineConfigId}/convertToTemplate | Convert a pipeline config to a pipeline template. 8 | [**GetAllPipelineConfigsUsingGET**](PipelineConfigControllerApi.md#GetAllPipelineConfigsUsingGET) | **Get** /pipelineConfigs | Get all pipeline configs. 9 | [**GetPipelineConfigHistoryUsingGET**](PipelineConfigControllerApi.md#GetPipelineConfigHistoryUsingGET) | **Get** /pipelineConfigs/{pipelineConfigId}/history | Get pipeline config history. 10 | 11 | 12 | # **ConvertPipelineConfigToPipelineTemplateUsingGET** 13 | > string ConvertPipelineConfigToPipelineTemplateUsingGET(ctx, pipelineConfigId) 14 | Convert a pipeline config to a pipeline template. 15 | 16 | ### Required Parameters 17 | 18 | Name | Type | Description | Notes 19 | ------------- | ------------- | ------------- | ------------- 20 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 21 | **pipelineConfigId** | **string**| pipelineConfigId | 22 | 23 | ### Return type 24 | 25 | **string** 26 | 27 | ### Authorization 28 | 29 | No authorization required 30 | 31 | ### HTTP request headers 32 | 33 | - **Content-Type**: Not defined 34 | - **Accept**: */* 35 | 36 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 37 | 38 | # **GetAllPipelineConfigsUsingGET** 39 | > []interface{} GetAllPipelineConfigsUsingGET(ctx, ) 40 | Get all pipeline configs. 41 | 42 | ### Required Parameters 43 | This endpoint does not need any parameter. 44 | 45 | ### Return type 46 | 47 | [**[]interface{}**](interface{}.md) 48 | 49 | ### Authorization 50 | 51 | No authorization required 52 | 53 | ### HTTP request headers 54 | 55 | - **Content-Type**: Not defined 56 | - **Accept**: */* 57 | 58 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 59 | 60 | # **GetPipelineConfigHistoryUsingGET** 61 | > []interface{} GetPipelineConfigHistoryUsingGET(ctx, pipelineConfigId, optional) 62 | Get pipeline config history. 63 | 64 | ### Required Parameters 65 | 66 | Name | Type | Description | Notes 67 | ------------- | ------------- | ------------- | ------------- 68 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 69 | **pipelineConfigId** | **string**| pipelineConfigId | 70 | **optional** | ***GetPipelineConfigHistoryUsingGETOpts** | optional parameters | nil if no parameters 71 | 72 | ### Optional Parameters 73 | Optional parameters are passed through a pointer to a GetPipelineConfigHistoryUsingGETOpts struct 74 | 75 | Name | Type | Description | Notes 76 | ------------- | ------------- | ------------- | ------------- 77 | 78 | **limit** | **optional.Int32**| limit | [default to 20] 79 | 80 | ### Return type 81 | 82 | [**[]interface{}**](interface{}.md) 83 | 84 | ### Authorization 85 | 86 | No authorization required 87 | 88 | ### HTTP request headers 89 | 90 | - **Content-Type**: Not defined 91 | - **Accept**: */* 92 | 93 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 94 | 95 | -------------------------------------------------------------------------------- /gateapi/api_plugin_publish_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "context" 14 | "io/ioutil" 15 | "net/http" 16 | "net/url" 17 | "strings" 18 | "fmt" 19 | "os" 20 | ) 21 | 22 | // Linger please 23 | var ( 24 | _ context.Context 25 | ) 26 | 27 | type PluginPublishControllerApiService service 28 | 29 | /* 30 | PluginPublishControllerApiService Publish a plugin binary and the plugin info metadata. 31 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 32 | * @param plugin plugin 33 | * @param pluginId pluginId 34 | * @param pluginInfo pluginInfo 35 | * @param pluginVersion pluginVersion 36 | 37 | 38 | */ 39 | func (a *PluginPublishControllerApiService) PublishPluginUsingPOST(ctx context.Context, plugin *os.File, pluginId string, pluginInfo interface{}, pluginVersion string) (*http.Response, error) { 40 | var ( 41 | localVarHttpMethod = strings.ToUpper("Post") 42 | localVarPostBody interface{} 43 | localVarFileName string 44 | localVarFileBytes []byte 45 | 46 | ) 47 | 48 | // create path and map variables 49 | localVarPath := a.client.cfg.BasePath + "/plugins/publish/{pluginId}/{pluginVersion}" 50 | localVarPath = strings.Replace(localVarPath, "{"+"pluginId"+"}", fmt.Sprintf("%v", pluginId), -1) 51 | localVarPath = strings.Replace(localVarPath, "{"+"pluginVersion"+"}", fmt.Sprintf("%v", pluginVersion), -1) 52 | 53 | localVarHeaderParams := make(map[string]string) 54 | localVarQueryParams := url.Values{} 55 | localVarFormParams := url.Values{} 56 | 57 | // to determine the Content-Type header 58 | localVarHttpContentTypes := []string{"multipart/form-data"} 59 | 60 | // set Content-Type header 61 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 62 | if localVarHttpContentType != "" { 63 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 64 | } 65 | 66 | // to determine the Accept header 67 | localVarHttpHeaderAccepts := []string{"*/*"} 68 | 69 | // set Accept header 70 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 71 | if localVarHttpHeaderAccept != "" { 72 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 73 | } 74 | var localVarFile *os.File 75 | if localVarFile != nil { 76 | fbs, _ := ioutil.ReadAll(localVarFile) 77 | localVarFileBytes = fbs 78 | localVarFileName = localVarFile.Name() 79 | localVarFile.Close() 80 | } 81 | localVarFormParams.Add("pluginInfo", parameterToString(pluginInfo, "")) 82 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 83 | if err != nil { 84 | return nil, err 85 | } 86 | 87 | localVarHttpResponse, err := a.client.callAPI(r) 88 | if err != nil || localVarHttpResponse == nil { 89 | return localVarHttpResponse, err 90 | } 91 | 92 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 93 | localVarHttpResponse.Body.Close() 94 | if err != nil { 95 | return localVarHttpResponse, err 96 | } 97 | 98 | 99 | if localVarHttpResponse.StatusCode >= 300 { 100 | newErr := GenericSwaggerError{ 101 | body: localVarBody, 102 | error: localVarHttpResponse.Status, 103 | } 104 | 105 | return localVarHttpResponse, newErr 106 | } 107 | 108 | return localVarHttpResponse, nil 109 | } 110 | -------------------------------------------------------------------------------- /gateapi/docs/ConcourseControllerApi.md: -------------------------------------------------------------------------------- 1 | # \ConcourseControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**JobsUsingGET**](ConcourseControllerApi.md#JobsUsingGET) | **Get** /concourse/{buildMaster}/teams/{team}/pipelines/{pipeline}/jobs | Retrieve the list of job names for a given pipeline available to triggers 8 | [**PipelinesUsingGET**](ConcourseControllerApi.md#PipelinesUsingGET) | **Get** /concourse/{buildMaster}/teams/{team}/pipelines | Retrieve the list of pipeline names for a given team available to triggers 9 | [**ResourcesUsingGET**](ConcourseControllerApi.md#ResourcesUsingGET) | **Get** /concourse/{buildMaster}/teams/{team}/pipelines/{pipeline}/resources | Retrieve the list of resource names for a given pipeline available to the Concourse stage 10 | 11 | 12 | # **JobsUsingGET** 13 | > []interface{} JobsUsingGET(ctx, buildMaster, pipeline, team) 14 | Retrieve the list of job names for a given pipeline available to triggers 15 | 16 | ### Required Parameters 17 | 18 | Name | Type | Description | Notes 19 | ------------- | ------------- | ------------- | ------------- 20 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 21 | **buildMaster** | **string**| buildMaster | 22 | **pipeline** | **string**| pipeline | 23 | **team** | **string**| team | 24 | 25 | ### Return type 26 | 27 | [**[]interface{}**](interface{}.md) 28 | 29 | ### Authorization 30 | 31 | No authorization required 32 | 33 | ### HTTP request headers 34 | 35 | - **Content-Type**: Not defined 36 | - **Accept**: */* 37 | 38 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 39 | 40 | # **PipelinesUsingGET** 41 | > []interface{} PipelinesUsingGET(ctx, buildMaster, team) 42 | Retrieve the list of pipeline names for a given team available to triggers 43 | 44 | ### Required Parameters 45 | 46 | Name | Type | Description | Notes 47 | ------------- | ------------- | ------------- | ------------- 48 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 49 | **buildMaster** | **string**| buildMaster | 50 | **team** | **string**| team | 51 | 52 | ### Return type 53 | 54 | [**[]interface{}**](interface{}.md) 55 | 56 | ### Authorization 57 | 58 | No authorization required 59 | 60 | ### HTTP request headers 61 | 62 | - **Content-Type**: Not defined 63 | - **Accept**: */* 64 | 65 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 66 | 67 | # **ResourcesUsingGET** 68 | > []interface{} ResourcesUsingGET(ctx, buildMaster, pipeline, team) 69 | Retrieve the list of resource names for a given pipeline available to the Concourse stage 70 | 71 | ### Required Parameters 72 | 73 | Name | Type | Description | Notes 74 | ------------- | ------------- | ------------- | ------------- 75 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 76 | **buildMaster** | **string**| buildMaster | 77 | **pipeline** | **string**| pipeline | 78 | **team** | **string**| team | 79 | 80 | ### Return type 81 | 82 | [**[]interface{}**](interface{}.md) 83 | 84 | ### Authorization 85 | 86 | No authorization required 87 | 88 | ### HTTP request headers 89 | 90 | - **Content-Type**: Not defined 91 | - **Accept**: */* 92 | 93 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 94 | 95 | -------------------------------------------------------------------------------- /gateapi/docs/ServerGroupControllerApi.md: -------------------------------------------------------------------------------- 1 | # \ServerGroupControllerApi 2 | 3 | All URIs are relative to *https://localhost* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**GetServerGroupDetailsUsingGET**](ServerGroupControllerApi.md#GetServerGroupDetailsUsingGET) | **Get** /applications/{applicationName}/serverGroups/{account}/{region}/{serverGroupName} | Retrieve a server group's details 8 | [**GetServerGroupsForApplicationUsingGET**](ServerGroupControllerApi.md#GetServerGroupsForApplicationUsingGET) | **Get** /applications/{applicationName}/serverGroups | Retrieve a list of server groups for a given application 9 | 10 | 11 | # **GetServerGroupDetailsUsingGET** 12 | > interface{} GetServerGroupDetailsUsingGET(ctx, account, applicationName, region, serverGroupName, optional) 13 | Retrieve a server group's details 14 | 15 | ### Required Parameters 16 | 17 | Name | Type | Description | Notes 18 | ------------- | ------------- | ------------- | ------------- 19 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 20 | **account** | **string**| account | 21 | **applicationName** | **string**| applicationName | 22 | **region** | **string**| region | 23 | **serverGroupName** | **string**| serverGroupName | 24 | **optional** | ***GetServerGroupDetailsUsingGETOpts** | optional parameters | nil if no parameters 25 | 26 | ### Optional Parameters 27 | Optional parameters are passed through a pointer to a GetServerGroupDetailsUsingGETOpts struct 28 | 29 | Name | Type | Description | Notes 30 | ------------- | ------------- | ------------- | ------------- 31 | 32 | 33 | 34 | 35 | **xRateLimitApp** | **optional.String**| X-RateLimit-App | 36 | **includeDetails** | **optional.String**| includeDetails | [default to true] 37 | 38 | ### Return type 39 | 40 | [**interface{}**](interface{}.md) 41 | 42 | ### Authorization 43 | 44 | No authorization required 45 | 46 | ### HTTP request headers 47 | 48 | - **Content-Type**: Not defined 49 | - **Accept**: */* 50 | 51 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 52 | 53 | # **GetServerGroupsForApplicationUsingGET** 54 | > []interface{} GetServerGroupsForApplicationUsingGET(ctx, applicationName, optional) 55 | Retrieve a list of server groups for a given application 56 | 57 | ### Required Parameters 58 | 59 | Name | Type | Description | Notes 60 | ------------- | ------------- | ------------- | ------------- 61 | **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. 62 | **applicationName** | **string**| applicationName | 63 | **optional** | ***GetServerGroupsForApplicationUsingGETOpts** | optional parameters | nil if no parameters 64 | 65 | ### Optional Parameters 66 | Optional parameters are passed through a pointer to a GetServerGroupsForApplicationUsingGETOpts struct 67 | 68 | Name | Type | Description | Notes 69 | ------------- | ------------- | ------------- | ------------- 70 | 71 | **xRateLimitApp** | **optional.String**| X-RateLimit-App | 72 | **cloudProvider** | **optional.String**| cloudProvider | 73 | **clusters** | **optional.String**| clusters | 74 | **expand** | **optional.String**| expand | [default to false] 75 | 76 | ### Return type 77 | 78 | [**[]interface{}**](interface{}.md) 79 | 80 | ### Authorization 81 | 82 | No authorization required 83 | 84 | ### HTTP request headers 85 | 86 | - **Content-Type**: Not defined 87 | - **Accept**: */* 88 | 89 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 90 | 91 | -------------------------------------------------------------------------------- /gateapi/api_version_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "context" 14 | "io/ioutil" 15 | "net/http" 16 | "net/url" 17 | "strings" 18 | ) 19 | 20 | // Linger please 21 | var ( 22 | _ context.Context 23 | ) 24 | 25 | type VersionControllerApiService service 26 | 27 | /* 28 | VersionControllerApiService Fetch Gate's current version 29 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 30 | 31 | @return Version 32 | */ 33 | func (a *VersionControllerApiService) GetVersionUsingGET(ctx context.Context) (Version, *http.Response, error) { 34 | var ( 35 | localVarHttpMethod = strings.ToUpper("Get") 36 | localVarPostBody interface{} 37 | localVarFileName string 38 | localVarFileBytes []byte 39 | localVarReturnValue Version 40 | ) 41 | 42 | // create path and map variables 43 | localVarPath := a.client.cfg.BasePath + "/version" 44 | 45 | localVarHeaderParams := make(map[string]string) 46 | localVarQueryParams := url.Values{} 47 | localVarFormParams := url.Values{} 48 | 49 | // to determine the Content-Type header 50 | localVarHttpContentTypes := []string{} 51 | 52 | // set Content-Type header 53 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 54 | if localVarHttpContentType != "" { 55 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 56 | } 57 | 58 | // to determine the Accept header 59 | localVarHttpHeaderAccepts := []string{"*/*"} 60 | 61 | // set Accept header 62 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 63 | if localVarHttpHeaderAccept != "" { 64 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 65 | } 66 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 67 | if err != nil { 68 | return localVarReturnValue, nil, err 69 | } 70 | 71 | localVarHttpResponse, err := a.client.callAPI(r) 72 | if err != nil || localVarHttpResponse == nil { 73 | return localVarReturnValue, localVarHttpResponse, err 74 | } 75 | 76 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 77 | localVarHttpResponse.Body.Close() 78 | if err != nil { 79 | return localVarReturnValue, localVarHttpResponse, err 80 | } 81 | 82 | if localVarHttpResponse.StatusCode < 300 { 83 | // If we succeed, return the data, otherwise pass on to decode error. 84 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 85 | if err == nil { 86 | return localVarReturnValue, localVarHttpResponse, err 87 | } 88 | } 89 | 90 | if localVarHttpResponse.StatusCode >= 300 { 91 | newErr := GenericSwaggerError{ 92 | body: localVarBody, 93 | error: localVarHttpResponse.Status, 94 | } 95 | 96 | if localVarHttpResponse.StatusCode == 200 { 97 | var v Version 98 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 99 | if err != nil { 100 | newErr.error = err.Error() 101 | return localVarReturnValue, localVarHttpResponse, newErr 102 | } 103 | newErr.model = v 104 | return localVarReturnValue, localVarHttpResponse, newErr 105 | } 106 | 107 | return localVarReturnValue, localVarHttpResponse, newErr 108 | } 109 | 110 | return localVarReturnValue, localVarHttpResponse, nil 111 | } 112 | -------------------------------------------------------------------------------- /gateclient/gateclient.go: -------------------------------------------------------------------------------- 1 | package gateclient 2 | 3 | import ( 4 | "crypto/tls" 5 | "fmt" 6 | "net/http" 7 | "net/http/cookiejar" 8 | "strings" 9 | "time" 10 | 11 | "github.com/codilime/floodgate/config" 12 | gateapi "github.com/codilime/floodgate/gateapi" 13 | log "github.com/sirupsen/logrus" 14 | "golang.org/x/net/context" 15 | ) 16 | 17 | // GateapiClient is a Client for Gate API which has instance-specific information. 18 | type GateapiClient struct { 19 | // Gate API Client 20 | *gateapi.APIClient 21 | 22 | // request context 23 | Context context.Context 24 | } 25 | 26 | // NewGateapiClient creates instance of Gate API wrapper based on Floodgate's Config 27 | func NewGateapiClient(floodgateConfig *config.Config) *GateapiClient { 28 | cookieJar, _ := cookiejar.New(nil) 29 | var gateHTTPClient = &http.Client{ 30 | Timeout: time.Duration(floodgateConfig.Timeout) * time.Second, 31 | Transport: &http.Transport{ 32 | TLSClientConfig: &tls.Config{InsecureSkipVerify: floodgateConfig.Insecure}, 33 | }, 34 | Jar: cookieJar, 35 | } 36 | 37 | var auth context.Context 38 | if floodgateConfig.Auth.Basic.Enabled { 39 | auth = context.WithValue(context.Background(), gateapi.ContextBasicAuth, gateapi.BasicAuth{ 40 | UserName: floodgateConfig.Auth.Basic.User, 41 | Password: floodgateConfig.Auth.Basic.Password, 42 | }) 43 | } 44 | 45 | if floodgateConfig.Auth.OAuth2.Enabled { 46 | token, err := OAuth2Authenticate(floodgateConfig) 47 | if err != nil { 48 | log.Fatalf("can't authenticate with oauth2: %v", err) 49 | } 50 | 51 | auth = context.WithValue(context.Background(), gateapi.ContextAccessToken, token.AccessToken) 52 | } 53 | 54 | if floodgateConfig.Auth.X509.Enabled { 55 | client, err := X509Authenticate(gateHTTPClient, floodgateConfig) 56 | if err != nil { 57 | log.Fatalf("can't authenticate with x509: %v", err) 58 | } 59 | 60 | gateHTTPClient = client 61 | } 62 | 63 | cfg := gateapi.NewConfiguration() 64 | cfg.BasePath = floodgateConfig.Endpoint 65 | cfg.HTTPClient = gateHTTPClient 66 | client := gateapi.NewAPIClient(cfg) 67 | 68 | return &GateapiClient{ 69 | APIClient: client, 70 | Context: auth, 71 | } 72 | } 73 | 74 | // WaitForSuccessfulTask function is waiting for task to finish 75 | func (c GateapiClient) WaitForSuccessfulTask(checkTask map[string]interface{}, maxRetries int) error { 76 | taskID := strings.Split(checkTask["ref"].(string), "/")[2] 77 | 78 | task, resp, err := c.TaskControllerApi.GetTaskUsingGET1(c.Context, taskID) 79 | 80 | retry := 0 81 | 82 | for (checkTask == nil || !isTaskCompleted(task)) && (retry < maxRetries) { 83 | retry++ 84 | log.Tracef("Polling task status... (%d/%d)", retry, maxRetries) 85 | time.Sleep(time.Duration(retry*retry) * time.Second) 86 | task, resp, err = c.TaskControllerApi.GetTaskUsingGET1(c.Context, taskID) 87 | } 88 | if err != nil { 89 | return err 90 | } 91 | if resp.StatusCode != 200 { 92 | return fmt.Errorf("encountered an error while polling for task: %s", taskID) 93 | } 94 | if !isTaskSuccessful(task) { 95 | return fmt.Errorf("encountered an error in task: %s", taskID) 96 | } 97 | 98 | return nil 99 | } 100 | 101 | func isTaskCompleted(task map[string]interface{}) bool { 102 | status, exists := task["status"] 103 | if !exists { 104 | return false 105 | } 106 | 107 | switch status.(string) { 108 | case 109 | "SUCCEEDED", 110 | "STOPPED", 111 | "SKIPPED", 112 | "TERMINAL", 113 | "FAILED_CONTINUE": 114 | return true 115 | } 116 | return false 117 | } 118 | 119 | func isTaskSuccessful(task map[string]interface{}) bool { 120 | status, exists := task["status"] 121 | if !exists { 122 | return false 123 | } 124 | 125 | switch status.(string) { 126 | case 127 | "SUCCEEDED", 128 | "STOPPED", 129 | "SKIPPED": 130 | return true 131 | } 132 | return false 133 | } 134 | -------------------------------------------------------------------------------- /gateapi/api_pubsub_subscription_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "context" 14 | "io/ioutil" 15 | "net/http" 16 | "net/url" 17 | "strings" 18 | ) 19 | 20 | // Linger please 21 | var ( 22 | _ context.Context 23 | ) 24 | 25 | type PubsubSubscriptionControllerApiService service 26 | 27 | /* 28 | PubsubSubscriptionControllerApiService Retrieve the list of pub/sub subscriptions configured in Echo. 29 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 30 | 31 | @return []Mapstringstring 32 | */ 33 | func (a *PubsubSubscriptionControllerApiService) AllUsingGET4(ctx context.Context) ([]Mapstringstring, *http.Response, error) { 34 | var ( 35 | localVarHttpMethod = strings.ToUpper("Get") 36 | localVarPostBody interface{} 37 | localVarFileName string 38 | localVarFileBytes []byte 39 | localVarReturnValue []Mapstringstring 40 | ) 41 | 42 | // create path and map variables 43 | localVarPath := a.client.cfg.BasePath + "/pubsub/subscriptions" 44 | 45 | localVarHeaderParams := make(map[string]string) 46 | localVarQueryParams := url.Values{} 47 | localVarFormParams := url.Values{} 48 | 49 | // to determine the Content-Type header 50 | localVarHttpContentTypes := []string{} 51 | 52 | // set Content-Type header 53 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 54 | if localVarHttpContentType != "" { 55 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 56 | } 57 | 58 | // to determine the Accept header 59 | localVarHttpHeaderAccepts := []string{"*/*"} 60 | 61 | // set Accept header 62 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 63 | if localVarHttpHeaderAccept != "" { 64 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 65 | } 66 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 67 | if err != nil { 68 | return localVarReturnValue, nil, err 69 | } 70 | 71 | localVarHttpResponse, err := a.client.callAPI(r) 72 | if err != nil || localVarHttpResponse == nil { 73 | return localVarReturnValue, localVarHttpResponse, err 74 | } 75 | 76 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 77 | localVarHttpResponse.Body.Close() 78 | if err != nil { 79 | return localVarReturnValue, localVarHttpResponse, err 80 | } 81 | 82 | if localVarHttpResponse.StatusCode < 300 { 83 | // If we succeed, return the data, otherwise pass on to decode error. 84 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 85 | if err == nil { 86 | return localVarReturnValue, localVarHttpResponse, err 87 | } 88 | } 89 | 90 | if localVarHttpResponse.StatusCode >= 300 { 91 | newErr := GenericSwaggerError{ 92 | body: localVarBody, 93 | error: localVarHttpResponse.Status, 94 | } 95 | 96 | if localVarHttpResponse.StatusCode == 200 { 97 | var v []Mapstringstring 98 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 99 | if err != nil { 100 | newErr.error = err.Error() 101 | return localVarReturnValue, localVarHttpResponse, newErr 102 | } 103 | newErr.model = v 104 | return localVarReturnValue, localVarHttpResponse, newErr 105 | } 106 | 107 | return localVarReturnValue, localVarHttpResponse, newErr 108 | } 109 | 110 | return localVarReturnValue, localVarHttpResponse, nil 111 | } 112 | -------------------------------------------------------------------------------- /cmd/root_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path" 8 | "runtime" 9 | "strings" 10 | ) 11 | 12 | func CreateTempFiles(endpoint string, createSponnet bool) (string, string, error) { 13 | dir, err := ioutil.TempDir("", "testing") 14 | if err != nil { 15 | return "", "", err 16 | } 17 | 18 | //Create applications dir with example json app declaration 19 | applicationsDir, err := ioutil.TempDir(dir, "applications") 20 | if err != nil { 21 | return "", "", err 22 | } 23 | 24 | application, err := ioutil.TempFile(applicationsDir, "*.jsonapp.json") 25 | if err != nil { 26 | return "", "", err 27 | } 28 | ioutil.WriteFile(application.Name(), []byte("{\n \"cloudProviders\": \"kubernetes\",\n \"dataSources\": {\n \"disabled\": [],\n \"enabled\": []\n },\n \"description\": \"Example application created from JSON file.\",\n \"email\": \"example@example.com\",\n \"name\": \"jsonapp\",\n \"platformHealthOnly\": false,\n \"platformHealthOnlyShowOverride\": false,\n \"providerSettings\": {\n \"aws\": {\n \"useAmiBlockDeviceMappings\": false\n },\n \"gce\": {\n \"associatePublicIpAddress\": false\n }\n },\n \"trafficGuards\": [],\n \"user\": \"floodgate@example.com\"\n}"), 0644) 29 | 30 | //Create pipelines dir with example json pipeline declaration 31 | pipelinesDir, err := ioutil.TempDir(dir, "pipelines") 32 | if err != nil { 33 | return "", "", err 34 | } 35 | 36 | if createSponnet { 37 | pipelineJsonnet, err := ioutil.TempFile(pipelinesDir, "*.jsonnetpipeline.jsonnet") 38 | if err != nil { 39 | return "", "", err 40 | } 41 | ioutil.WriteFile(pipelineJsonnet.Name(), []byte("local pipelines = import 'pipeline.libsonnet';\n\npipelines.pipeline()\n.withName('Example pipeline from Jsonnet')\n.withId('jsonnetpipeline')\n.withApplication('jsonnetapp')"), 0644) 42 | 43 | } 44 | pipeline, err := ioutil.TempFile(pipelinesDir, "*.jsonpipeline.json") 45 | if err != nil { 46 | return "", "", err 47 | } 48 | ioutil.WriteFile(pipeline.Name(), []byte("{\n \"application\": \"jsonnetapp\",\n \"id\": \"jsonnetpipeline\",\n \"keepWaitingPipelines\": false,\n \"limitConcurrent\": true,\n \"name\": \"Example pipeline from Jsonnet\",\n \"notifications\": [ ],\n \"stages\": [ ],\n \"triggers\": [ ]\n}\n"), 0644) 49 | 50 | //Create pipeline templates dir with example json pipeline template declaration 51 | pipelineTemplatesDir, err := ioutil.TempDir(dir, "pipelinetemplates") 52 | if err != nil { 53 | return "", "", err 54 | } 55 | 56 | pipelineTemplate, err := ioutil.TempFile(pipelineTemplatesDir, "*.jsonpipeline.json") 57 | if err != nil { 58 | return "", "", err 59 | } 60 | ioutil.WriteFile(pipelineTemplate.Name(), []byte("{\n \"id\": \"jsonnetpt\",\n \"metadata\": {\n \"description\": \"Example pipeline template created from Jsonnet file.\",\n \"name\": \"Example pipeline template from Jsonnet\",\n \"owner\": \"floodgate@example.com\",\n \"scopes\": [\n \"global\"\n ]\n },\n \"protect\": false,\n \"schema\": \"v2\",\n \"variables\": [ ]\n}"), 0644) 61 | 62 | //Get sponnet directory 63 | _, filename, _, _ := runtime.Caller(0) 64 | sponnetDir := path.Join(path.Dir(filename), "../sponnet") 65 | 66 | //Create config file 67 | config, err := ioutil.TempFile(dir, "*.config.yaml") 68 | if err != nil { 69 | return "", "", err 70 | } 71 | configStr := fmt.Sprintf("endpoint: %s\ninsecure: true\nauth:\n basic:\n enabled: true\n user: admin\n password: VRCm9L80yO3FHTKeVthtxknfGq1b10WqInKoBFqozphGcrGi\nlibraries:\n - %s\nresources:\n - %s\n - %s\n - %s", endpoint, sponnetDir, applicationsDir, pipelinesDir, pipelineTemplatesDir) 72 | ioutil.WriteFile(config.Name(), []byte(configStr), 0644) 73 | 74 | return dir, config.Name(), nil 75 | } 76 | 77 | func RemoveTempDir(dir string) { 78 | if dir != "" && strings.HasPrefix(dir, "/tmp/testing") { 79 | os.RemoveAll(dir) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /gateapi/api_subnet_controller.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Spinnaker API 3 | * 4 | * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 5 | * 6 | * API version: 1.0.0 7 | * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 8 | */ 9 | 10 | package swagger 11 | 12 | import ( 13 | "context" 14 | "io/ioutil" 15 | "net/http" 16 | "net/url" 17 | "strings" 18 | "fmt" 19 | ) 20 | 21 | // Linger please 22 | var ( 23 | _ context.Context 24 | ) 25 | 26 | type SubnetControllerApiService service 27 | 28 | /* 29 | SubnetControllerApiService Retrieve a list of subnets for a given cloud provider 30 | * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 31 | * @param cloudProvider cloudProvider 32 | 33 | @return []interface{} 34 | */ 35 | func (a *SubnetControllerApiService) AllByCloudProviderUsingGET1(ctx context.Context, cloudProvider string) ([]interface{}, *http.Response, error) { 36 | var ( 37 | localVarHttpMethod = strings.ToUpper("Get") 38 | localVarPostBody interface{} 39 | localVarFileName string 40 | localVarFileBytes []byte 41 | localVarReturnValue []interface{} 42 | ) 43 | 44 | // create path and map variables 45 | localVarPath := a.client.cfg.BasePath + "/subnets/{cloudProvider}" 46 | localVarPath = strings.Replace(localVarPath, "{"+"cloudProvider"+"}", fmt.Sprintf("%v", cloudProvider), -1) 47 | 48 | localVarHeaderParams := make(map[string]string) 49 | localVarQueryParams := url.Values{} 50 | localVarFormParams := url.Values{} 51 | 52 | // to determine the Content-Type header 53 | localVarHttpContentTypes := []string{} 54 | 55 | // set Content-Type header 56 | localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 57 | if localVarHttpContentType != "" { 58 | localVarHeaderParams["Content-Type"] = localVarHttpContentType 59 | } 60 | 61 | // to determine the Accept header 62 | localVarHttpHeaderAccepts := []string{"*/*"} 63 | 64 | // set Accept header 65 | localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 66 | if localVarHttpHeaderAccept != "" { 67 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 68 | } 69 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 70 | if err != nil { 71 | return localVarReturnValue, nil, err 72 | } 73 | 74 | localVarHttpResponse, err := a.client.callAPI(r) 75 | if err != nil || localVarHttpResponse == nil { 76 | return localVarReturnValue, localVarHttpResponse, err 77 | } 78 | 79 | localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 80 | localVarHttpResponse.Body.Close() 81 | if err != nil { 82 | return localVarReturnValue, localVarHttpResponse, err 83 | } 84 | 85 | if localVarHttpResponse.StatusCode < 300 { 86 | // If we succeed, return the data, otherwise pass on to decode error. 87 | err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 88 | if err == nil { 89 | return localVarReturnValue, localVarHttpResponse, err 90 | } 91 | } 92 | 93 | if localVarHttpResponse.StatusCode >= 300 { 94 | newErr := GenericSwaggerError{ 95 | body: localVarBody, 96 | error: localVarHttpResponse.Status, 97 | } 98 | 99 | if localVarHttpResponse.StatusCode == 200 { 100 | var v []interface{} 101 | err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 102 | if err != nil { 103 | newErr.error = err.Error() 104 | return localVarReturnValue, localVarHttpResponse, newErr 105 | } 106 | newErr.model = v 107 | return localVarReturnValue, localVarHttpResponse, newErr 108 | } 109 | 110 | return localVarReturnValue, localVarHttpResponse, newErr 111 | } 112 | 113 | return localVarReturnValue, localVarHttpResponse, nil 114 | } 115 | --------------------------------------------------------------------------------