Skip to content

Commit

Permalink
Fixed null error
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Jan 21, 2021
1 parent 59866af commit b96d207
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion octopusdeploy/schema_endpoint.go
Expand Up @@ -61,7 +61,7 @@ func flattenEndpoint(endpoint *octopusdeploy.EndpointResource) []interface{} {
"connection_endpoint": endpoint.ConnectionEndpoint,
"container": flattenDeploymentActionContainer(endpoint.Container),
"default_worker_pool_id": endpoint.DefaultWorkerPoolID,
"destination": flattenOfflinePackageDropDestination(*endpoint.Destination),
"destination": flattenOfflinePackageDropDestination(endpoint.Destination),
"dot_net_core_platform": endpoint.DotNetCorePlatform,
"fingerprint": endpoint.Fingerprint,
"host": endpoint.Host,
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/schema_offline_package_drop.go
Expand Up @@ -19,7 +19,7 @@ func expandOfflinePackageDrop(flattenedMap map[string]interface{}) *octopusdeplo
func flattenOfflinePackageDrop(endpoint octopusdeploy.OfflinePackageDropEndpoint) []interface{} {
rawEndpoint := map[string]interface{}{
"applications_directory": endpoint.ApplicationsDirectory,
"destination": flattenOfflinePackageDropDestination(endpoint.Destination),
"destination": flattenOfflinePackageDropDestination(&endpoint.Destination),
"id": endpoint.GetID(),
"working_directory": endpoint.WorkingDirectory,
}
Expand Down
Expand Up @@ -36,7 +36,7 @@ func flattenOfflinePackageDropDeploymentTarget(deploymentTarget *octopusdeploy.D
flattenedDeploymentTarget := flattenDeploymentTarget(deploymentTarget)
endpointResource, _ := octopusdeploy.ToEndpointResource(deploymentTarget.Endpoint)
flattenedDeploymentTarget["applications_directory"] = endpointResource.ApplicationsDirectory
flattenedDeploymentTarget["destination"] = flattenOfflinePackageDropDestination(*endpointResource.Destination)
flattenedDeploymentTarget["destination"] = flattenOfflinePackageDropDestination(endpointResource.Destination)
flattenedDeploymentTarget["working_directory"] = endpointResource.WorkingDirectory
return flattenedDeploymentTarget
}
Expand Down Expand Up @@ -94,7 +94,7 @@ func setOfflinePackageDropDeploymentTarget(ctx context.Context, d *schema.Resour

d.Set("applications_directory", endpointResource.ApplicationsDirectory)

if err := d.Set("destination", flattenOfflinePackageDropDestination(*endpointResource.Destination)); err != nil {
if err := d.Set("destination", flattenOfflinePackageDropDestination(endpointResource.Destination)); err != nil {
return fmt.Errorf("error setting destination: %s", err)
}

Expand Down
6 changes: 5 additions & 1 deletion octopusdeploy/schema_offline_package_drop_destination.go
Expand Up @@ -19,7 +19,11 @@ func expandOfflinePackageDropDestination(values interface{}) octopusdeploy.Offli
}
}

func flattenOfflinePackageDropDestination(offlineDropDestination octopusdeploy.OfflinePackageDropDestination) []interface{} {
func flattenOfflinePackageDropDestination(offlineDropDestination *octopusdeploy.OfflinePackageDropDestination) []interface{} {
if offlineDropDestination == nil {
return nil
}

return []interface{}{map[string]interface{}{
"destination_type": offlineDropDestination.DestinationType,
"drop_folder_path": offlineDropDestination.DropFolderPath,
Expand Down

0 comments on commit b96d207

Please sign in to comment.